org.modeshape.jcr.cache

## Class SiblingCounter

- java.lang.Object
- - org.modeshape.jcr.cache.SiblingCounter

-     public abstract class SiblingCounter
      extends Object

  A function interface that determines (potentially lazily) the number of siblings with a given name.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SiblingCounter()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static SiblingCounter` | `alter(SiblingCounter counter, int delta)` Creates a sibling counter that alters another counter by a constant value.
    `static SiblingCounter` | `constant(int count)` Create a sibling counter that always return the supplied count, regardless of the name or node.
    `abstract int` | `countSiblingsNamed(Name childName)` Get the number of existing siblings that all have the supplied name.
    `static SiblingCounter` | `create(CachedNode node, NodeCache cache)` Creates a sibling counter that lazily obtains a `ChildReferences`.
    `static SiblingCounter` | `create(ChildReferences childRefs)` Creates a sibling counter that uses the supplied `ChildReferences`.
    `static SiblingCounter` | `noSiblings()` Create a sibling counter that always returns '0' for the number of same name siblings.
    `static SiblingCounter` | `oneSibling()` Create a sibling counter that always returns '1' for the number of same name siblings.

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

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

- - ### Constructor Detail

    - #### SiblingCounter

          public SiblingCounter()

  - ### Method Detail

    - #### countSiblingsNamed

          public abstract int countSiblingsNamed(Name childName)

      Get the number of existing siblings that all have the supplied name. If the implementation is expensive, it should cache the result so subsequent calls with the same parameter are fast.
      Parameters:
        `childName` - the name for the siblings; may not be null
      Returns:
        the number of existing siblings with the new child's name

    - #### noSiblings

          public static SiblingCounter noSiblings()

      Create a sibling counter that always returns '0' for the number of same name siblings.
      Returns:
        the counter that always returns 0; never null

    - #### oneSibling

          public static SiblingCounter oneSibling()

      Create a sibling counter that always returns '1' for the number of same name siblings.
      Returns:
        the counter that always returns 0; never null

    - #### constant

          public static SiblingCounter constant(int count)

      Create a sibling counter that always return the supplied count, regardless of the name or node.
      Parameters:
        `count` - the count to be returned; may not be negative
      Returns:
        the counter that always returns `count`; never null

    - #### create

          public static SiblingCounter create(ChildReferences childRefs)

      Creates a sibling counter that uses the supplied `ChildReferences`.
      Parameters:
        `childRefs` - the child references; may not be null
      Returns:
        the sibling counter; never null

    - #### create

          public static SiblingCounter create(CachedNode node,
                              NodeCache cache)

      Creates a sibling counter that lazily obtains a `ChildReferences`.
      Parameters:
        `node` - the node; may not be null
        `cache` - the cache; may not be null
      Returns:
        the sibling counter; never null

    - #### alter

          public static SiblingCounter alter(SiblingCounter counter,
                             int delta)

      Creates a sibling counter that alters another counter by a constant value.
      Parameters:
        `counter` - the sibling counter; may not be null
        `delta` - the positive or negative amount by which the `counter`'s value is altered
      Returns:
        the sibling counter; never null

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.