Class BeanPropertyMap
java.lang.Object
com.fasterxml.jackson.databind.deser.impl.BeanPropertyMap
- All Implemented Interfaces:
Serializable,Iterable<SettableBeanProperty>
Helper class used for storing mapping from property name to
SettableBeanProperty instances.
Note that this class is used instead of generic HashMap
for bit of performance gain (and some memory savings): although default
implementation is very good for generic use cases, it can be streamlined
a bit for specific use case we have. Even relatively small improvements
matter since this is directly on the critical path during deserialization,
as it is done for each and every POJO property deserialized.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<String, List<PropertyName>> Configuration of alias mappings, indexed by unmodified property name to unmodified aliases, if any; entries only included for properties that do have aliases.Mapping from secondary names (aliases) to primary names.protected final booleanprivate Object[]Hash area that contains key/property pairs in adjacent elements.private intprivate final Localeprivate final SettableBeanProperty[]Array of properties in the exact order they were handed in.private intNumber of entries stored in the hash area.private intprivate static final long -
Constructor Summary
ConstructorsModifierConstructorDescriptionBeanPropertyMap(boolean caseInsensitive, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasDefs) Deprecated.since 2.11BeanPropertyMap(boolean caseInsensitive, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasDefs, Locale locale) protectedBeanPropertyMap(BeanPropertyMap base, boolean caseInsensitive) privateBeanPropertyMap(BeanPropertyMap src, SettableBeanProperty newProp, int hashIndex, int orderedIndex) privateBeanPropertyMap(BeanPropertyMap src, SettableBeanProperty newProp, String key, int slot) -
Method Summary
Modifier and TypeMethodDescription_buildAliasMapping(Map<String, List<PropertyName>> defs, boolean caseInsensitive, Locale loc) private final SettableBeanPropertyprivate SettableBeanProperty_find2ViaAlias(String key, int slot, Object match) private final intHelper method used to find exact location of a property with name given exactly, not subject to case changes, within hash area.private SettableBeanProperty_findWithAlias(String keyFromAlias) private final intprivate List<SettableBeanProperty> protected SettableBeanProperty_rename(SettableBeanProperty prop, NameTransformer xf) static BeanPropertyMapconstruct(MapperConfig<?> config, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasMapping) Deprecated.since 2.12static BeanPropertyMapconstruct(MapperConfig<?> config, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasMapping, boolean caseInsensitive) static BeanPropertyMapconstruct(Collection<SettableBeanProperty> props, boolean caseInsensitive, Map<String, List<PropertyName>> aliasMapping) Deprecated.since 2.11find(int index) booleanfindDeserializeAndSet(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, Object bean, String key) Convenience method that tries to find property with given name, and if it is found, callSettableBeanProperty.deserializeAndSet(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, java.lang.Object)on it, and return true; or, if not found, return false.private static final intfindSize(int size) Method that will re-create initial insertion-ordering of properties contained in this map.protected final Stringbooleanprotected voidinit(Collection<SettableBeanProperty> props) booleaniterator()Accessor for traversing over all contained properties.voidremove(SettableBeanProperty propToRm) Specialized method for removing specified existing entry.renameAll(NameTransformer transformer) Mutant factory method for constructing a map where all entries use given prefixvoidreplace(SettableBeanProperty origProp, SettableBeanProperty newProp) Specialized method that can be used to replace an existing entry (note: entry MUST exist; otherwise exception is thrown) with specified replacement.intsize()toString()withCaseInsensitivity(boolean state) Mutant factory method that constructs a new instance if desired case-insensitivity state differs from the state of this instance; if states are the same, returnsthis.withoutProperties(Collection<String> toExclude) Mutant factory method that will use this instance as the base, and construct an instance that is otherwise same except for excluding properties with specified names.withoutProperties(Collection<String> toExclude, Collection<String> toInclude) Mutant factory method that will use this instance as the base, and construct an instance that is otherwise same except for excluding properties with specified names, or including only the one marked as includedwithProperty(SettableBeanProperty newProp) Fluent copy method that creates a new instance that is a copy of this instance except for one additional property that is passed as the argument.protected voidwrapAndThrow(Throwable t, Object bean, String fieldName, DeserializationContext ctxt) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
_caseInsensitive
protected final boolean _caseInsensitive- Since:
- 2.5
-
_hashMask
private int _hashMask -
_size
private int _sizeNumber of entries stored in the hash area. -
_spillCount
private int _spillCount -
_hashArea
Hash area that contains key/property pairs in adjacent elements. -
_propsInOrder
Array of properties in the exact order they were handed in. This is used by as-array serialization, deserialization. -
_aliasDefs
Configuration of alias mappings, indexed by unmodified property name to unmodified aliases, if any; entries only included for properties that do have aliases. This is is used for constructing actual reverse lookup mapping, if needed, taking into account possible case-insensitivity, as well as possibility of name prefixes.- Since:
- 2.9
-
_aliasMapping
Mapping from secondary names (aliases) to primary names.- Since:
- 2.9
-
_locale
We requireLocalesince case changes are locale-sensitive in certain cases (see Turkish I for example)- Since:
- 2.11
-
-
Constructor Details
-
BeanPropertyMap
public BeanPropertyMap(boolean caseInsensitive, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasDefs, Locale locale) - Since:
- 2.11
-
BeanPropertyMap
@Deprecated public BeanPropertyMap(boolean caseInsensitive, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasDefs) Deprecated.since 2.11 -
BeanPropertyMap
private BeanPropertyMap(BeanPropertyMap src, SettableBeanProperty newProp, int hashIndex, int orderedIndex) -
BeanPropertyMap
-
BeanPropertyMap
- Since:
- 2.8
-
-
Method Details
-
withCaseInsensitivity
Mutant factory method that constructs a new instance if desired case-insensitivity state differs from the state of this instance; if states are the same, returnsthis.- Since:
- 2.8
-
init
-
findSize
private static final int findSize(int size) -
construct
public static BeanPropertyMap construct(MapperConfig<?> config, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasMapping, boolean caseInsensitive) - Since:
- 2.12
-
construct
@Deprecated public static BeanPropertyMap construct(MapperConfig<?> config, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasMapping) Deprecated.since 2.12- Since:
- 2.11
-
construct
@Deprecated public static BeanPropertyMap construct(Collection<SettableBeanProperty> props, boolean caseInsensitive, Map<String, List<PropertyName>> aliasMapping) Deprecated.since 2.11 -
withProperty
Fluent copy method that creates a new instance that is a copy of this instance except for one additional property that is passed as the argument. Note that method does not modify this instance but constructs and returns a new one. -
assignIndexes
-
renameAll
Mutant factory method for constructing a map where all entries use given prefix -
withoutProperties
Mutant factory method that will use this instance as the base, and construct an instance that is otherwise same except for excluding properties with specified names.- Since:
- 2.8
-
withoutProperties
public BeanPropertyMap withoutProperties(Collection<String> toExclude, Collection<String> toInclude) Mutant factory method that will use this instance as the base, and construct an instance that is otherwise same except for excluding properties with specified names, or including only the one marked as included- Since:
- 2.12
-
replace
Specialized method that can be used to replace an existing entry (note: entry MUST exist; otherwise exception is thrown) with specified replacement.- Since:
- 2.9.4
-
remove
Specialized method for removing specified existing entry. NOTE: entry MUST exist, otherwise an exception is thrown. -
size
public int size() -
isCaseInsensitive
public boolean isCaseInsensitive()- Since:
- 2.9
-
hasAliases
public boolean hasAliases()- Since:
- 2.9
-
iterator
Accessor for traversing over all contained properties.- Specified by:
iteratorin interfaceIterable<SettableBeanProperty>
-
_properties
-
getPropertiesInInsertionOrder
Method that will re-create initial insertion-ordering of properties contained in this map. Note that if properties have been removed, array may contain nulls; otherwise it should be consecutive.- Since:
- 2.1
-
getPropertyName
-
find
- Since:
- 2.3
-
find
-
_find2
-
_findWithAlias
-
_find2ViaAlias
-
findDeserializeAndSet
public boolean findDeserializeAndSet(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, Object bean, String key) throws IOException Convenience method that tries to find property with given name, and if it is found, callSettableBeanProperty.deserializeAndSet(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, java.lang.Object)on it, and return true; or, if not found, return false. Note, too, that if deserialization is attempted, possible exceptions are wrapped if and as necessary, so caller need not handle those.- Throws:
IOException- Since:
- 2.5
-
toString
-
_rename
-
wrapAndThrow
protected void wrapAndThrow(Throwable t, Object bean, String fieldName, DeserializationContext ctxt) throws IOException - Throws:
IOException
-
_findFromOrdered
Helper method used to find exact location of a property with name given exactly, not subject to case changes, within hash area. Expectation is that such property SHOULD exist, although no exception is thrown.- Since:
- 2.7
-
_hashCode
-
_buildAliasMapping
-