Package org.apache.sis.xml
Class NilObjectHandler
java.lang.Object
org.apache.sis.xml.NilObjectHandler
- All Implemented Interfaces:
InvocationHandler
The handler for an object where all methods returns null or empty collections, except
a few methods related to object identity. This handler is used only when no concrete
definition were found for a XML element identified by
xlink
or uuidref
attributes.
Implementation note:
The same handler could be used for every proxy having the same XLink.
For now, it doesn't seem worth to cache the handlers.
- Since:
- 0.3
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Object
The identifiers as anIdentifierMapAdapter
object, or thenilReason
attribute as aNilReason
object. -
Constructor Summary
ConstructorsConstructorDescriptionNilObjectHandler
(NilReason nilReason) Creates a new handler for an object which is nil for the given reason.NilObjectHandler
(org.opengis.metadata.Identifier[] identifiers) Creates a new handler for an object identified by the given identifiers. -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
equals
(Object proxy, Object other, ComparisonMode mode) Compares the given objects to the given level of strictness.private static Class<?>
getInterface
(Object proxy) Returns the interface implemented by the given proxy.Processes a method invocation.(package private) static boolean
isIgnoredInterface
(Class<?> type) Returnstrue
if the given type is one of the interfaces ignored bygetInterface(Object)
.
-
Field Details
-
attribute
The identifiers as anIdentifierMapAdapter
object, or thenilReason
attribute as aNilReason
object. We don't use separated fields because those attributes are exclusive, and some operations liketoString()
,hashCode()
andequals(Object)
are the same for both types.
-
-
Constructor Details
-
NilObjectHandler
NilObjectHandler(org.opengis.metadata.Identifier[] identifiers) Creates a new handler for an object identified by the given identifiers. The identifiers are wrapped in a mutable list, so users can add, remove or modify identifiers. -
NilObjectHandler
NilObjectHandler(NilReason nilReason) Creates a new handler for an object which is nil for the given reason.
-
-
Method Details
-
isIgnoredInterface
Returnstrue
if the given type is one of the interfaces ignored bygetInterface(Object)
. -
getInterface
Returns the interface implemented by the given proxy. -
invoke
Processes a method invocation. For any invocation of a getter method, there is a choice:- If the invoked method is
getIdentifiers()
, returns the identifiers given at construction time. - If the invoked method is
getIdentifierMap()
, returns a view over the identifiers given at construction time. - If the invoked method is any other kind of getter, returns null except if:
- the return type is a collection, in which case an empty collection is returned;
- the return type is a primitive, in which case the nil value for that primitive type is returned.
- If the invoked method is a setter method, throw a
UnsupportedOperationException
since the proxy instance is assumed unmodifiable. - If the invoked method is one of the
Object
method, delegate to theattribute
.
- Specified by:
invoke
in interfaceInvocationHandler
- Throws:
Throwable
- If the invoked method is
-
equals
Compares the given objects to the given level of strictness. The first object shall be the proxy, and the second object an arbitrary implementation. This method returnstrue
if the given arbitrary implementation contains only null or empty attributes.- Throws:
Throwable
-