Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.deser.impl

public Class BeanPropertyMap

extends Object
implements Iterable<SettableBeanProperty>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Iterable
Imports
java.io.IOException, java.lang.reflect.InvocationTargetException, java.util.*, com.fasterxml.jackson.core.JacksonException, .JsonParser, com.fasterxml.jackson.databind.DeserializationContext, .DeserializationFeature, .JsonDeserializer, .JsonMappingException, .MapperFeature, .PropertyName, com.fasterxml.jackson.databind.cfg.MapperConfig, com.fasterxml.jackson.databind.deser.SettableBeanProperty, com.fasterxml.jackson.databind.util.ClassUtil, .IgnorePropertiesUtil, .NameTransformer

Helper class used for storing mapping from property name to SettableBeanProperty instances.

Note that this class is used instead of generic java.util.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

Modifier and TypeField and Description
private final Map<String, List<PropertyName>>
_aliasDefs

Configuration of alias mappings, indexed by unmodified property name to unmodified aliases, if any; entries only included for properties that do have aliases.

private final Map<String, String>
_aliasMapping

Mapping from secondary names (aliases) to primary names.

protected final boolean
private Object[]
_hashArea

Hash area that contains key/property pairs in adjacent elements.

private int
private final Locale
_locale

We require Locale since case changes are locale-sensitive in certain cases (see Turkish I for example)

private final SettableBeanProperty[]
_propsInOrder

Array of properties in the exact order they were handed in. This is used by as-array serialization, deserialization.

private int
_size

Number of entries stored in the hash area.

private int
private static final long

Constructor Summary

AccessConstructor and Description
public
BeanPropertyMap(boolean caseInsensitive, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasDefs, Locale locale)

public
BeanPropertyMap(boolean caseInsensitive, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasDefs)

Deprecated since 2.11
private
BeanPropertyMap(BeanPropertyMap src, SettableBeanProperty newProp, int hashIndex, int orderedIndex)

private
protected
BeanPropertyMap(BeanPropertyMap base, boolean caseInsensitive)

Method Summary

Modifier and TypeMethod and Description
private Map<String, String>
_buildAliasMapping(Map<String, List<PropertyName>> defs, boolean caseInsensitive, Locale loc)

private final SettableBeanProperty
_find2(String key, int slot, Object match)

private SettableBeanProperty
_find2ViaAlias(String key, int slot, Object match)

private final int
_findFromOrdered(SettableBeanProperty prop)

Helper 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 int
private List<SettableBeanProperty>
protected SettableBeanProperty
public BeanPropertyMap
public static BeanPropertyMap
construct(MapperConfig<?> config, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasMapping, boolean caseInsensitive)

public static BeanPropertyMap
construct(MapperConfig<?> config, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasMapping)

Deprecated since 2.12
public static BeanPropertyMap
construct(Collection<SettableBeanProperty> props, boolean caseInsensitive, Map<String, List<PropertyName>> aliasMapping)

Deprecated since 2.11
public SettableBeanProperty
find(int index)

public SettableBeanProperty
find(String key)

public 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, call SettableBeanProperty#deserializeAndSet on it, and return true; or, if not found, return false.

private static final int
findSize(int size)

public SettableBeanProperty[]
getPropertiesInInsertionOrder()

Method that will re-create initial insertion-ordering of properties contained in this map.

protected final String
public boolean
protected void
public boolean
public Iterator<SettableBeanProperty>
iterator()

Implements java.lang.Iterable.iterator.

Accessor for traversing over all contained properties.
public void
remove(SettableBeanProperty propToRm)

Specialized method for removing specified existing entry.

public BeanPropertyMap
renameAll(NameTransformer transformer)

Mutant factory method for constructing a map where all entries use given prefix

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.

public int
size()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
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, returns this.

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.

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

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.

protected void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_aliasDefsback to summary
private final Map<String, List<PropertyName>> _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
_aliasMappingback to summary
private final Map<String, String> _aliasMapping

Mapping from secondary names (aliases) to primary names.

Since
2.9
_caseInsensitiveback to summary
protected final boolean _caseInsensitive
Since
2.5
_hashAreaback to summary
private Object[] _hashArea

Hash area that contains key/property pairs in adjacent elements.

_hashMaskback to summary
private int _hashMask
_localeback to summary
private final Locale _locale

We require Locale since case changes are locale-sensitive in certain cases (see Turkish I for example)

Since
2.11
_propsInOrderback to summary
private final SettableBeanProperty[] _propsInOrder

Array of properties in the exact order they were handed in. This is used by as-array serialization, deserialization.

_sizeback to summary
private int _size

Number of entries stored in the hash area.

_spillCountback to summary
private int _spillCount
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

BeanPropertyMapback to summary
public BeanPropertyMap(boolean caseInsensitive, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasDefs, Locale locale)
Since
2.11
BeanPropertyMapback to summary
public BeanPropertyMap(boolean caseInsensitive, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasDefs)

Deprecated

since 2.11

Annotations
@Deprecated
BeanPropertyMapback to summary
private BeanPropertyMap(BeanPropertyMap src, SettableBeanProperty newProp, int hashIndex, int orderedIndex)
BeanPropertyMapback to summary
private BeanPropertyMap(BeanPropertyMap src, SettableBeanProperty newProp, String key, int slot)
BeanPropertyMapback to summary
protected BeanPropertyMap(BeanPropertyMap base, boolean caseInsensitive)
Since
2.8

Method Detail

_buildAliasMappingback to summary
private Map<String, String> _buildAliasMapping(Map<String, List<PropertyName>> defs, boolean caseInsensitive, Locale loc)
_find2back to summary
private final SettableBeanProperty _find2(String key, int slot, Object match)
_find2ViaAliasback to summary
private SettableBeanProperty _find2ViaAlias(String key, int slot, Object match)
_findFromOrderedback to summary
private final int _findFromOrdered(SettableBeanProperty prop)

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
_findWithAliasback to summary
private SettableBeanProperty _findWithAlias(String keyFromAlias)
_hashCodeback to summary
private final int _hashCode(String key)
_propertiesback to summary
private List<SettableBeanProperty> _properties()
_renameback to summary
protected SettableBeanProperty _rename(SettableBeanProperty prop, NameTransformer xf)
assignIndexesback to summary
public BeanPropertyMap assignIndexes()
constructback to summary
public static BeanPropertyMap construct(MapperConfig<?> config, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasMapping, boolean caseInsensitive)
Since
2.12
constructback to summary
public static BeanPropertyMap construct(MapperConfig<?> config, Collection<SettableBeanProperty> props, Map<String, List<PropertyName>> aliasMapping)

Deprecated

since 2.12

Annotations
@Deprecated
Since
2.11
constructback to summary
public static BeanPropertyMap construct(Collection<SettableBeanProperty> props, boolean caseInsensitive, Map<String, List<PropertyName>> aliasMapping)

Deprecated

since 2.11

Annotations
@Deprecated
findback to summary
public SettableBeanProperty find(int index)
Since
2.3
findback to summary
public SettableBeanProperty find(String key)
findDeserializeAndSetback to summary
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, call SettableBeanProperty#deserializeAndSet 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.

Since
2.5
findSizeback to summary
private static final int findSize(int size)
getPropertiesInInsertionOrderback to summary
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
getPropertyNameback to summary
protected final String getPropertyName(SettableBeanProperty prop)
hasAliasesback to summary
public boolean hasAliases()
Since
2.9
initback to summary
protected void init(Collection<SettableBeanProperty> props)
isCaseInsensitiveback to summary
public boolean isCaseInsensitive()
Since
2.9
iteratorback to summary
public Iterator<SettableBeanProperty> iterator()

Implements java.lang.Iterable.iterator.

Accessor for traversing over all contained properties.

Returns:Iterator<SettableBeanProperty>

Doc from java.lang.Iterable.iterator.

an Iterator.

Annotations
@Override
removeback to summary
public void remove(SettableBeanProperty propToRm)

Specialized method for removing specified existing entry.

Note

entry MUST exist, otherwise an exception is thrown.

renameAllback to summary
public BeanPropertyMap renameAll(NameTransformer transformer)

Mutant factory method for constructing a map where all entries use given prefix

replaceback to summary
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
sizeback to summary
public int size()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
withCaseInsensitivityback to summary
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, returns this.

Since
2.8
withoutPropertiesback to summary
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
withoutPropertiesback to summary
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
withPropertyback to summary
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.

wrapAndThrowback to summary
protected void wrapAndThrow(Throwable t, Object bean, String fieldName, DeserializationContext ctxt) throws IOException