Package com.adobe.granite.ui.components
Class Config
- java.lang.Object
-
- com.adobe.granite.ui.components.Config
-
public class Config extends Object
The config properties of a resource.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDATASOURCEThe resource name for datasource config ("datasource").static StringDEFAULTSThe resource name for the defaults config ("defaults").static StringITEMSThe resource name for items ("items").static StringLAYOUTThe resource name for layout config ("layout").static StringRENDERCONDITIONThe resource name for render condition config ("rendercondition").
-
Constructor Summary
Constructors Constructor Description Config(Resource resource)Alias ofConfig(Resource, boolean)with inherit isfalse.Config(Resource resource, boolean inherit)Create a new Config object for the given resource.Config(Resource resource, ValueMap defaults, ValueMap parentProperties)Create a new Config object for the given resource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringget(String name)Returns the value of property with the given name, converted to string.<T> Tget(String name, Class<T> type)Returns the value of property with the given name, converted into the given type.<T> Tget(String name, T defaultValue)Returns the value of property with the given name, converted into the given type.ResourcegetChild(String name)Returns the child resource with the given name.ValueMapgetDefaultProperties()Returns the default properties that will be applied to child elements.StringgetInherited(String name)Returns the value of property with the given name, converted to string.<T> TgetInherited(String name, Class<T> type)Returns the value of property with the given name, converted into the given type.<T> TgetInherited(String name, T defaultValue)Returns the value of property with the given name, converted into the given type.StringgetInheritedDefault(String name)Alias ofget(String).<T> TgetInheritedDefault(String name, Class<T> type)Alias ofget(String, Class).<T> TgetInheritedDefault(String name, T defaultValue)Alias ofget(String, Object);Iterator<Resource>getItems()Returns the child resources ofITEMSsub-resource.Iterator<Resource>getItems(String name)Returns the child resources of the sub-resource with the given name.Iterator<Resource>getItems(Resource resource)Returns the child resources ofITEMSsub-resource of the given resource.Iterator<Resource>getItems(Resource resource, String name)Returns the child resources of the sub resource with the given name of the given resource.ResourcegetParentResource()Returns the parent of the resource.ValueMapgetProperties()Returns the properties of the resource merged with the default properties.
-
-
-
Constructor Detail
-
Config
public Config(@CheckForNull Resource resource)
Alias ofConfig(Resource, boolean)with inherit isfalse.- Parameters:
resource- The resource
-
Config
public Config(@CheckForNull Resource resource, boolean inherit)
Create a new Config object for the given resource. Ifinheritistrue, the default properties are setup and taken from the parent'sDEFAULTSsub-resource, and parent properties are used when callinggetInherited(String, Class).- Parameters:
resource- The resourceinherit- Whether to inherit default properties or not- See Also:
getParentResource()
-
Config
public Config(@CheckForNull Resource resource, @CheckForNull ValueMap defaults, @CheckForNull ValueMap parentProperties)
Create a new Config object for the given resource.- Parameters:
resource- The resourcedefaults- The default properties. Passnullif these are not required.parentProperties- The properties of the parent resource. Passnullif these are not required.
-
-
Method Detail
-
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 propertydefaultValue- 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 isnullany 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. Returnnullif non existing or can't be converted.- Type Parameters:
T- The type of the submitted type param- Parameters:
name- The name of the propertytype- 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:
getParentResource()
-
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 propertydefaultValue- 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 isnullany existing property is not converted.- Returns:
- The value of property with the given name, converted into the given type
- See Also:
getParentResource()
-
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. Returnnullif 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 propertytype- 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:
getParentResource()
-
getInheritedDefault
@Nonnull public String getInheritedDefault(@Nonnull String name)
Alias ofget(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)
Alias ofget(String, Object);- Type Parameters:
T- The type to convert the value of the property to- Parameters:
name- The name of the propertydefaultValue- 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 isnullany 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)
Alias ofget(String, Class).- Type Parameters:
T- The type to convert the value of the property to- Parameters:
name- The name of the propertytype- 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 ofITEMSsub-resource.- Returns:
- The child resources of the specified
ITEMSsub-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 ofITEMSsub-resource of the given resource.- Parameters:
resource- The resource- Returns:
- The child resources of the
ITEMSsub-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:
name- The name of the resourceresource- 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 typeJcrConstants.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
-
-