Class BeanDictionaryMap

All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>

Represents a map of dictionary type names to bean classes that make up a bean dictionary.

In general, this approach for defining dictionary names for classes is used when it's not possible to use the @Bean(typeName) annotation.

Example:

// A bean dictionary map consisting of classes without @Bean(typeName) annotations // that require type names to be explicitly specified. public class MyBeanDictionaryMap extends BeanDictionaryMap { // Must provide a no-arg constructor! public MyBeanDictionaryMap() { append("MyBean", MyBean.class); append("MyBeanArray", MyBean[].class); append("StringArray", String[].class); append("String2dArray", String[][].class); append("IntArray", int[].class); append("Int2dArray", int[][].class); append("LinkedList", LinkedList.class); append("TreeMap", TreeMap.class); append("LinkedListOfInts", LinkedList.class, Integer.class); append("LinkedListOfR1", LinkedList.class, R1.class); append("LinkedListOfCalendar", LinkedList.class, Calendar.class); } } // Use it in a parser. ReaderParser parser = JsonParser .create() .dictionary(MyBeanDictionaryMap.class) .build();

Subclasses must implement a public no-arg constructor so that it can be instantiated by the bean context code.

See Also:
  • Constructor Details

  • Method Details

    • append

      protected BeanDictionaryMap append(String typeName, Class<?> c)
      Add a dictionary name mapping for the specified class.
      Parameters:
      typeName - The dictionary name of the class.
      c - The class represented by the dictionary name.
      Returns:
      This object.
    • append

      protected BeanDictionaryMap append(String typeName, Class<? extends Map> mapClass, Object keyClass, Object valueClass)
      Add a dictionary name mapping for the specified map class with the specified key and value classes.
      Parameters:
      typeName - The dictionary name of the class.
      mapClass - The map implementation class.
      keyClass - The key class.
      valueClass - The value class.
      Returns:
      This object.
    • append

      protected BeanDictionaryMap append(String typeName, Class<? extends Collection> collectionClass, Object entryClass)
      Add a dictionary name mapping for the specified collection class with the specified entry class.
      Parameters:
      typeName - The dictionary name of the class.
      collectionClass - The collection implementation class.
      entryClass - The entry class.
      Returns:
      This object.