Class BeanPropertyMap
java.lang.Object
tools.jackson.databind.deser.bean.BeanPropertyMap
- All Implemented Interfaces:
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate PropertyName[][]Configuration of alias mappings, if any (`null` if none), aligned with properties in_propsInOrderprivate final booleanprivate final Localeprivate tools.jackson.core.sym.PropertyNameMatcherprivate SettableBeanProperty[]Array of properties in the exact order they were handed in.private SettableBeanProperty[]Lazily instantiated array of properties mapped from lookup index, in which first entries are same as in_propsInOrderfollowed by alias mappings. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBeanPropertyMap(Collection<SettableBeanProperty> props, PropertyName[][] aliasDefs, Locale locale, boolean caseInsensitive, boolean assignIndexes) protectedBeanPropertyMap(BeanPropertyMap base, boolean caseInsensitive) -
Method Summary
Modifier and TypeMethodDescriptionstatic BeanPropertyMapconstruct(MapperConfig<?> config, Collection<SettableBeanProperty> props, PropertyName[][] aliases, boolean caseInsensitive) findDefinition(int index) findDefinition(String key) NOTE: does NOT do case-insensitive matching -- only to be used during construction and never during deserialization process -- nor alias expansion.tools.jackson.core.sym.PropertyNameMatcherMethod that will re-create initial insertion-ordering of properties contained in this map.booleaninitMatcher(tools.jackson.core.TokenStreamFactory tsf) booleaniterator()Accessor for traversing over all contained properties.voidremove(SettableBeanProperty propToRm) Specialized method for removing specified existing entry.renameAll(DeserializationContext ctxt, NameTransformer transformer) Mutant factory method for constructing a map where all entries use given prefixvoidreplace(SettableBeanProperty oldProp, 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.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
_propsInOrder
Array of properties in the exact order they were handed in. This is used by as-array serialization, deserialization. Contains both primary properties (first_primaryCountentries) and possible aliased mappings -
_aliasDefs
Configuration of alias mappings, if any (`null` if none), aligned with properties in_propsInOrder -
_locale
-
_caseInsensitive
private final boolean _caseInsensitive -
_nameMatcher
private transient tools.jackson.core.sym.PropertyNameMatcher _nameMatcher -
_propsWithAliases
Lazily instantiated array of properties mapped from lookup index, in which first entries are same as in_propsInOrderfollowed by alias mappings.
-
-
Constructor Details
-
BeanPropertyMap
protected BeanPropertyMap(Collection<SettableBeanProperty> props, PropertyName[][] aliasDefs, Locale locale, boolean caseInsensitive, boolean assignIndexes) - Parameters:
props- Sequence of primary properties to indexaliasDefs- Alias mappings, if any (null if none)caseInsensitive- Whether property name matching should case-insensitive or notassignIndexes- Whether to assign indices to property entities or not
-
BeanPropertyMap
-
-
Method Details
-
construct
public static BeanPropertyMap construct(MapperConfig<?> config, Collection<SettableBeanProperty> props, PropertyName[][] aliases, boolean caseInsensitive) -
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. -
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. -
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. -
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 -
replace
Specialized method that can be used to replace an existing entry (note: entry MUST exist; otherwise exception is thrown) with specified replacement. -
remove
Specialized method for removing specified existing entry. NOTE: entry MUST exist, otherwise an exception is thrown. -
initMatcher
-
getNameMatcher
public tools.jackson.core.sym.PropertyNameMatcher getNameMatcher() -
getNameMatcherProperties
-
size
public int size() -
isCaseInsensitive
public boolean isCaseInsensitive() -
hasAliases
public boolean hasAliases() -
iterator
Accessor for traversing over all contained properties.- Specified by:
iteratorin interfaceIterable<SettableBeanProperty>
-
getPrimaryProperties
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. -
findDefinition
-
findDefinition
NOTE: does NOT do case-insensitive matching -- only to be used during construction and never during deserialization process -- nor alias expansion. -
toString
-