Package jnr.constants
Class ConstantSet
Provides forward and reverse lookup for platform constants
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final boolean
private static final ConcurrentMap
<String, ConstantSet> private static final ClassLoader
private static final Object
private Long
private Long
private static Throwable
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ConstantSet
(Class<Enum> enumClass) Creates a new instance ofConstantSet
-
Method Summary
Modifier and TypeMethodDescriptionboolean
getConstant
(long value) Gets the constant for a value.final Constant
getConstant
(String name) Gets the constant for a name.static ConstantSet
getConstantSet
(String name) Gets aConstantSet
getEnumClass
(String name) Gets theEnum
class for the constant name space.private Long
getLongField
(String name, long defaultValue) getName
(int value) Gets the name of a platform constant value.long
Gets the integer value of a platform constant.iterator()
private static ConstantSet
loadConstantSet
(String name) static void
long
maxValue()
Returns the maximum value in this ConstantSetlong
minValue()
Returns the minimum value in this ConstantSetint
size()
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Field Details
-
nameToConstant
-
valueToConstant
-
constants
-
enumClass
-
minValue
-
maxValue
-
constantSets
-
lock
-
LOADER
-
CAN_LOAD_RESOURCES
private static final boolean CAN_LOAD_RESOURCES -
RESOURCE_READ_ERROR
-
-
Constructor Details
-
ConstantSet
Creates a new instance ofConstantSet
- Parameters:
enumClass
- The Enum subclass to load constants from.
-
-
Method Details
-
getConstantSet
Gets aConstantSet
- Parameters:
name
- The name of the constant set to get.- Returns:
- A
ConstantSet
.
-
loadConstantSet
-
getEnumClass
Gets theEnum
class for the constant name space.- Parameters:
name
- The name of the constants to locate.- Returns:
- A Class.
-
getConstant
Gets the constant for a name.- Parameters:
name
- The name of the system constant (e.g. "EINVAL").- Returns:
- A
Constant
instance.
-
getConstant
Gets the constant for a value.- Parameters:
value
- A system constant value.- Returns:
- A
Constant
instance.
-
getValue
Gets the integer value of a platform constant.- Parameters:
name
- The name of the platform constant to look up (e.g. "EINVAL").- Returns:
- The integer value of the constant.
-
getName
Gets the name of a platform constant value.- Parameters:
value
- The integer value to look up.- Returns:
- The name of the constant.
-
getLongField
-
minValue
public long minValue()Returns the minimum value in this ConstantSet- Returns:
- a long value
-
maxValue
public long maxValue()Returns the maximum value in this ConstantSet- Returns:
- a long value
-
iterator
-
size
public int size()- Specified by:
size
in interfaceCollection<Constant>
- Specified by:
size
in interfaceSet<Constant>
- Specified by:
size
in classAbstractCollection<Constant>
-
contains
- Specified by:
contains
in interfaceCollection<Constant>
- Specified by:
contains
in interfaceSet<Constant>
- Overrides:
contains
in classAbstractCollection<Constant>
-
main
-