@Override public boolean containsKey(Object key) { // works fine since null values are not supported return get(key) != null; }
/** Returns the field for the given field */ public MappedFieldType get(String field) { String concreteField = aliasToConcreteName.getOrDefault(field, field); return fullNameToFieldType.get(concreteField); }
public Mapper getMapper(String field) { return mappers.get(field); }
/** Returns the field for the given field */ public MappedFieldType get(String field) { String concreteField = aliasToConcreteName.getOrDefault(field, field); return fullNameToFieldType.get(concreteField); }
/** * Get the set of types that have a mapping for the given field. * Note: this method is only visible for testing. **/ protected Set<String> getTypes(String field) { Set<String> types = fullNameToTypes.get(field); if (types == null) { types = Collections.emptySet(); } return types; }
/** Returns the field for the given field */ public MappedFieldType get(String field) { String concreteField = aliasToConcreteName.getOrDefault(field, field); return fullNameToFieldType.get(concreteField); }
private static CopyOnWriteHashMap<String, Set<String>> addType(CopyOnWriteHashMap<String, Set<String>> map, String key, String type) { Set<String> types = map.get(key); if (types == null) { return map.copyAndPut(key, Collections.singleton(type)); } else if (types.contains(type)) { // noting to do return map; } else { Set<String> newTypes = new HashSet<>(types.size() + 1); newTypes.addAll(types); newTypes.add(type); assert newTypes.size() == types.size() + 1; newTypes = Collections.unmodifiableSet(newTypes); return map.copyAndPut(key, newTypes); } }
/** * Checks if the given field type is compatible with an existing field type. * An IllegalArgumentException is thrown in case of incompatibility. * If updateAllTypes is true, only basic compatibility is checked. */ private void validateField(String type, MappedFieldType existingFieldType, MappedFieldType newFieldType, CopyOnWriteHashMap<String, String> aliasToConcreteName, boolean updateAllTypes) { String fieldName = newFieldType.name(); if (aliasToConcreteName.containsKey(fieldName)) { throw new IllegalArgumentException("The name for field [" + fieldName + "] has already" + " been used to define a field alias."); } if (existingFieldType != null) { List<String> conflicts = new ArrayList<>(); final Set<String> types = fullNameToTypes.get(newFieldType.name()); boolean strict = beStrict(type, types, updateAllTypes); existingFieldType.checkCompatibility(newFieldType, conflicts, strict); if (conflicts.isEmpty() == false) { throw new IllegalArgumentException("Mapper for [" + fieldName + "] conflicts with existing mapping in other types:\n" + conflicts.toString()); } } }
MappedFieldType fullNameFieldType = fullName.get(fieldType.name());
protected void doMerge(final ObjectMapper mergeWith, boolean updateAllTypes) { if (nested().isNested()) { if (!mergeWith.nested().isNested()) { throw new IllegalArgumentException("object mapping [" + name() + "] can't be changed from nested to non-nested"); } } else { if (mergeWith.nested().isNested()) { throw new IllegalArgumentException("object mapping [" + name() + "] can't be changed from non-nested to nested"); } } this.includeInAll = mergeWith.includeInAll; if (mergeWith.dynamic != null) { this.dynamic = mergeWith.dynamic; } for (Mapper mergeWithMapper : mergeWith) { Mapper mergeIntoMapper = mappers.get(mergeWithMapper.simpleName()); checkEnabledFieldChange(mergeWith, mergeWithMapper, mergeIntoMapper); Mapper merged; if (mergeIntoMapper == null) { // no mapping, simply add it merged = mergeWithMapper; } else { // root mappers can only exist here for backcompat, and are merged in Mapping merged = mergeIntoMapper.merge(mergeWithMapper, updateAllTypes); } putMapper(merged); } }
@Override public boolean containsKey(Object key) { // works fine since null values are not supported return get(key) != null; }
@Override public boolean containsKey(Object key) { // works fine since null values are not supported return get(key) != null; }
@Override public boolean containsKey(Object key) { // works fine since null values are not supported return get(key) != null; }
@Override public boolean containsKey(Object key) { // works fine since null values are not supported return get(key) != null; }
/** Returns the field for the given field */ public MappedFieldType get(String field) { return fullNameToFieldType.get(field); }
/** Get the set of types that have a mapping for the given field. */ public Set<String> getTypes(String field) { Set<String> types = fullNameToTypes.get(field); if (types == null) { types = Collections.emptySet(); } return types; }
/** * Get the set of types that have a mapping for the given field. * Note: this method is only visible for testing. **/ protected Set<String> getTypes(String field) { Set<String> types = fullNameToTypes.get(field); if (types == null) { types = Collections.emptySet(); } return types; }
/** Get the set of types that have a mapping for the given field. */ public Set<String> getTypes(String field) { Set<String> types = fullNameToTypes.get(field); if (types == null) { types = Collections.emptySet(); } return types; }
/** * Get the set of types that have a mapping for the given field. * Note: this method is only visible for testing. **/ protected Set<String> getTypes(String field) { Set<String> types = fullNameToTypes.get(field); if (types == null) { types = Collections.emptySet(); } return types; }
/** Get the set of types that have a mapping for the given field. */ public Set<String> getTypesByIndexName(String field) { Set<String> types = indexNameToTypes.get(field); if (types == null) { types = Collections.emptySet(); } return types; }