Enum Class ValueExistencePolicy
- All Implemented Interfaces:
Serializable, Comparable<ValueExistencePolicy>, Constable
Whatever
MetadataStandard.asValueMap(…) shall contain entries for null,
nil or empty values. By default the value map does not provide
entries for null metadata properties, nil objects or
empty collections.
This enumeration allows to control this behavior.
Difference between null and nil
A null property is a reference which isnull in the Java sense.
Null references can be used for missing properties when no information is provided about why the property is missing.
On the other hand, a nil object is a placeholder for a missing property similar in purpose to null references,
except that an explanation about why the property is missing can be attached to those objects.
Those explanations can be obtained by calls to the NilReason.forObject(Object) method.- Since:
- 0.3
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionIncludes all entries in the map, including those having a null value or an empty collection.Same asTITLEDbut omitting the properties which have been used as titles.Includes only the properties that are non-null, non-nil and non empty.Includes only the non-null and non-nil properties.Includes only the non-null properties.Same asNON_EMPTY, but with the addition of titles associated with metadata objects. -
Method Summary
Modifier and TypeMethodDescriptionstatic ValueExistencePolicyReturns the enum constant of this class with the specified name.static ValueExistencePolicy[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
ALL
Includes all entries in the map, including those having a null value or an empty collection. -
NON_NULL
Includes only the non-null properties.NilObjects are included. Collections are included no matter if they are empty or not.The set of
NON_NULLproperties is a subset ofALLproperties. -
NON_NIL
Includes only the non-null and non-nil properties. Collections are included no matter if they are empty or not.The set of
NON_NILproperties is a subset ofNON_NULLproperties.- Since:
- 0.4
-
NON_EMPTY
Includes only the properties that are non-null, non-nil and non empty. A non-null and non-nil property is considered empty in any of the following cases:- It is a character sequence containing only whitespaces.
- It is an empty collection.
- It is an empty map.
- It is an empty array (of length 0).
AbstractMetadata.asMap().The set of
NON_EMPTYproperties is a subset ofNON_NILproperties. -
TITLED
Same asNON_EMPTY, but with the addition of titles associated with metadata objects. Metadata objects such asare normally associated with no textual value. Texts are rather associated with properties of the metadata object. But some metadata classes have a property which can summarize the whole object. For example, forinvalid reference
CitationCitationobjects, this property is the citation title.The property to use as the title of a metadata object is specified by the
TitlePropertyannotation on the metadata implementation class (for example,DefaultCitation). When using thisTITLEDor theCOMPACTpolicy, the values of the properties identified by theTitlePropertyannotations are copied in the root of the metadata sub-tree. SeeCOMPACTJavadoc for an example.- Since:
- 1.7
- See Also:
-
COMPACT
Same asTITLEDbut omitting the properties which have been used as titles. This omission removes a redundancy, thus making the tree a little bit more compact, at the expanse of a slight departure from the metadata model. For metadata classes withoutTitlePropertyannotation, this policy is equivalent toNON_EMPTY.Example
TheDefaultCitationandDefaultCitationDateclasses are annotated with@TitleProperty(name="title")and@TitleProperty(name="date")respectively. The following table compares the trees produced by three policies:
ThisComparison of policies on the same metadata NON_EMPTYTITLEDCOMPACTCitation ├─Title……………………… My document └─Date ├─Date………………… 2012/01/01 └─Date type…… CreationCitation……………………… My document ├─Title……………………… My document └─Date………………………… 2012/01/01 ├─Date………………… 2012/01/01 └─Date type…… CreationCitation……………………… My document └─Date………………………… 2012/01/01 └─Date type…… CreationCOMPACTpolicy is the default behavior ofAbstractMetadata.asTreeTable(). Therefore, this policy defines the default rendering ofAbstractMetadata.toString().- Since:
- 0.8
- See Also:
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-