public class LayoutBuilder
extends java.lang.Object
name
property.Constructor and Description |
---|
LayoutBuilder() |
LayoutBuilder(Resource resource) |
Modifier and Type | Method and Description |
---|---|
void |
add(java.util.Map<java.lang.String,java.lang.Object> data)
Adds a map of properties to this layout.
|
void |
add(java.lang.String key,
java.lang.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,
java.lang.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,
java.lang.String defaultResourceType)
Builds a layout from the given resource.
|
java.lang.String |
getName()
Returns the name of this layout.
|
java.lang.String |
getResourceType()
Returns the resource type of this layout.
|
boolean |
hasName()
true if this layout has name. |
void |
setName(java.lang.String name)
Sets the name of this layout.
|
void |
setResourceType(java.lang.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 java.lang.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 java.lang.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 java.lang.String getName()
public void setName(@CheckForNull java.lang.String name)
name
- the name to set@CheckForNull public java.lang.String getResourceType()
public void setResourceType(@CheckForNull java.lang.String resourceType)
resourceType
- the resource type to setpublic void add(@Nonnull java.lang.String key, @CheckForNull java.lang.Object value)
key
- the property keyvalue
- the property valuepublic void add(@Nonnull java.util.Map<java.lang.String,java.lang.Object> data)
data
- the map of properties to add@Nonnull public JSONObject toJSON()
Copyright © 2010 - 2020 Adobe. All Rights Reserved