Class ExtendedEnum.ExternalEnumNames<T extends Named>
- java.lang.Object
-
- com.opengamma.strata.collect.named.ExtendedEnum.ExternalEnumNames<T>
-
- Type Parameters:
T
- the type of the enum
- Enclosing class:
- ExtendedEnum<T extends Named>
public static final class ExtendedEnum.ExternalEnumNames<T extends Named> extends Object
Maps names used by external systems to the standard name used here.A frequent problem in parsing external file formats is converting enum values. This class provides a suitable mapping, allowing multiple external names to map to one standard name.
A single instance represents the mapping for a single external group. This allows the mapping for different groups to differ. For example, the mapping used by FpML may differ from that used by Bloomberg.
Instances of this class are configured via INI files and provided via
ExtendedEnum
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableMap<String,String>
externalNames()
Returns the complete map of external name to standard name.T
lookup(String name)
Looks up an instance by name.<S extends T>
Slookup(String name, Class<S> subtype)
Looks up an instance by name and type.String
reverseLookup(T namedEnum)
Looks up the external name given a standard enum instance.String
toString()
-
-
-
Method Detail
-
lookup
public T lookup(String name)
Looks up an instance by name.This finds the instance matching the specified name. Instances may have alternate names (aliases), thus the returned instance may have a name other than that requested.
- Parameters:
name
- the enum name to return- Returns:
- the named enum
- Throws:
IllegalArgumentException
- if the name is not found
-
lookup
public <S extends T> S lookup(String name, Class<S> subtype)
Looks up an instance by name and type.This finds the instance matching the specified name, ensuring it is of the specified type. Instances may have alternate names (aliases), thus the returned instance may have a name other than that requested.
- Type Parameters:
S
- the enum subtype- Parameters:
subtype
- the enum subtype to matchname
- the enum name to return- Returns:
- the named enum
- Throws:
IllegalArgumentException
- if the name is not found or has the wrong type
-
externalNames
public ImmutableMap<String,String> externalNames()
Returns the complete map of external name to standard name.The map is keyed by the external name.
- Returns:
- the map of external names
-
reverseLookup
public String reverseLookup(T namedEnum)
Looks up the external name given a standard enum instance.This searches the map of external names and returns the first matching entry that maps to the given standard name.
- Parameters:
namedEnum
- the named enum to find an external name for- Returns:
- the external name
- Throws:
IllegalArgumentException
- if there is no external name
-
-