public class EmptyReference<T> extends Reference<T>
Modifier and Type | Method and Description |
---|---|
static <T> Reference<T> |
create(java.lang.String fieldName)
Creates a dummy empty reference that serves as a null object to prevent NullPointerExceptions.
|
boolean |
equals(java.lang.Object o) |
T |
get()
Returns the object represented by this reference.
|
java.lang.String |
getFieldName()
A field name hinting where this reference was used.
|
java.lang.String |
getId()
Id of the object this reference represents.
|
java.lang.String |
getTypeId()
Type id of the object this reference represents, e.g.
|
int |
hashCode() |
boolean |
isEmpty()
True if this reference has no value in the parent object.
|
boolean |
isExpanded()
Checks whether a reference has been expanded.
|
protected java.lang.Object |
toJson() |
ReferenceId<T> |
toReferenceIdOrNull() |
java.lang.String |
toString() |
create, toUnexpandedReference
@Nonnull public java.lang.String getFieldName()
protected java.lang.Object toJson()
public static <T> Reference<T> create(java.lang.String fieldName)
fieldName
- Name of the attribute in the parent object where the reference is used, for better error messages.public boolean isExpanded()
isExpanded
before calling get()
.
This way, the user won't get an exception even if the reference was empty in the parent object.isExpanded
in class Reference<T>
public boolean isEmpty()
Reference
Reference.isEmpty()
returns true, there's not much to do with this reference - Reference.isExpanded()
will return false and all other methods will throw a ReferenceException
.public T get() throws ReferenceException
Reference
ReferenceException
. Never returns null.get
in class Reference<T>
ReferenceException
- If this reference has not been expanded.public java.lang.String getId() throws ReferenceException
Reference
getId
in class Reference<T>
ReferenceException
public java.lang.String getTypeId() throws ReferenceException
Reference
getTypeId
in class Reference<T>
ReferenceException
public ReferenceId<T> toReferenceIdOrNull()
toReferenceIdOrNull
in class Reference<T>