Package com.adobe.granite.ui.components
Class LayoutBuilder
java.lang.Object
com.adobe.granite.ui.components.LayoutBuilder
A builder to create a layout. A layout is a configuration map consisting a
set of properties. A layout at very least requires a
name property.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given key-value pair of property to this layout.voidAdds a map of properties to this layout.static LayoutBuilderBuilds a layout from the given config.static LayoutBuilderBuilds a layout from the given config.static LayoutBuilderBuilds a layout from the given resource.static LayoutBuilderBuilds a layout from the given resource.getName()Returns the name of this layout.Returns the resource type of this layout.booleanhasName()trueif this layout has name.voidSets the name of this layout.voidsetResourceType(String resourceType) Sets the resource type of this layout.toJSON()Returns this layout as JSON.
-
Constructor Details
-
LayoutBuilder
public LayoutBuilder() -
LayoutBuilder
-
-
Method Details
-
from
Builds a layout from the given config. The actual layout resource is retrieved based onConfig.LAYOUTpath. This method doesn't set default resource type of layout, usefrom(Config, String)orComponentHelper.getLayout()instead.- Parameters:
config- the config- Returns:
- the layout builder
-
from
@Nonnull public static LayoutBuilder from(@Nonnull Config config, @Nonnull String defaultResourceType) Builds a layout from the given config. The actual layout resource is retrieved based onConfig.LAYOUTpath. The given defaultResourceType will be used when sling:resourceType property of the resource is not set.- Parameters:
config- the configdefaultResourceType- the default resource type- Returns:
- the layout builder
-
from
Builds a layout from the given resource. This method doesn't set default resource type of layout, usefrom(Resource, String)orComponentHelper.getLayout()instead.- Parameters:
resource- the resource- Returns:
- the layout builder
-
from
@Nonnull public static LayoutBuilder from(@CheckForNull Resource resource, @CheckForNull String defaultResourceType) Builds a layout from the given resource. The given defaultResourceType will be used when sling:resourceType property of the resource is not set.- Parameters:
resource- the resourcedefaultResourceType- the default resource type- Returns:
- the layout builder
-
hasName
public boolean hasName()trueif this layout has name.falseotherwise.- Returns:
trueif this layout has a name,falseotherwise
-
getName
Returns the name of this layout.- Returns:
- returns the name of this layout
-
setName
Sets the name of this layout.- Parameters:
name- the name to set
-
getResourceType
Returns the resource type of this layout. This will be used to point to the renderer of the layout using standard Sling mechanism.- Returns:
- the resource type as a string
-
setResourceType
Sets the resource type of this layout.- Parameters:
resourceType- the resource type to set
-
add
Adds the given key-value pair of property to this layout.- Parameters:
key- the property keyvalue- the property value
-
add
Adds a map of properties to this layout. Entry with key having a namespace (e.g. jcr:primaryType) will be excluded.- Parameters:
data- the map of properties to add
-
toJSON
Returns this layout as JSON.- Returns:
- the layout as JSON
-