public class LayoutBuilder extends Object
name property.| Constructor and Description |
|---|
LayoutBuilder() |
LayoutBuilder(Resource resource) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Map<String,Object> data)
Adds a map of properties to this layout.
|
void |
add(String key,
Object value)
Adds the given key-value pair of property to this layout.
|
static LayoutBuilder |
from(Config config)
Builds a layout from the given config.
|
static LayoutBuilder |
from(Config config,
String defaultResourceType)
Builds a layout from the given config.
|
static LayoutBuilder |
from(Resource resource)
Builds a layout from the given resource.
|
static LayoutBuilder |
from(Resource resource,
String defaultResourceType)
Builds a layout from the given resource.
|
String |
getName()
Returns the name of this layout.
|
String |
getResourceType()
Returns the resource type of this layout.
|
boolean |
hasName()
true if this layout has name. |
void |
setName(String name)
Sets the name of this layout.
|
void |
setResourceType(String resourceType)
Sets the resource type of this layout.
|
JSONObject |
toJSON()
Returns this layout as JSON.
|
public LayoutBuilder()
public LayoutBuilder(@CheckForNull Resource resource)
@Nonnull public static LayoutBuilder from(@Nonnull Config config)
Config.LAYOUT path. This method doesn't set
default resource type of layout, use from(Config, String) or
ComponentHelper.getLayout() instead.config - the config@Nonnull public static LayoutBuilder from(@Nonnull Config config, @Nonnull String defaultResourceType)
Config.LAYOUT path. The given defaultResourceType
will be used when sling:resourceType property of the resource is not set.config - the configdefaultResourceType - the default resource type@Nonnull public static LayoutBuilder from(@CheckForNull Resource resource)
from(Resource, String) or
ComponentHelper.getLayout() instead.resource - the resource@Nonnull public static LayoutBuilder from(@CheckForNull Resource resource, @CheckForNull String defaultResourceType)
resource - the resourcedefaultResourceType - the default resource typepublic boolean hasName()
true if this layout has name. false otherwise.true if this layout has a name, false otherwise@CheckForNull public String getName()
public void setName(@CheckForNull String name)
name - the name to set@CheckForNull public String getResourceType()
public void setResourceType(@CheckForNull String resourceType)
resourceType - the resource type to setpublic void add(@Nonnull String key, @CheckForNull Object value)
key - the property keyvalue - the property valuepublic void add(@Nonnull Map<String,Object> data)
data - the map of properties to add@Nonnull public JSONObject toJSON()
Copyright © 2010 - 2020 Adobe. All Rights Reserved