org.apache.ignite.internal.util.lang

## Class GridNodePredicate

- java.lang.Object
- - org.apache.ignite.internal.util.lang.GridNodePredicate

All Implemented Interfaces:
  Serializable, Iterable<UUID>, IgnitePredicate<ClusterNode>

    public class GridNodePredicate
    extends Object
    implements IgnitePredicate<ClusterNode>, Iterable<UUID>

Convenient node predicate as a separate class. It allows to avoid "dragging" enclosing class's state when predicates are created as anonymous classes in stateful enclosing context. This class is also optimized for evaluation of large number of nodes.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`GridNodePredicate(ClusterNode... nodes)` Creates node predicate that evaluates to `true` for all provided nodes.
`GridNodePredicate(Collection<UUID> ids)` Creates node predicate that evaluates to `true` for all provided node IDs.
`GridNodePredicate(Set<UUID> ids)` Creates node predicate that evaluates to `true` for all provided node IDs.
`GridNodePredicate(UUID... ids)` Creates node predicate that evaluates to `true` for all provided node IDs.

### Method Summary

Methods
`boolean` `apply(ClusterNode n)` Predicate body.
`boolean` `equals(Object o)`
`int` `hashCode()`
`Iterator<UUID>` `iterator()`
`Set<UUID>` `nodeIds()` Gets set of node IDs this predicate is based on.
`String` `toString()`

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

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### GridNodePredicate

    public GridNodePredicate(Set<UUID> ids)

Creates node predicate that evaluates to `true` for all provided node IDs. Implementation will not make a defensive copy.

Parameters:
  `ids` - Optional node IDs. If none provided - predicate will always return `false`.

#### GridNodePredicate

    public GridNodePredicate(@Nullable
                     Collection<UUID> ids)

Creates node predicate that evaluates to `true` for all provided node IDs. Implementation will make a defensive copy.

Parameters:
  `ids` - Optional node IDs. If none provided - predicate will always return `false`.

#### GridNodePredicate

    public GridNodePredicate(@Nullable
                     UUID... ids)

Creates node predicate that evaluates to `true` for all provided node IDs. Implementation will make a defensive copy.

Parameters:
  `ids` - Optional node IDs. If none provided - predicate will always return `false`.

#### GridNodePredicate

    public GridNodePredicate(@Nullable
                     ClusterNode... nodes)

Creates node predicate that evaluates to `true` for all provided nodes. Implementation will make a defensive copy.

Parameters:
  `nodes` - Optional grid nodes. If none provided - predicate will always return `false`.

### Method Detail

#### nodeIds

    public Set<UUID> nodeIds()

Gets set of node IDs this predicate is based on. Note that for performance reasons this methods return the internal set that should not be modified by the caller.

Returns:
  Set of node IDs this predicate is based on.

#### iterator

    public Iterator<UUID> iterator()

Specified by:
  `iterator` in interface `Iterable<UUID>`

#### apply

    public boolean apply(ClusterNode n)

Predicate body.

Specified by:
  `apply` in interface `IgnitePredicate<ClusterNode>`
Parameters:
  `n` - Predicate parameter.
Returns:
  Return value.

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.7.0
Release Date | : August 1 2016