java.lang.Object
org.apache.camel.component.salesforce.api.dto.composite.SObjectNode
All Implemented Interfaces:
Serializable

public final class SObjectNode extends Object implements Serializable
Represents one node in the SObject tree request. SObject trees (SObjectTree) are composed from instances of SObjectNodes. Each SObjectNode contains the SObject (AbstractSObjectBase) and any child records linked to it. SObjects at root level are added to SObjectTree using SObjectTree.addObject(AbstractSObjectBase), then you can add child records on the SObjectNode returned by using addChild(AbstractDescribedSObjectBase), addChildren(AbstractDescribedSObjectBase, AbstractDescribedSObjectBase...) or addChild(String, AbstractSObjectBase) and addChildren(String, AbstractSObjectBase, AbstractSObjectBase...).

Upon submission to the Salesforce Composite API the SObjectTree and the SObjectNodes in it might contain errors that you need to fetch using getErrors() method.

See Also:
  • Method Details

    • addChild

      public SObjectNode addChild(AbstractDescribedSObjectBase child)
      Add a described child with the metadata needed already present within it to the this node.
      Parameters:
      child - to add
      Returns:
      the newly created node, used in builder fashion to add more child objects to it (on the next level)
    • addChild

      public SObjectNode addChild(String labelPlural, AbstractSObjectBase child)
      Add a child that does not contain the required metadata to the this node. You need to specify the plural form of the child (e.g. `Account` its `Accounts`).
      Parameters:
      labelPlural - plural form
      child - to add
      Returns:
      the newly created node, used in builder fashion to add more child objects to it (on the next level)
    • addChildren

      public void addChildren(AbstractDescribedSObjectBase first, AbstractDescribedSObjectBase... others)
      Add multiple described children with the metadata needed already present within them to the this node..
      Parameters:
      first - first child to add
      others - any other children to add
    • addChildren

      public void addChildren(String labelPlural, AbstractSObjectBase first, AbstractSObjectBase... others)
      Add a child that does not contain the required metadata to the this node. You need to specify the plural form of the child (e.g. `Account` its `Accounts`).
      Parameters:
      labelPlural - plural form
      first - first child to add
      others - any other children to add
    • getChildNodes

      public Stream<SObjectNode> getChildNodes()
      Returns all children of this node (one level deep).
      Returns:
      children of this node
    • getChildNodesOfType

      public Stream<SObjectNode> getChildNodesOfType(String type)
      Returns all children of this node (one level deep) of certain type (in plural form).
      Parameters:
      type - type of child requested in plural form (e.g for `Account` is `Accounts`)
      Returns:
      children of this node of specified type
    • getChildren

      public Stream<AbstractSObjectBase> getChildren()
      Returns child SObjects of this node (one level deep).
      Returns:
      child SObjects of this node
    • getChildrenOfType

      public Stream<AbstractSObjectBase> getChildrenOfType(String type)
      Returns child SObjects of this node (one level deep) of certain type (in plural form)
      Parameters:
      type - type of child requested in plural form (e.g for `Account` is `Accounts`)
      Returns:
      child SObjects of this node
    • getErrors

      public List<RestError> getErrors()
      Errors reported against this this node received in response to the SObject tree being submitted.
      Returns:
      errors for this node
    • getObject

      public AbstractSObjectBase getObject()
      SObject at this node.
      Returns:
      SObject
    • hasErrors

      public boolean hasErrors()
      Are there any errors resulted from the submission on this node?
      Returns:
      true if there are errors
    • size

      public int size()
      Size of the branch beginning with this node (number of SObjects in it).
      Returns:
      number of objects within this branch
    • toString

      public String toString()
      Overrides:
      toString in class Object