T - the type of the enumpublic static final class ExtendedEnum.ExternalEnumNames<T extends Named> extends Object
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.
| Modifier and Type | Method and 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> |
lookup(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() |
public T lookup(String 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.
name - the enum name to returnIllegalArgumentException - if the name is not foundpublic <S extends T> S lookup(String name, Class<S> subtype)
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.
S - the enum subtypesubtype - the enum subtype to matchname - the enum name to returnIllegalArgumentException - if the name is not found or has the wrong typepublic ImmutableMap<String,String> externalNames()
The map is keyed by the external name.
public String reverseLookup(T namedEnum)
This searches the map of external names and returns the first matching entry that maps to the given standard name.
namedEnum - the named enum to find an external name forIllegalArgumentException - if there is no external nameCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.