com.atlassian.confluence.api.model.reference
Class Reference<T>

java.lang.Object
  extended by com.atlassian.confluence.api.model.reference.Reference<T>
Type Parameters:
T - - the type of the Referent object
All Implemented Interfaces:
java.lang.Iterable<T>
Direct Known Subclasses:
ExpandedReference

@ExperimentalApi
public abstract class Reference<T>
extends java.lang.Object
implements java.lang.Iterable<T>

A reference to a model object. References can be either expanded or collapsed. The object that a reference points to can either exist or not. If a reference both exists and is expanded then call to get() will return the referenced object. Collapsed References provide id properties that give just enough information to identify the referenced object. Model object that wish to be able to have references generated for them need to provide an enum named IdProperties. This enum must have values that match the name of the fields in the object that comprise it's ID.


Constructor Summary
Reference()
           
 
Method Summary
static
<T> Reference<T>
collapsed(java.lang.Class objClass)
           
static
<T> Reference<T>
collapsed(java.lang.Class objClass, java.util.Map idProperties)
           
static
<T> Reference<T>
collapsed(T obj)
          create a collapse reference to the given object
static
<T> Reference<T>
empty(java.lang.Class<T> referrentClass)
          create an empty reference to the given class
abstract  boolean exists()
           
abstract  T get()
           
abstract  java.util.Map<java.lang.Object,java.lang.Object> getIdProperties()
          A map of properties key by the idProperty enum in the model class for the referent object.
 java.lang.Object getIdProperty(java.lang.Enum key)
           
abstract  boolean isExpanded()
          indicates a reference is expanded and can be resolved to an object by calling get, or whether the reference is collapsed and calling get will throw an exception.
static
<T> Reference<T>
orEmpty(Reference<T> reference, java.lang.Class<T> referentClass)
           
static
<T> Reference<T>
orEmpty(T entity, java.lang.Class<T> referentClass)
           
abstract  java.lang.Class<? extends T> referentClass()
           
static
<T> Reference<T>
to(T obj)
          create an exanded reference to the referent object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Iterable
iterator
 

Constructor Detail

Reference

public Reference()
Method Detail

get

public abstract T get()
               throws java.lang.IllegalStateException
Returns:
the reference object or null if the object does not exist. It is Illegal to call get() on a reference that has not been expanded
Throws:
java.lang.IllegalStateException

exists

public abstract boolean exists()
Returns:
true if the object is expanded and exists, or is collapsed and has enough information to identify itself, false if the object does not exist (is empty)

isExpanded

public abstract boolean isExpanded()
indicates a reference is expanded and can be resolved to an object by calling get, or whether the reference is collapsed and calling get will throw an exception.

Returns:
true if the reference is expanded, false otherwise

getIdProperties

public abstract java.util.Map<java.lang.Object,java.lang.Object> getIdProperties()
A map of properties key by the idProperty enum in the model class for the referent object. The map contains properties sufficient to identify the referent object.

Returns:
a map of id properties keyed by idProperty enum

getIdProperty

public java.lang.Object getIdProperty(java.lang.Enum key)

referentClass

public abstract java.lang.Class<? extends T> referentClass()
Returns:
the class of the referent object.

empty

public static <T> Reference<T> empty(java.lang.Class<T> referrentClass)
create an empty reference to the given class

Type Parameters:
T -
Parameters:
referrentClass -
Returns:

orEmpty

public static <T> Reference<T> orEmpty(Reference<T> reference,
                                       java.lang.Class<T> referentClass)
Type Parameters:
T -
Parameters:
reference -
referentClass -
Returns:
the reference parameter or an empty reference if the reference is null or does not exist

orEmpty

public static <T> Reference<T> orEmpty(T entity,
                                       java.lang.Class<T> referentClass)

collapsed

public static <T> Reference<T> collapsed(T obj)
create a collapse reference to the given object

Parameters:
obj -
Returns:

collapsed

public static <T> Reference<T> collapsed(java.lang.Class objClass)

collapsed

public static <T> Reference<T> collapsed(java.lang.Class objClass,
                                         java.util.Map idProperties)

to

public static <T> Reference<T> to(T obj)
create an exanded reference to the referent object

Parameters:
obj -
Returns:


Copyright © 2003-2014 Atlassian. All Rights Reserved.