Package org.apache.sis.metadata
Enum ValueExistencePolicy
- All Implemented Interfaces:
Serializable,Comparable<ValueExistencePolicy>
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
- Version:
- 0.8
- See Also:
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionIncludes all entries in the map, including those having a null value or an empty collection.Includes non-empty properties but omits title properties.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. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanisEmpty(CharSequence value) Returnstrueif the given character sequence shall be considered empty.(package private) static booleanisNullOrEmpty(Object value) Returnstrueif the specified object is null or an empty collection, array or string.(package private) abstract booleanReturnstrueif the given value shall be skipped for this policy.(package private) abstract booleansubstituteByNullElement(Collection<?> values) ReturnstrueifTreeNodeshall substitute the given collection by a singleton containing only a null element.static ValueExistencePolicyReturns the enum constant of this type with the specified name.static ValueExistencePolicy[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
ALL
Includes all entries in the map, including those having a null value or an empty collection. -
NON_NULL
-
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. -
COMPACT
Includes non-empty properties but omits title properties. Values associated to title properties are instead associated with the parent node. This policy is relevant for metadata classes annotated withTitleProperty; for all other classes, this policy is identical toNON_EMPTY.Example: theThis policy is the default behavior ofDefaultCitationandDefaultCitationDateclasses are annotated with@TitleProperty(name="title")and@TitleProperty(name="date")respectively. The following table compares the trees produced by two policies:Comparison of "non-empty" and "compact" policy on the same metadata NON_EMPTYCOMPACTAbstractMetadata.asTreeTable(), and consequently defines the default rendering ofAbstractMetadata.toString().- Since:
- 0.8
- See Also:
-
-
Constructor Details
-
ValueExistencePolicy
private ValueExistencePolicy()
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException- if the argument is null
-
isSkipped
Returnstrueif the given value shall be skipped for this policy. -
substituteByNullElement
ReturnstrueifTreeNodeshall substitute the given collection by a singleton containing only a null element.Purpose
When a collection is null or empty, while not excluded according thisValueExistencePolicy, we need an empty space for making the metadata property visible inTreeNode. -
isNullOrEmpty
Returnstrueif the specified object is null or an empty collection, array or string.This method intentionally does not inspect array or collection elements, since this method is invoked from methods doing shallow copy or comparison. If we were inspecting elements, we would need to add a check against infinite recursivity.
This method does not check for the
Emptiableinterface because theisEmpty()method may be costly (for exampleAbstractMetadata.isEmpty()iterates over all the metadata tree). Instead, the check forEmptiablewill be done explicitly by the caller when appropriate. -
isEmpty
Returnstrueif the given character sequence shall be considered empty. The current implementation returnstrueif the sequence contains only whitespaces in the sense of Java (i.e. ignoring line feeds, but not ignoring non-breaking spaces). The exact criterion is not a committed part of the API and may change in future SIS versions according experiences.
-