public final class SObjectTree extends Object implements Serializable
This will generate a tree of SObjects resembling:Account account = ... Contact president = ... Contact marketing = ... Account anotherAccount = ... Contact sales = ... Asset someAsset = ... SObjectTree request = new SObjectTree(); request.addObject(account).addChildren(president, marketing); request.addObject(anotherAccount).addChild(sales).addChild(someAsset);
By default references that correlate between SObjects in the tree and returned identifiers and errors are handled automatically, if you wish to customize the generation of the reference implement. |-- account | |-- president | `-- marketing `-- anotherAccount `-- sales `-- someAsset
ReferenceGenerator
and
supply it as constructor argument to SObjectTree(ReferenceGenerator)
.
Note that the tree can hold single object type at the root of the tree.Constructor and Description |
---|
SObjectTree()
Create new SObject tree with the default
ReferenceGenerator . |
SObjectTree(ReferenceGenerator referenceGenerator)
Create new SObject tree with custom
ReferenceGenerator . |
Modifier and Type | Method and Description |
---|---|
SObjectNode |
addObject(AbstractSObjectBase object)
Add SObject at the root of the tree.
|
Stream<SObjectNode> |
allNodes()
Returns a stream of all nodes in the tree.
|
Stream<AbstractSObjectBase> |
allObjects()
Returns a stream of all objects in the tree.
|
String |
getObjectType()
Returns the type of the objects in the root of the tree.
|
Class[] |
objectTypes() |
void |
setErrorFor(String referenceId,
List<RestError> errors)
Sets errors for the given reference.
|
void |
setIdFor(String referenceId,
String id)
Sets identifier of SObject for the given reference.
|
int |
size()
Returns the number of elements in the tree.
|
public SObjectTree()
ReferenceGenerator
.public SObjectTree(ReferenceGenerator referenceGenerator)
ReferenceGenerator
.public SObjectNode addObject(AbstractSObjectBase object)
object
- SObject to addSObjectNode
for the given SObjectpublic Stream<SObjectNode> allNodes()
public Stream<AbstractSObjectBase> allObjects()
public String getObjectType()
public Class[] objectTypes()
public void setErrorFor(String referenceId, List<RestError> errors)
referenceId
- reference identifiererrors
- list of RestError
public void setIdFor(String referenceId, String id)
referenceId
- reference identifierid
- SObject identifierpublic int size()
Apache Camel