Package org.eclipse.graphiti.pattern.id

# Class IdPatternHelper

java.lang.Object
org.eclipse.graphiti.pattern.id.IdPatternHelper

public class IdPatternHelper extends Object
Some helper methods to be used in ID patterns and related features.

Since:
  0.18

## Constructor Summary

Constructors
Constructor
Description
`IdPatternHelper()`

## Method Summary

Modifier and Type
Method
Description
`static PropertyContainer`
`findById(PictogramElement pictogramElement, String idToFind)`
Searches for a `PictogramElement` that has the given ID starting from the given `PictogramElement`.
`static PropertyContainer`
`findByIdInGraphicsAlgorithmChildren(GraphicsAlgorithm graphicsAlgorithm, String idToFind)`
Searches for a `PictogramElement` that has the given ID starting from the given `PictogramElement`.
`static String`
`getId(PropertyContainer container)`
Returns any ID that has been set for the given `PictogramElement`; it can be any `PropertyContainer`, especially `Shape`s or `GraphicsAlgorithm`s are allowed.
`static void`
`setId(PropertyContainer container, String id)`
Set the ID property (
invalid reference

    #PROPERTY_KEY_ID

) for the given `PictogramElement`; it can be any `PropertyContainer` ,especially `Shape`s or `GraphicsAlgorithm`s are allowed.

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

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

## Constructor Details

### IdPatternHelper

public IdPatternHelper()

## Method Details

### getId

public static String getId(PropertyContainer container)
Returns any ID that has been set for the given `PictogramElement`; it can be any `PropertyContainer`, especially `Shape`s or `GraphicsAlgorithm`s are allowed.

Parameters:
  `container` - The `PictogramElement` to get the ID property from
Returns:
  A `String` representing the value of the property or `null` in case the property is not set, see `setId(PropertyContainer, String)`.

### setId

public static void setId(PropertyContainer container, String id)
Set the ID property (
invalid reference

    #PROPERTY_KEY_ID

) for the given `PictogramElement`; it can be any `PropertyContainer` ,especially `Shape`s or `GraphicsAlgorithm`s are allowed. The used ID string can later be used to identify the shape, e.g. in the update or layout methods.

Parameters:
  `container` - The `PictogramElement` to set the ID property for
  `id` - The `String` ID to set.

### findById

public static PropertyContainer findById(PictogramElement pictogramElement, String idToFind)
Searches for a `PictogramElement` that has the given ID starting from the given `PictogramElement`. First the given element is checked, then its `GraphicsAlgorithm`; after that the `PictogramElement` children are checked recursively and last the `GraphicsAlgorithm` children also recursively. The first `PictogramElement` that has the given ID is returned, in case none is found in the tree spanned by the given `PictogramElement`, `null` is returned.

Parameters:
  `pictogramElement` - The `PictogramElement` at which the search shall start, any `Shape`s or `GraphicsAlgorithm`s on top of this element are ignored.
  `idToFind` - A `String` representing the ID to search for
Returns:
  The `PictogramElement` that has the given ID property, in case none id found `null`.

### findByIdInGraphicsAlgorithmChildren

public static PropertyContainer findByIdInGraphicsAlgorithmChildren(GraphicsAlgorithm graphicsAlgorithm, String idToFind)
Searches for a `PictogramElement` that has the given ID starting from the given `PictogramElement`. The `PictogramElement` children are checked recursively and last the `GraphicsAlgorithm` children also recursively. The first `PictogramElement` that has the given ID is returned, in case none is found in the tree spanned by the given `PictogramElement`, `null` is returned.

Parameters:
  `idToFind` - A `String` representing the ID to search for
  `pictogramElement` - The `PictogramElement` at which the search shall start, any `Shape`s or `GraphicsAlgorithm`s on top of this element are ignored.
Returns:
  The `PictogramElement` that has the given ID property, in case none id found `null`.