Class BeanPropertyMap

java.lang.Object
tools.jackson.databind.deser.bean.BeanPropertyMap
All Implemented Interfaces:
Iterable<SettableBeanProperty>

public class BeanPropertyMap extends Object implements 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.

  • Constructor Details

    • BeanPropertyMap

      protected BeanPropertyMap(Collection<SettableBeanProperty> props, PropertyName[][] aliasDefs, Locale locale, boolean caseInsensitive, boolean assignIndexes)
      Parameters:
      caseInsensitive - Whether property name matching should case-insensitive or not
      props - Sequence of primary properties to index
      aliasDefs - Alias mappings, if any (null if none)
      assignIndexes - Whether to assign indices to property entities or not
    • BeanPropertyMap

      protected BeanPropertyMap(BeanPropertyMap base, boolean caseInsensitive)
  • Method Details

    • construct

      public static BeanPropertyMap construct(MapperConfig<?> config, Collection<SettableBeanProperty> props, PropertyName[][] aliases, boolean caseInsensitive)
    • 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, returns this.
    • 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.
    • renameAll

      public BeanPropertyMap renameAll(DeserializationContext ctxt, 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.
    • 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

      public void replace(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.
    • remove

      public void remove(SettableBeanProperty propToRm)
      Specialized method for removing specified existing entry. NOTE: entry MUST exist, otherwise an exception is thrown.
    • initMatcher

      public BeanPropertyMap initMatcher(TokenStreamFactory tsf)
    • getNameMatcher

      public PropertyNameMatcher getNameMatcher()
    • getNameMatcherProperties

      public SettableBeanProperty[] getNameMatcherProperties()
    • size

      public int size()
    • isCaseInsensitive

      public boolean isCaseInsensitive()
    • hasAliases

      public boolean hasAliases()
    • iterator

      public Iterator<SettableBeanProperty> iterator()
      Accessor for traversing over all contained properties.
      Specified by:
      iterator in interface Iterable<SettableBeanProperty>
    • getPrimaryProperties

      public 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

      public SettableBeanProperty findDefinition(int index)
    • findDefinition

      public SettableBeanProperty findDefinition(String key)
      NOTE: does NOT do case-insensitive matching -- only to be used during construction and never during deserialization process -- nor alias expansion.
    • toString

      public String toString()
      Overrides:
      toString in class Object