Class Config

java.lang.Object
com.adobe.granite.ui.components.Config

public class Config extends Object
The config properties of a resource.
  • Field Details

    • DEFAULTS

      @Nonnull public static String DEFAULTS
      The resource name for the defaults config ("defaults").
    • ITEMS

      @Nonnull public static String ITEMS
      The resource name for items ("items").
    • LAYOUT

      @Nonnull public static String LAYOUT
      The resource name for layout config ("layout").
    • DATASOURCE

      @Nonnull public static String DATASOURCE
      The resource name for datasource config ("datasource").
    • RENDERCONDITION

      @Nonnull public static String RENDERCONDITION
      The resource name for render condition config ("rendercondition").
  • Constructor Details

    • Config

      public Config(@CheckForNull Resource resource)
      Alias of Config(Resource, boolean) with inherit is false.
      Parameters:
      resource - The resource
    • Config

      public Config(@CheckForNull Resource resource, boolean inherit)
      Create a new Config object for the given resource. If inherit is true, the default properties are setup and taken from the parent's DEFAULTS sub-resource, and parent properties are used when calling getInherited(String, Class).
      Parameters:
      resource - The resource
      inherit - Whether to inherit default properties or not
      See Also:
    • Config

      public Config(@CheckForNull Resource resource, @CheckForNull ValueMap defaults, @CheckForNull ValueMap parentProperties)
      Create a new Config object for the given resource.
      Parameters:
      resource - The resource
      defaults - The default properties. Pass null if these are not required.
      parentProperties - The properties of the parent resource. Pass null if these are not required.
  • Method Details

    • get

      @Nonnull public String get(@Nonnull String name)
      Returns the value of property with the given name, converted to string. If the property does not exist it is taken from the defaults. Return an empty string if still not existing can't be converted.
      Parameters:
      name - the name of the property
      Returns:
      the value of property with the given name, converted to string
    • get

      @Nonnull public <T> T get(@Nonnull String name, @Nonnull T defaultValue)
      Returns the value of property with the given name, converted into the given type. If the property does not exist it is taken from the defaults. Return the given defaultValue if still non existing or can't be converted.
      Type Parameters:
      T - The type of the default value
      Parameters:
      name - The name of the property
      defaultValue - The default value to use if the named property does not exist or cannot be converted to the requested type. The default value is also used to define the type to convert the value to. If this is null any existing property is not converted.
      Returns:
      The value of property with the given name, converted into the given type
    • get

      @CheckForNull public <T> T get(@Nonnull String name, @Nonnull Class<T> type)
      Returns the value of property with the given name, converted into the given type. If the property does not exist, it is taken from the defaults. Return null if non existing or can't be converted.
      Type Parameters:
      T - The type of the submitted type param
      Parameters:
      name - The name of the property
      type - The type to convert the value of the given property name to
      Returns:
      The value of property with the given name, converted into the given type
    • getInherited

      @Nonnull public String getInherited(@Nonnull String name)
      Returns the value of property with the given name, converted to string. If the property does not exist, it is taken from the parent properties. Return an empty string if still not existing can't be converted.
      Parameters:
      name - The name of the property
      Returns:
      The value of property with the given name, converted to string.
      See Also:
    • getInherited

      @Nonnull public <T> T getInherited(@Nonnull String name, @Nonnull T defaultValue)
      Returns the value of property with the given name, converted into the given type. If the property does not exist, it is taken from the parent properties. Return the given defaultValue if still non existing or can't be converted.
      Type Parameters:
      T - The type to convert the value of the property to
      Parameters:
      name - The name of the property
      defaultValue - The default value to use if the named property does not exist or cannot be converted to the requested type. The default value is also used to define the type to convert the value to. If this is null any existing property is not converted.
      Returns:
      The value of property with the given name, converted into the given type
      See Also:
    • getInherited

      @CheckForNull public <T> T getInherited(@Nonnull String name, @Nonnull Class<T> type)
      Returns the value of property with the given name, converted into the given type. If the property does not exist, it is taken from the parent properties. Return null if non existing or can't be converted.
      Type Parameters:
      T - The type to convert the value of the property to
      Parameters:
      name - The name of the property
      type - The type to convert the value of the given property name to
      Returns:
      The value of property with the given name, converted into the given type
      See Also:
    • getInheritedDefault

      @Nonnull public String getInheritedDefault(@Nonnull String name)
      Alias of get(String).
      Parameters:
      name - The name of the property
      Returns:
      The value of property with the given name, converted to string
    • getInheritedDefault

      @Nonnull public <T> T getInheritedDefault(@Nonnull String name, @Nonnull T defaultValue)
      Type Parameters:
      T - The type to convert the value of the property to
      Parameters:
      name - The name of the property
      defaultValue - The default value to use if the named property does not exist or cannot be converted to the requested type. The default value is also used to define the type to convert the value to. If this is null any existing property is not converted.
      Returns:
      The value of property with the given name, converted to string
    • getInheritedDefault

      @CheckForNull public <T> T getInheritedDefault(@Nonnull String name, @Nonnull Class<T> type)
      Type Parameters:
      T - The type to convert the value of the property to
      Parameters:
      name - The name of the property
      type - The type to convert the value of the given property name to
      Returns:
      The value of property with the given name, converted to string
    • getDefaultProperties

      @Nonnull public ValueMap getDefaultProperties()
      Returns the default properties that will be applied to child elements. Be aware that these are not the defaults that are applied to the resource itself.
      Returns:
      The value map containing the default properties
    • getProperties

      @Nonnull public ValueMap getProperties()
      Returns the properties of the resource merged with the default properties.
      Returns:
      The value map containing the properties merged with the default properties.
    • getItems

      @Nonnull public Iterator<Resource> getItems()
      Returns the child resources of ITEMS sub-resource.
      Returns:
      The child resources of the specified ITEMS sub-resource
    • getItems

      @Nonnull public Iterator<Resource> getItems(@CheckForNull String name)
      Returns the child resources of the sub-resource with the given name.
      Parameters:
      name - The name of the resource
      Returns:
      The child resources of the sub-resource with the given name
    • getItems

      @Nonnull public Iterator<Resource> getItems(@CheckForNull Resource resource)
      Returns the child resources of ITEMS sub-resource of the given resource.
      Parameters:
      resource - The resource
      Returns:
      The child resources of the ITEMS sub-resource of the given resource
    • getItems

      @Nonnull public Iterator<Resource> getItems(@CheckForNull Resource resource, @CheckForNull String name)
      Returns the child resources of the sub resource with the given name of the given resource.
      Parameters:
      resource - The resource
      name - The name of the resource
      Returns:
      the child resources of the sub resource with the given name of the given resource.
    • getChild

      @CheckForNull public Resource getChild(@Nonnull String name)
      Returns the child resource with the given name.
      Parameters:
      name - The name of the resource
      Returns:
      The child resource
    • getParentResource

      @CheckForNull public Resource getParentResource()
      Returns the parent of the resource. If the parent is of type JcrConstants.NT_UNSTRUCTURED, then the parent is a container (e.g. "items"), then the container's parent is returned instead.
      Returns:
      The parent of the resource