package org.apache.avro; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.TextNode; import j$.util.DesugarCollections; import j$.util.concurrent.ConcurrentHashMap; import j$.util.concurrent.ConcurrentMap; import java.io.IOException; import java.util.AbstractSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Queue; import java.util.Set; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentMap; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Function; import org.apache.avro.util.MapEntry; import org.apache.avro.util.internal.Accessor; import org.apache.avro.util.internal.JacksonUtils; /* compiled from: OperaSrc */ /* loaded from: classes9.dex */ public abstract class JsonProperties { public static final Null NULL_VALUE; private ConcurrentMap props = new AnonymousClass2(); private Set reserved; /* compiled from: OperaSrc */ /* renamed from: org.apache.avro.JsonProperties$2, reason: invalid class name */ /* loaded from: classes9.dex */ public class AnonymousClass2 extends ConcurrentHashMap implements j$.util.concurrent.ConcurrentMap { private static final long serialVersionUID = 1; private Queue> propOrder = new ConcurrentLinkedQueue(); public AnonymousClass2() { } @Override // j$.util.concurrent.ConcurrentHashMap, java.util.Map, java.util.concurrent.ConcurrentMap, j$.util.Map public final /* synthetic */ Object compute(Object obj, BiFunction biFunction) { return ConcurrentMap.-CC.$default$compute(this, obj, biFunction); } @Override // j$.util.concurrent.ConcurrentHashMap, java.util.Map, java.util.concurrent.ConcurrentMap, j$.util.Map public final /* synthetic */ Object computeIfAbsent(Object obj, Function function) { return ConcurrentMap.-CC.$default$computeIfAbsent(this, obj, function); } @Override // j$.util.concurrent.ConcurrentHashMap, java.util.Map, java.util.concurrent.ConcurrentMap, j$.util.Map public final /* synthetic */ Object computeIfPresent(Object obj, BiFunction biFunction) { return ConcurrentMap.-CC.$default$computeIfPresent(this, obj, biFunction); } @Override // j$.util.concurrent.ConcurrentHashMap, java.util.AbstractMap, java.util.Map public Set> entrySet() { return new AbstractSet>() { // from class: org.apache.avro.JsonProperties.2.1 @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator> iterator() { return new Iterator>() { // from class: org.apache.avro.JsonProperties.2.1.1 Iterator> it; { this.it = AnonymousClass2.this.propOrder.iterator(); } @Override // java.util.Iterator public boolean hasNext() { return this.it.hasNext(); } @Override // java.util.Iterator public Map.Entry next() { return this.it.next(); } }; } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public int size() { return AnonymousClass2.this.propOrder.size(); } }; } @Override // j$.util.concurrent.ConcurrentHashMap, java.util.Map, java.util.concurrent.ConcurrentMap, j$.util.Map public final /* synthetic */ void forEach(BiConsumer biConsumer) { ConcurrentMap.-CC.$default$forEach(this, biConsumer); } @Override // j$.util.concurrent.ConcurrentHashMap, java.util.Map, java.util.concurrent.ConcurrentMap, j$.util.Map public final /* synthetic */ Object getOrDefault(Object obj, Object obj2) { return ConcurrentMap.-CC.$default$getOrDefault(this, obj, obj2); } @Override // j$.util.concurrent.ConcurrentHashMap, java.util.Map, java.util.concurrent.ConcurrentMap, j$.util.Map public final /* synthetic */ Object merge(Object obj, Object obj2, BiFunction biFunction) { return ConcurrentMap.-CC.$default$merge(this, obj, obj2, biFunction); } @Override // j$.util.concurrent.ConcurrentHashMap, java.util.Map, java.util.concurrent.ConcurrentMap, j$.util.Map public final /* synthetic */ void replaceAll(BiFunction biFunction) { ConcurrentMap.-CC.$default$replaceAll(this, biFunction); } @Override // j$.util.concurrent.ConcurrentHashMap, java.util.AbstractMap, java.util.Map public JsonNode put(String str, JsonNode jsonNode) { return putIfAbsent(str, jsonNode); } @Override // j$.util.concurrent.ConcurrentHashMap, java.util.Map, java.util.concurrent.ConcurrentMap, j$.util.Map public JsonNode putIfAbsent(String str, JsonNode jsonNode) { JsonNode jsonNode2 = (JsonNode) super.putIfAbsent((AnonymousClass2) str, (String) jsonNode); if (jsonNode2 == null) { this.propOrder.add(new MapEntry<>(str, jsonNode)); } return jsonNode2; } } /* compiled from: OperaSrc */ /* loaded from: classes9.dex */ public static class Null { private Null() { } } static { Accessor.setAccessor(new Accessor.JsonPropertiesAccessor() { // from class: org.apache.avro.JsonProperties.1 @Override // org.apache.avro.util.internal.Accessor.JsonPropertiesAccessor public void addProp(JsonProperties jsonProperties, String str, JsonNode jsonNode) { jsonProperties.addProp(str, jsonNode); } }); NULL_VALUE = new Null(); } public JsonProperties(Set set) { this.reserved = set; } private JsonNode getJsonProp(String str) { return this.props.get(str); } public void addAllProps(JsonProperties jsonProperties) { for (Map.Entry entry : jsonProperties.props.entrySet()) { addProp(entry.getKey(), entry.getValue()); } } public void addProp(String str, String str2) { addProp(str, (JsonNode) TextNode.valueOf(str2)); } public Object getObjectProp(String str) { return JacksonUtils.toObject(this.props.get(str)); } public Map getObjectProps() { LinkedHashMap linkedHashMap = new LinkedHashMap(); for (Map.Entry entry : this.props.entrySet()) { linkedHashMap.put(entry.getKey(), JacksonUtils.toObject(entry.getValue())); } return DesugarCollections.unmodifiableMap(linkedHashMap); } public String getProp(String str) { JsonNode jsonProp = getJsonProp(str); if (jsonProp != null && jsonProp.isTextual()) { return jsonProp.textValue(); } return null; } public boolean hasProps() { return !this.props.isEmpty(); } public boolean propsEqual(JsonProperties jsonProperties) { return this.props.equals(jsonProperties.props); } public int propsHashCode() { return this.props.hashCode(); } public void putAll(JsonProperties jsonProperties) { for (Map.Entry entry : jsonProperties.props.entrySet()) { addProp(entry.getKey(), entry.getValue()); } } public void writeProps(JsonGenerator jsonGenerator) throws IOException { for (Map.Entry entry : this.props.entrySet()) { jsonGenerator.writeObjectField(entry.getKey(), entry.getValue()); } } public void addProp(String str, Object obj) { if (obj instanceof JsonNode) { addProp(str, (JsonNode) obj); } else { addProp(str, JacksonUtils.toJsonNode(obj)); } } public JsonProperties(Set set, Map map) { JsonNode jsonNode; this.reserved = set; for (Map.Entry entry : map.entrySet()) { Object value = entry.getValue(); if (value instanceof String) { jsonNode = TextNode.valueOf((String) value); } else if (value instanceof JsonNode) { jsonNode = (JsonNode) value; } else { jsonNode = JacksonUtils.toJsonNode(value); } this.props.put(entry.getKey(), jsonNode); } } /* JADX INFO: Access modifiers changed from: private */ public void addProp(String str, JsonNode jsonNode) { if (this.reserved.contains(str)) { throw new AvroRuntimeException("Can't set reserved property: " + str); } if (jsonNode != null) { JsonNode putIfAbsent = this.props.putIfAbsent(str, jsonNode); if (putIfAbsent == null || putIfAbsent.equals(jsonNode)) { return; } throw new AvroRuntimeException("Can't overwrite property: " + str); } throw new AvroRuntimeException("Can't set a property to null: " + str); } }