Package org.apache.sling.discovery.commons

# Class InstancesDiff.InstanceCollection

java.lang.Object
org.apache.sling.discovery.commons.InstancesDiff.InstanceCollection

Enclosing class:
  `InstancesDiff`

public final class InstancesDiff.InstanceCollection extends Object
The `InstanceCollection` collection allows to filter the instances using a set of custom filter either implementing `InstanceFilter` or pre-defined ones.

Filters conditions are joined combined together using the logical operator "AND".

## Method Summary

Modifier and Type
Method
Description
`@NotNull InstancesDiff.InstanceCollection`
`filterWith(@Nullable org.apache.sling.discovery.InstanceFilter filter)`
Filter the instances with a custom `InstanceFilter` filter.
`@NotNull Collection<org.apache.sling.discovery.InstanceDescription>`
`get()`
Return the collection of `InstanceDescription` instances that have not been filtered out.
`@NotNull InstancesDiff.InstanceCollection`
`isInClusterView(@Nullable org.apache.sling.discovery.ClusterView clusterView)`
Keep only the instances that are contained in the same `ClusterView` cluster view as the one provided.
`@NotNull InstancesDiff.InstanceCollection`
`isLeader()`
Keep only the leader instances (see `InstanceDescription.isLeader()`.
`@NotNull InstancesDiff.InstanceCollection`
`isLocal()`
Keep only the local instance (see `InstanceDescription.isLocal()`.
`@NotNull InstancesDiff.InstanceCollection`
`isNotInClusterView(@Nullable org.apache.sling.discovery.ClusterView clusterView)`
Filter out the instances that are contained in the same `ClusterView` cluster view as the one provided.
`@NotNull InstancesDiff.InstanceCollection`
`isNotLeader()`
Filter out the leader instances (see `InstanceDescription.isLeader()`.
`@NotNull InstancesDiff.InstanceCollection`
`isNotLocal()`
Filter out the local instances (see `InstanceDescription.isLocal()`.

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

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

## Method Details

### filterWith

@NotNull public @NotNull InstancesDiff.InstanceCollection filterWith(@Nullable @Nullable org.apache.sling.discovery.InstanceFilter filter)
Filter the instances with a custom `InstanceFilter` filter.

Parameters:
  `filter` - the filter to be applied on the instances
Returns:
  `this`

### isLocal

@NotNull public @NotNull InstancesDiff.InstanceCollection isLocal()
Keep only the local instance (see `InstanceDescription.isLocal()`.

Returns:
  `this`

### isNotLocal

@NotNull public @NotNull InstancesDiff.InstanceCollection isNotLocal()
Filter out the local instances (see `InstanceDescription.isLocal()`.

Returns:
  `this`

### isLeader

@NotNull public @NotNull InstancesDiff.InstanceCollection isLeader()
Keep only the leader instances (see `InstanceDescription.isLeader()`.

Returns:
  `this`

### isNotLeader

@NotNull public @NotNull InstancesDiff.InstanceCollection isNotLeader()
Filter out the leader instances (see `InstanceDescription.isLeader()`.

Returns:
  `this`

### isInClusterView

@NotNull public @NotNull InstancesDiff.InstanceCollection isInClusterView(@Nullable @Nullable org.apache.sling.discovery.ClusterView clusterView)
Keep only the instances that are contained in the same `ClusterView` cluster view as the one provided.

The comparison between cluster views is done on the basis of the cluster view identifier. Two cluster views with the same identifier are considered equal.

Parameters:
  `clusterView` - the cluster view used to filter the instances
Returns:
  `this`

### isNotInClusterView

@NotNull public @NotNull InstancesDiff.InstanceCollection isNotInClusterView(@Nullable @Nullable org.apache.sling.discovery.ClusterView clusterView)
Filter out the instances that are contained in the same `ClusterView` cluster view as the one provided.

The comparison between cluster views is done on the basis of the cluster view identifier. Two cluster views with the same identifier are considered equal.

Parameters:
  `clusterView` - the cluster view used to filter the instances
Returns:
  `this`

### get

@NotNull public @NotNull Collection<org.apache.sling.discovery.InstanceDescription> get()
Return the collection of `InstanceDescription` instances that have not been filtered out.

Returns:
  the filtered collection of instances.