Package org.apache.sling.discovery.commons.providers

# Class DefaultClusterView

java.lang.Object
org.apache.sling.discovery.commons.providers.DefaultClusterView

All Implemented Interfaces:
  `org.apache.sling.discovery.ClusterView`

Direct Known Subclasses:
  `LocalClusterView`

public class DefaultClusterView extends Object implements org.apache.sling.discovery.ClusterView
Default implementation of the ClusterView interface.

Besides implementing the interface methods it also adds add/remove of InstanceDescriptions as well as implementing equals and hashCode.

## Constructor Summary

Constructors
Constructor
Description
`DefaultClusterView(String id)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addInstanceDescription(DefaultInstanceDescription instance)`
Add the given instance to this cluster and set the cluster on the instance (back pointer)
`boolean`
`equals(Object obj)`
`String`
`getId()`
`List<org.apache.sling.discovery.InstanceDescription>`
`getInstances()`
`org.apache.sling.discovery.InstanceDescription`
`getLeader()`
`org.apache.sling.discovery.InstanceDescription`
`getLocalInstance()`
Returns the local InstanceDescription or null if no local instance is listed
`int`
`hashCode()`
`boolean`
`removeInstanceDescription(org.apache.sling.discovery.InstanceDescription instance)`
Removes the given instance from this cluster.
`String`
`toString()`

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

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

## Constructor Details

### DefaultClusterView

public DefaultClusterView(String id)

## Method Details

### equals

public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### getId

public String getId()

Specified by:
  `getId` in interface `org.apache.sling.discovery.ClusterView`

### addInstanceDescription

public void addInstanceDescription(DefaultInstanceDescription instance)
Add the given instance to this cluster and set the cluster on the instance (back pointer)

Parameters:
  `instance` - the instance to add to this cluster

### getInstances

public List<org.apache.sling.discovery.InstanceDescription> getInstances()

Specified by:
  `getInstances` in interface `org.apache.sling.discovery.ClusterView`

### getLeader

public org.apache.sling.discovery.InstanceDescription getLeader()

Specified by:
  `getLeader` in interface `org.apache.sling.discovery.ClusterView`

### removeInstanceDescription

public boolean removeInstanceDescription(org.apache.sling.discovery.InstanceDescription instance)
Removes the given instance from this cluster.

Note that the instance will still have a pointer to this cluster however.

Parameters:
  `instance` - the instance to remove from this cluster

### getLocalInstance

public org.apache.sling.discovery.InstanceDescription getLocalInstance()
Returns the local InstanceDescription or null if no local instance is listed

Returns:
  the local InstanceDescription or null if no local instance is listed
Throws:
  `IllegalStateException` - if multiple local instances are listed