Class BeanPropertyMap
- java.lang.Object
-
- com.fasterxml.jackson.databind.deser.impl.BeanPropertyMap
-
- All Implemented Interfaces:
Serializable
,Iterable<SettableBeanProperty>
public class BeanPropertyMap extends Object implements Iterable<SettableBeanProperty>, Serializable
Helper class used for storing mapping from property name toSettableBeanProperty
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BeanPropertyMap(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)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BeanPropertyMap
assignIndexes()
static BeanPropertyMap
construct(MapperConfig<?> config, Collection<SettableBeanProperty> props, Map<String,List<PropertyName>> aliasMapping)
Deprecated.since 2.12static BeanPropertyMap
construct(MapperConfig<?> config, Collection<SettableBeanProperty> props, Map<String,List<PropertyName>> aliasMapping, boolean caseInsensitive)
static BeanPropertyMap
construct(Collection<SettableBeanProperty> props, boolean caseInsensitive, Map<String,List<PropertyName>> aliasMapping)
Deprecated.since 2.11SettableBeanProperty
find(int index)
SettableBeanProperty
find(String key)
boolean
findDeserializeAndSet(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.SettableBeanProperty[]
getPropertiesInInsertionOrder()
Method that will re-create initial insertion-ordering of properties contained in this map.boolean
hasAliases()
boolean
isCaseInsensitive()
Iterator<SettableBeanProperty>
iterator()
Accessor for traversing over all contained properties.void
remove(SettableBeanProperty propToRm)
Specialized method for removing specified existing entry.BeanPropertyMap
renameAll(NameTransformer transformer)
Mutant factory method for constructing a map where all entries use given prefixvoid
replace(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.int
size()
String
toString()
BeanPropertyMap
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
.BeanPropertyMap
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.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 includedBeanPropertyMap
withProperty(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 java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
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
-
-
Method Detail
-
withCaseInsensitivity
public BeanPropertyMap 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
.- Since:
- 2.8
-
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
public BeanPropertyMap withProperty(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. Note that method does not modify this instance but constructs and returns a new one.
-
assignIndexes
public BeanPropertyMap assignIndexes()
-
renameAll
public BeanPropertyMap renameAll(NameTransformer transformer)
Mutant factory method for constructing a map where all entries use given prefix
-
withoutProperties
public BeanPropertyMap 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.- 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
public void replace(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.- Since:
- 2.9.4
-
remove
public void remove(SettableBeanProperty propToRm)
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
public Iterator<SettableBeanProperty> iterator()
Accessor for traversing over all contained properties.- Specified by:
iterator
in interfaceIterable<SettableBeanProperty>
-
getPropertiesInInsertionOrder
public SettableBeanProperty[] 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
-
find
public SettableBeanProperty find(int index)
- Since:
- 2.3
-
find
public SettableBeanProperty find(String key)
-
findDeserializeAndSet
public boolean findDeserializeAndSet(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
-
-