org.eclipse.handly.model.impl.support

## Class Body

- java.lang.Object
- - org.eclipse.handly.model.impl.support.Body

- Direct Known Subclasses:
    SourceElementBody

      public class Body
      extends java.lang.Object

  Holds cached structure and properties for an `IElement`.

  This implementation is thread-safe under the condition that mutator methods are not invoked concurrently. If multiple threads access a body concurrently, and at most one of them modifies the body, which is the typical usage pattern, external synchronization is not required.

  Clients can use this class as it stands or subclass it as circumstances warrant.

  See Also:
    `IBodyCache`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Body()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addChild(IElement child)` Adds the given child element to this body if it is not already present.
    `void` | `findContentChange(Body oldBody, IElement element, IElementDeltaBuilder builder)` Finds whether this body has had a content change.
    `IElement[]` | `getChildren()` Returns the child elements for this body.
    `void` | `removeChild(IElement child)` Removes the given child element from this body if it is present.
    `void` | `setChildren(IElement[] children)` Sets the child elements for this body.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Body

          public Body()

  - ### Method Detail

    - #### getChildren

          public IElement[] getChildren()

      Returns the child elements for this body.

      This implementation returns an array of exactly the same runtime type as the array given in the most recent call to `setChildren`.

      Returns:
        the child elements for this body (never `null`). Clients must not modify the returned array.

    - #### setChildren

          public void setChildren(IElement[] children)

      Sets the child elements for this body. Clients must not modify the given array afterwards.
      Parameters:
        `children` - not `null`, must not contain `null` elements

    - #### addChild

          public void addChild(IElement child)

      Adds the given child element to this body if it is not already present. Throws a runtime exception if the class of the given element prevents it from being added.
      Parameters:
        `child` - not `null`

    - #### removeChild

          public void removeChild(IElement child)

      Removes the given child element from this body if it is present.
      Parameters:
        `child` - may be `null`

    - #### findContentChange

          public void findContentChange(Body oldBody,
                                        IElement element,
                                        IElementDeltaBuilder builder)

      Finds whether this body has had a content change.

      Implementations can compare this body and the given old body and, if there are differences (excepting children), insert an appropriate change delta (such as `F_CONTENT`) for the given element into the delta tree being built. Implementations should not take changes in children into account.

      Parameters:
        `oldBody` - the old version of the body (not `null`)
        `element` - the element this body corresponds to (not `null`)
        `builder` - represents the delta tree being built (not `null`)

Copyright (c) 2014, 2020 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0