org.apache.sling.discovery.impl.common

## Class View

- java.lang.Object
- - org.apache.sling.discovery.impl.common.View

Direct Known Subclasses:
  VotingView

    public class View
    extends Object

DAO for a view stored in the repository.

### Field Summary

Fields
`protected static String` `VIEW_PROPERTY_CLUSTER_ID`
`protected static String` `VIEW_PROPERTY_CLUSTER_ID_DEFINED_AT`
`protected static String` `VIEW_PROPERTY_CLUSTER_ID_DEFINED_BY`

### Constructor Summary

Constructors
Constructor and Description
`View(org.apache.sling.api.resource.Resource resource)`

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `equals(Object obj)`
`org.apache.sling.api.resource.Resource` `getResource()` Returns the underlying resource of this view.
`String` `getViewId()` Returns the id of this view.
`int` `hashCode()`
`String` `matches(Set<String> view)` Compare this view with the given set of slingIds
`String` `matchesLiveView(org.apache.sling.api.resource.Resource clusterInstancesRes, Config config)` Checks whether this view matches the 'live view' as represented in the clusterInstances resource
`void` `remove(boolean logErrorOnFailure)` Delete this view from the repository

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

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

### Field Detail

#### VIEW_PROPERTY_CLUSTER_ID

    protected static final String VIEW_PROPERTY_CLUSTER_ID

See Also:
  Constant Field Values

#### VIEW_PROPERTY_CLUSTER_ID_DEFINED_AT

    protected static final String VIEW_PROPERTY_CLUSTER_ID_DEFINED_AT

See Also:
  Constant Field Values

#### VIEW_PROPERTY_CLUSTER_ID_DEFINED_BY

    protected static final String VIEW_PROPERTY_CLUSTER_ID_DEFINED_BY

See Also:
  Constant Field Values

### Constructor Detail

#### View

    public View(org.apache.sling.api.resource.Resource resource)

### Method Detail

#### getResource

    public org.apache.sling.api.resource.Resource getResource()

Returns the underlying resource of this view.

Returns:
  the underlying resource of this view

#### equals

    public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### getViewId

    public String getViewId()

Returns the id of this view.

Returns:
  the id of this view

#### matchesLiveView

    public String matchesLiveView(org.apache.sling.api.resource.Resource clusterInstancesRes,
                                  Config config)
                           throws Exception

Checks whether this view matches the 'live view' as represented in the clusterInstances resource

Parameters:
  `clusterInstancesRes` - the clusterInstances resource against which to check
Returns:
  null if view matches, not-null-details about what differs if they don't match
Throws:
  `Exception` - thrown the view cannot be properly matched - eg when the ./members resource doesn't exist at all or a RuntimeException occurs

#### matches

    public String matches(Set<String> view)
                   throws Exception

Compare this view with the given set of slingIds

Parameters:
  `view` - a set of slingIds against which to compare this view
Returns:
  true if this view matches the given set of slingIds
Throws:
  `Exception` - thrown the view cannot be properly matched - eg when the ./members resource doesn't exist at all or a RuntimeException occurs

#### remove

    public void remove(boolean logErrorOnFailure)

Delete this view from the repository