public class TransparentWrapper extends java.lang.Object implements WrappedResource
WrappedResource
interface. Since hashCode()
and
equals(java.lang.Object)
are redirected to the contained reference, this is as
suitable for use in a collection as the contained reference.Modifier and Type | Field and Description |
---|---|
private java.lang.Long |
id
The resource's ID.
|
protected java.lang.Object |
referent
The object being contained.
|
Constructor and Description |
---|
TransparentWrapper(java.lang.Object referent)
Construct an instance given the object reference to contain.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Determines if this instance and the passed-in instance are equivalent.
|
java.lang.Object |
get()
Returns the referent of this instance as an
Object . |
int |
hashCode()
Hash code implementation which is redirected to that of the
contained object so long as that object is not
null . |
java.lang.Long |
id()
Get this resource's ID, if is already set.
|
void |
id(long id)
Set this resource's ID.
|
void |
set(java.lang.Object referent)
Set the referent of this instance.
|
boolean |
unknown()
Reports if this object is unknown.
|
boolean |
valid()
Reports if this object is valid for use.
|
protected java.lang.Object referent
private java.lang.Long id
null
until the ID is requested via
handle.resourceId(com.goldencode.p2j.util.WrappedResource)
public TransparentWrapper(java.lang.Object referent)
referent
- The object to contain.public java.lang.Long id()
id
in interface WrappedResource
null
if not set.public void id(long id)
id
in interface WrappedResource
id
- The resource's ID.public java.lang.Object get()
Object
.Object
or null
if
there is no contained object.public void set(java.lang.Object referent)
referent
- The value to be represented in this instance.public boolean valid()
WrappedResource
, then this
call will be redirected to the contained object. Otherwise, if
the contained object is null
, then it is considered
invalid and not null
is valid.valid
in interface WrappedResource
true
if we are valid (can be used).public boolean unknown()
If referent
is not an instance of WrappedResource
, it
returns false. Else, it returns WrappedResource.unknown()
result.
unknown
in interface WrappedResource
true
if object is unknown.public int hashCode()
null
.hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- The instance to compare against.true
if the objects are the same.