Package org.apache.sis.internal.util
Class CodeLists
java.lang.Object
org.apache.sis.internal.util.CodeLists
- All Implemented Interfaces:
org.opengis.util.CodeList.Filter
Implementation of some
Types
methods needed by sis-utility
module.
This class opportunistically implements CodeList.Filter
interface, but this should be considered
an implementation details.- Since:
- 1.0
- Version:
- 1.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
Returnstrue
if the given names matches the name we are looking for.boolean
accept
(org.opengis.util.CodeList<?> code) Returnstrue
if the given code matches the name we are looking for.codename()
Returns the name of the code to create, ornull
if no new code list shall be created.static <T extends Enum<T>>
TReturns the enumeration value of the given type that matches the given name, ornull
if none.static <T extends org.opengis.util.CodeList<T>>
TReturns the code of the given type that matches the given name, or optionally returns a new one if none match the name.static <T extends org.opengis.util.CodeList<?>>
T[]Returns all known values for the given type of code list or enumeration.
-
Field Details
-
RESOURCES
The name of bundle resources for code list titles. The resources should be loaded with the same class loader thanorg.opengis.annotation.UML.class.getClassLoader()
. Keys areCodeList.identifier()
.- See Also:
-
codename
The name to compare during filtering operation. -
canCreate
private final boolean canCreatetrue
ifCodeList.valueOf(java.lang.Class<T>, java.lang.String)
is allowed to create new code lists.
-
-
Constructor Details
-
CodeLists
Creates a new filter for the specified code name.
-
-
Method Details
-
codename
Returns the name of the code to create, ornull
if no new code list shall be created.- Specified by:
codename
in interfaceorg.opengis.util.CodeList.Filter
- Returns:
- the name specified at construction time.
-
accept
public boolean accept(org.opengis.util.CodeList<?> code) Returnstrue
if the given code matches the name we are looking for.- Specified by:
accept
in interfaceorg.opengis.util.CodeList.Filter
- Parameters:
code
- the code list candidate.
-
accept
Returnstrue
if the given names matches the name we are looking for. This is defined in a separated method in order to ensure that all code paths use the same criterion. -
forName
public static <T extends org.opengis.util.CodeList<T>> T forName(Class<T> codeType, String name, boolean canCreate) Returns the code of the given type that matches the given name, or optionally returns a new one if none match the name.- Type Parameters:
T
- the compile-time type given as thecodeType
parameter.- Parameters:
codeType
- the type of code list.name
- the name of the code to obtain, ornull
.canCreate
-true
if this method is allowed to create new code.- Returns:
- a code matching the given name, or
null
. - See Also:
-
forName
Returns the enumeration value of the given type that matches the given name, ornull
if none.- Type Parameters:
T
- the compile-time type given as theenumType
parameter.- Parameters:
enumType
- the type of enumeration.name
- the name of the enumeration value to obtain, ornull
.- Returns:
- a value matching the given name, or
null
. - See Also:
-
values
Returns all known values for the given type of code list or enumeration.- Type Parameters:
T
- the compile-time type given as thecodeType
parameter.- Parameters:
codeType
- the type of code list or enumeration.- Returns:
- the list of values for the given code list or enumeration, or an empty array if none.
- See Also:
-