Class MapEntityContext<T>

java.lang.Object
org.keycloak.models.map.storage.file.common.MapEntityContext<T>
All Implemented Interfaces:
BlockContext<T>

public class MapEntityContext<T> extends Object implements BlockContext<T>
BlockContext which handles any entity accompanied with EntityField field getters and setters, namely Map*Entity classes.
Author:
hmlnarik
  • Field Details

    • objectClass

      protected final Class<T> objectClass
    • result

      protected final T result
    • SCHEMA_VERSION

      public static final String SCHEMA_VERSION
      See Also:
    • ATTRIBUTES_NAME

      protected static final String ATTRIBUTES_NAME
  • Constructor Details

    • MapEntityContext

      public MapEntityContext(Class<T> clazz)
    • MapEntityContext

      public MapEntityContext(Class<T> clazz, boolean topContext)
    • MapEntityContext

      protected MapEntityContext(Class<T> clazz, Map<String,EntityField<?>> nameToEntityField, Map<String,Supplier<? extends BlockContext<?>>> contextCreators, boolean topContext)
  • Method Details

    • fieldsToContextCreators

      protected static <T> Map<String,Supplier<? extends BlockContext<?>>> fieldsToContextCreators(Class<T> type)
    • fieldsToEntityField

      public static <T> Map<String,EntityField<?>> fieldsToEntityField(Class<T> type)
    • setEntityField

      public static <T> boolean setEntityField(T result, EntityField<? super T> ef, Object value)
    • add

      public void add(String name, Object value)
      Description copied from interface: BlockContext
      Modifies the result returned from within this context by providing the read mapping entry name to given value.

      Called after reading a map entry (both key and value) from the YAML file is finished. The entry is represented as name parameter (key part of the entry) and value (value part of the entry).

      The method is called in the same order as the mapping items appear in the source YAML mapping.

      Specified by:
      add in interface BlockContext<T>
    • getScalarType

      public Class<T> getScalarType()
      Specified by:
      getScalarType in interface BlockContext<T>
    • getResult

      public T getResult()
      Description copied from interface: BlockContext
      Returns the result of parsing the given part of YAML file.
      Specified by:
      getResult in interface BlockContext<T>
      Returns:
    • getContext

      public BlockContext<?> getContext(String nameOfSubcontext)
      Description copied from interface: BlockContext
      Called after reading a key of map entry in YAML file and before reading its value. The key of the entry is represented as nameOfSubcontext parameter, and provides means to specify a YamlContext for transforming the mapping value into appropriate Java object.
      Specified by:
      getContext in interface BlockContext<T>
      Parameters:
      nameOfSubcontext - Key of the map entry
      Returns:
      Context used for transforming the value, or null if the default primitive / sequence / mapping context should be used instead.
      See Also:
    • writeValue

      public void writeValue(T entity, WritingMechanism mech)
      Description copied from interface: BlockContext
      Writes the given value using WritingMechanism.
      Specified by:
      writeValue in interface BlockContext<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object