com.fasterxml.jackson.databind.ser.impl

## Class PropertySerializerMap

- java.lang.Object
- - com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap

-     public abstract class PropertySerializerMap
      extends java.lang.Object

  Helper container used for resolving serializers for dynamic (possibly but not necessarily polymorphic) properties: properties whose type is not forced to use dynamic (declared) type and that are not final. If so, serializer to use can only be established once actual value type is known. Since this happens a lot unless static typing is forced (or types are final) this implementation is optimized for efficiency. Instances are immutable; new instances are created with factory methods: this is important to ensure correct multi-threaded access.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `PropertySerializerMap.SerializerAndMapResult` Value class used for returning tuple that has both serializer that was retrieved and new map instance

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `_resetWhenFull` Configuration setting that determines what happens when maximum size (currently 8) is reached: if true, will "start from beginning"; if false, will simply stop adding new entries.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `PropertySerializerMap(boolean resetWhenFull)`
    `protected` | `PropertySerializerMap(PropertySerializerMap base)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `PropertySerializerMap.SerializerAndMapResult` | `addSerializer(java.lang.Class<?> type, JsonSerializer<java.lang.Object> serializer)` Method that can be used to 'register' a serializer that caller has resolved without help of this map.
    `PropertySerializerMap.SerializerAndMapResult` | `addSerializer(JavaType type, JsonSerializer<java.lang.Object> serializer)`
    `static PropertySerializerMap` | `emptyForProperties()`
    `static PropertySerializerMap` | `emptyForRootValues()`
    `static PropertySerializerMap` | `emptyMap()` Deprecated. Since 2.5 Use `emptyForProperties()` instead
    `PropertySerializerMap.SerializerAndMapResult` | `findAndAddKeySerializer(java.lang.Class<?> type, SerializerProvider provider, BeanProperty property)` Method called if initial lookup fails, when looking for a key serializer (possible attached indirectly to a property) Will both find serializer and construct new map instance if warranted, and return both.
    `PropertySerializerMap.SerializerAndMapResult` | `findAndAddPrimarySerializer(java.lang.Class<?> type, SerializerProvider provider, BeanProperty property)` Method called if initial lookup fails, when looking for a primary serializer (one that is directly attached to a property).
    `PropertySerializerMap.SerializerAndMapResult` | `findAndAddPrimarySerializer(JavaType type, SerializerProvider provider, BeanProperty property)`
    `PropertySerializerMap.SerializerAndMapResult` | `findAndAddRootValueSerializer(java.lang.Class<?> type, SerializerProvider provider)` Method called if initial lookup fails, when looking for a root value serializer: one that is not directly attached to a property, but needs to have `TypeSerializer` wrapped around it.
    `PropertySerializerMap.SerializerAndMapResult` | `findAndAddRootValueSerializer(JavaType type, SerializerProvider provider)`
    `PropertySerializerMap.SerializerAndMapResult` | `findAndAddSecondarySerializer(java.lang.Class<?> type, SerializerProvider provider, BeanProperty property)` Method called if initial lookup fails, when looking for a non-primary serializer (one that is not directly attached to a property).
    `PropertySerializerMap.SerializerAndMapResult` | `findAndAddSecondarySerializer(JavaType type, SerializerProvider provider, BeanProperty property)`
    `abstract PropertySerializerMap` | `newWith(java.lang.Class<?> type, JsonSerializer<java.lang.Object> serializer)`
    `abstract JsonSerializer<java.lang.Object>` | `serializerFor(java.lang.Class<?> type)` Main lookup method.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _resetWhenFull

          protected final boolean _resetWhenFull

      Configuration setting that determines what happens when maximum size (currently 8) is reached: if true, will "start from beginning"; if false, will simply stop adding new entries.
      Since:
        2.5

  - ### Constructor Detail

    - #### PropertySerializerMap

          protected PropertySerializerMap(boolean resetWhenFull)

      Since:
        2.5

    - #### PropertySerializerMap

          protected PropertySerializerMap(PropertySerializerMap base)

  - ### Method Detail

    - #### serializerFor

          public abstract JsonSerializer<java.lang.Object> serializerFor(java.lang.Class<?> type)

      Main lookup method. Takes a "raw" type since usage is always from place where parameterization is fixed such that there can not be type-parametric variations.

    - #### findAndAddPrimarySerializer

          public final PropertySerializerMap.SerializerAndMapResult findAndAddPrimarySerializer(java.lang.Class<?> type,
                                                                                 SerializerProvider provider,
                                                                                 BeanProperty property)
                                                                                         throws JsonMappingException

      Method called if initial lookup fails, when looking for a primary serializer (one that is directly attached to a property). Will both find serializer and construct new map instance if warranted, and return both.
      Throws:
        `JsonMappingException`
      Since:
        2.3

    - #### findAndAddPrimarySerializer

          public final PropertySerializerMap.SerializerAndMapResult findAndAddPrimarySerializer(JavaType type,
                                                                                 SerializerProvider provider,
                                                                                 BeanProperty property)
                                                                                         throws JsonMappingException

      Throws:
        `JsonMappingException`

    - #### findAndAddSecondarySerializer

          public final PropertySerializerMap.SerializerAndMapResult findAndAddSecondarySerializer(java.lang.Class<?> type,
                                                                                   SerializerProvider provider,
                                                                                   BeanProperty property)
                                                                                           throws JsonMappingException

      Method called if initial lookup fails, when looking for a non-primary serializer (one that is not directly attached to a property). Will both find serializer and construct new map instance if warranted, and return both.
      Throws:
        `JsonMappingException`
      Since:
        2.3

    - #### findAndAddSecondarySerializer

          public final PropertySerializerMap.SerializerAndMapResult findAndAddSecondarySerializer(JavaType type,
                                                                                   SerializerProvider provider,
                                                                                   BeanProperty property)
                                                                                           throws JsonMappingException

      Throws:
        `JsonMappingException`

    - #### findAndAddRootValueSerializer

          public final PropertySerializerMap.SerializerAndMapResult findAndAddRootValueSerializer(java.lang.Class<?> type,
                                                                                   SerializerProvider provider)
                                                                                           throws JsonMappingException

      Method called if initial lookup fails, when looking for a root value serializer: one that is not directly attached to a property, but needs to have `TypeSerializer` wrapped around it. Will both find the serializer and construct new map instance if warranted, and return both.
      Throws:
        `JsonMappingException`
      Since:
        2.5

    - #### findAndAddRootValueSerializer

          public final PropertySerializerMap.SerializerAndMapResult findAndAddRootValueSerializer(JavaType type,
                                                                                   SerializerProvider provider)
                                                                                           throws JsonMappingException

      Throws:
        `JsonMappingException`
      Since:
        2.5

    - #### findAndAddKeySerializer

          public final PropertySerializerMap.SerializerAndMapResult findAndAddKeySerializer(java.lang.Class<?> type,
                                                                             SerializerProvider provider,
                                                                             BeanProperty property)
                                                                                     throws JsonMappingException

      Method called if initial lookup fails, when looking for a key serializer (possible attached indirectly to a property) Will both find serializer and construct new map instance if warranted, and return both.
      Throws:
        `JsonMappingException`
      Since:
        2.7

    - #### addSerializer

          public final PropertySerializerMap.SerializerAndMapResult addSerializer(java.lang.Class<?> type,
                                                                   JsonSerializer<java.lang.Object> serializer)

      Method that can be used to 'register' a serializer that caller has resolved without help of this map.
      Since:
        2.5

    - #### addSerializer

          public final PropertySerializerMap.SerializerAndMapResult addSerializer(JavaType type,
                                                                   JsonSerializer<java.lang.Object> serializer)

      Since:
        2.5

    - #### newWith

          public abstract PropertySerializerMap newWith(java.lang.Class<?> type,
                                      JsonSerializer<java.lang.Object> serializer)

    - #### emptyMap

          @Deprecated
          public static PropertySerializerMap emptyMap()

      Deprecated. Since 2.5 Use `emptyForProperties()` instead

    - #### emptyForProperties

          public static PropertySerializerMap emptyForProperties()

      Since:
        2.5

    - #### emptyForRootValues

          public static PropertySerializerMap emptyForRootValues()

      Since:
        2.5