Class ResourceChange


  • @ConsumerType
    public class ResourceChange
    extends java.lang.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 class  ResourceChange.ChangeType
      The type of the change
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      @Nullable java.util.Set<java.lang.String> getAddedPropertyNames()
      Deprecated.
      As there is no guarantee that this information is contained in the change event, this should not be used anymore.
      @Nullable java.util.Set<java.lang.String> getChangedPropertyNames()
      Deprecated.
      As there is no guarantee that this information is contained in the change event, this should not be used anymore.
      @NotNull java.lang.String getPath()
      Get the resource path.
      @Nullable java.util.Set<java.lang.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 java.lang.String getUserId()
      Get the user id of the user initiating the change
      boolean isExternal()
      Is this an external event?
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ResourceChange

        public ResourceChange​(@NotNull
                              @NotNull ResourceChange.ChangeType changeType,
                              @NotNull
                              @NotNull java.lang.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 java.lang.String path,
                              boolean isExternal,
                              java.util.Set<java.lang.String> addedPropertyNames,
                              java.util.Set<java.lang.String> changedPropertyNames,
                              java.util.Set<java.lang.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 Detail

      • getPath

        @NotNull
        public @NotNull java.lang.String getPath()
        Get the resource path.
        Returns:
        The path to the resource.
      • getUserId

        @Nullable
        public @Nullable java.lang.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.
      • getChangedPropertyNames

        @Deprecated
        @Nullable
        public @Nullable java.util.Set<java.lang.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 java.util.Set<java.lang.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 java.util.Set<java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object