Package org.apache.sling.api.resource.observation

# Class ResourceChange

java.lang.Object
org.apache.sling.api.resource.observation.ResourceChange

@ConsumerType public class ResourceChange extends Object
A resource change event is immutable. A change event can either be local or external. Local changes happened on the same instance, while external changes happened on a different instance. Resource listeners only receive external changes if they mark themselves as a `ExternalResourceChangeListener`. For all events (local and external), the path and the type of change is set. Resource provider events are always local events and only provide the path. Local events for resources provide the names of the properties that have been added, removed or changed. This information might be missing for external events.

Since:
  1.0.0 (Sling API Bundle 2.11.0)

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`ResourceChange.ChangeType`
The type of the change

## Constructor Summary

Constructors
Constructor
Description
`ResourceChange(@NotNull ResourceChange.ChangeType changeType, @NotNull String path, boolean isExternal)`
Create a new change object
`ResourceChange(@NotNull ResourceChange.ChangeType changeType, @NotNull String path, boolean isExternal, Set<String> addedPropertyNames, Set<String> changedPropertyNames, Set<String> removedPropertyNames)`
Deprecated.
The sets of property names are not supported anymore.

## Method Summary

Modifier and Type
Method
Description
`@Nullable Set<String>`
`getAddedPropertyNames()`
Deprecated.
As there is no guarantee that this information is contained in the change event, this should not be used anymore.
`@Nullable Set<String>`
`getChangedPropertyNames()`
Deprecated.
As there is no guarantee that this information is contained in the change event, this should not be used anymore.
`@NotNull String`
`getPath()`
Get the resource path.
`@Nullable Set<String>`
`getRemovedPropertyNames()`
Deprecated.
As there is no guarantee that this information is contained in the change event, this should not be used anymore.
`@NotNull ResourceChange.ChangeType`
`getType()`
Get the type of change
`@Nullable String`
`getUserId()`
Get the user id of the user initiating the change
`boolean`
`isExternal()`
Is this an external event?
`String`
`toString()`

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

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

## Constructor Details

### ResourceChange

public ResourceChange(@NotNull @NotNull ResourceChange.ChangeType changeType, @NotNull @NotNull String path, boolean isExternal)
Create a new change object

Parameters:
  `changeType` - The change type
  `path` - The resource path
  `isExternal` - {code true} if the change happened on another node
Since:
  1.2.0 (Sling API Bundle 2.15.0)

### ResourceChange

@Deprecated public ResourceChange(@NotNull @NotNull ResourceChange.ChangeType changeType, @NotNull @NotNull String path, boolean isExternal, Set<String> addedPropertyNames, Set<String> changedPropertyNames, Set<String> removedPropertyNames)
Deprecated.
The sets of property names are not supported anymore.
Create a new change object

Parameters:
  `changeType` - The change type
  `path` - The resource path
  `isExternal` - {code true} if the change happened on another node
  `addedPropertyNames` - set of added property names, if provided must be immutable
  `changedPropertyNames` - set of added property names, if provided must be immutable
  `removedPropertyNames` - set of added property names, if provided must be immutable

## Method Details

### getPath

@NotNull public @NotNull String getPath()
Get the resource path.

Returns:
  The path to the resource.

### getUserId

@Nullable public @Nullable String getUserId()
Get the user id of the user initiating the change

Returns:
  The user id or `null` if it's not available.

### isExternal

public boolean isExternal()
Is this an external event?

Returns:
  `true` if the event is external.

### getType

@NotNull public @NotNull ResourceChange.ChangeType getType()
Get the type of change

Returns:
  The type of change

### getChangedPropertyNames

@Deprecated @Nullable public @Nullable Set<String> getChangedPropertyNames()
Deprecated.
As there is no guarantee that this information is contained in the change event, this should not be used anymore.
Optional information about changed properties. The application code can not rely on getting the correct set of changed properties. A resource provider implementation is free to not support this. Therefore if this method returns `null` it does not mean that there are no changed properties. However if an empty set is returned, it can safely be assumed that there are none. Therefore returning {code null} is the equivalent of "don't know".

Returns:
  The set of changed property names. For external events or resource provider events `null` is returned.

### getAddedPropertyNames

@Deprecated @Nullable public @Nullable Set<String> getAddedPropertyNames()
Deprecated.
As there is no guarantee that this information is contained in the change event, this should not be used anymore.
Optional information about added properties. The application code can not rely on getting the correct set of added properties. A resource provider implementation is free to not support this. Therefore if this method returns `null` it does not mean that there are no added properties. However if an empty set is returned, it can safely be assumed that there are none. Therefore returning {code null} is the equivalent of "don't know".

Returns:
  The set of changed property names. For external events or resource provider events `null` is returned.

### getRemovedPropertyNames

@Deprecated @Nullable public @Nullable Set<String> getRemovedPropertyNames()
Deprecated.
As there is no guarantee that this information is contained in the change event, this should not be used anymore.
Optional information about removed properties. The application code can not rely on getting the correct set of removed properties. A resource provider implementation is free to not support this. Therefore if this method returns `null` it does not mean that there are no removed properties. However if an empty set is returned, it can safely be assumed that there are none. Therefore returning {code null} is the equivalent of "don't know".

Returns:
  The set of changed property names. For external events or resource provider events `null` is returned.

### toString

public String toString()

Overrides:
  `toString` in class `Object`