Class ValueInspectorService<T extends GenericValue>

  • All Implemented Interfaces:
    io.wcm.sling.commons.caservice.ContextAwareService

    @ConsumerType
    public abstract class ValueInspectorService<T extends GenericValue>
    extends java.lang.Object
    implements io.wcm.sling.commons.caservice.ContextAwareService
    Allows to customize the inspection process which turns properties in Sling Models instance to specific ones e.g. for links, media and rich text.
    • Field Summary

      • Fields inherited from interface io.wcm.sling.commons.caservice.ContextAwareService

        PROPERTY_ACCEPTS_CONTEXT_PATH_EMPTY, PROPERTY_CONTEXT_PATH_BLACKLIST_PATTERN, PROPERTY_CONTEXT_PATH_PATTERN
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      @NotNull java.util.List<T> inspect​(@NotNull java.lang.String key, @NotNull java.util.List<java.lang.Object> rawValues, @NotNull java.lang.Object instance)
      Inspect the value of given property to check if a specific value representation can be extracted.
      protected abstract T inspectValue​(@NotNull java.lang.String key, @NotNull java.lang.Object rawValue, @NotNull java.lang.Object instance)
      Inspects raw value and tries to convert it to the target type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ValueInspectorService

        public ValueInspectorService()
    • Method Detail

      • inspect

        @NotNull
        public @NotNull java.util.List<T> inspect​(@NotNull
                                                  @NotNull java.lang.String key,
                                                  @NotNull
                                                  @NotNull java.util.List<java.lang.Object> rawValues,
                                                  @NotNull
                                                  @NotNull java.lang.Object instance)
        Inspect the value of given property to check if a specific value representation can be extracted.
        Parameters:
        key - Property key
        rawValues - Raw property values
        instance - Instance property is read from for further inspection
        Returns:
        List of matching values that are found. Returns empty list if not value was found.
      • inspectValue

        @Nullable
        protected abstract T inspectValue​(@NotNull
                                          @NotNull java.lang.String key,
                                          @NotNull
                                          @NotNull java.lang.Object rawValue,
                                          @NotNull
                                          @NotNull java.lang.Object instance)
        Inspects raw value and tries to convert it to the target type.
        Parameters:
        key - Property key
        rawValue - Raw property value
        instance - Instance property is read from for further inspection
        Returns:
        Target type instance or null