Class PropertiesConverter

All Implemented Interfaces:
Function<String,String>, ObjectConverter<String,String>

final class PropertiesConverter extends SurjectiveConverter<String,String>
Converts AbstractIdentifiedObject entries to NamedIdentifier entries. This converter:
  • Exclude remarks, because they will be taken by AbstractIdentifiedObject and we don't want to duplicate them in NamedIdentifier.
  • Optionally rename de NAME_KEY as CODE_KEY in order to allow NamedIdentifier to inherit the name given to AbstractIdentifiedObject if no code were explicitly given.
Since:
0.4
Version:
0.4
  • Field Details

    • CODE_INCLUDED

      private static final PropertiesConverter CODE_INCLUDED
      The converter to use if the map already contains a CODE_KEY.
    • CODE_INFERED

      private static final PropertiesConverter CODE_INFERED
      The converter to use if the does not contain a CODE_KEY, in which case it needs to be inferred from the NAME_KEY.
    • rename

      private final boolean rename
      true for renaming NAME_KEY as CODE_KEY, or false for excluding the NAME_KEY instead.
  • Constructor Details

    • PropertiesConverter

      private PropertiesConverter(boolean rename)
      Constructor for static constants only.
  • Method Details

    • convert

      static Map<String,?> convert(Map<String,?> properties)
      Converts the given map.
    • getSourceClass

      public Class<String> getSourceClass()
      Returns the type of keys before conversion.
      Returns:
      the type of objects to convert.
    • getTargetClass

      public Class<String> getTargetClass()
      Returns the type of keys after conversion.
      Returns:
      the type of converted objects.
    • apply

      public String apply(String key)
      Converts a key as documented in class javadoc.
      Parameters:
      key - the object to convert, or null.
      Returns:
      the converted object, or null.