Package org.zkoss.stateless.ui.util
Class Immutables
- java.lang.Object
-
- org.zkoss.stateless.ui.util.Immutables
-
public final class Immutables extends java.lang.Object
An immutables utils.- Author:
- jumperchen
-
-
Constructor Summary
Constructors Constructor Description Immutables()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends IComponent>
java.util.List<T>createComponents(java.lang.String uri, java.util.Map<?,?> arg)
CreatesIComponent
s fromComponent
s that don't belong to any page from a page file specified by an URI.static <T extends IComponent>
java.util.List<T>createComponents(PageDefinition pagedef, java.util.Map<?,?> arg)
CreatesIComponent
s fromComponent
s that don't belong to any page from the specified page definition.static <T extends IComponent>
java.util.List<T>createComponentsDirectly(java.lang.String content, java.lang.String extension, java.util.Map<?,?> arg)
CreatesIComponent
s fromComponent
s that don't belong to any page from the raw content specified by a string.static <T extends IComponent>
IReplacer<T>newReplacer(T root)
Constructs a replacer for replacing the descendant of the IComponent tree in a bulk execution for multiple replacements.static IComponent
proxyIChild(Component instance)
static IComponent
proxyIChild(Component instance, java.lang.Class<? extends Component> skipClass)
static java.util.List<? extends IComponent>
proxyIChildren(Component instance)
static <T extends Component,I extends IComponent>
IproxyIComponent(T t)
Makes a proxy ofComponent
intoIComponent
.static <R extends IComponent,T extends IComponent>
RreplaceDescendant(R root, T source, T target)
Replaces the descendant of the given root with the new child from the given source, if any.static <R extends IComponent,T extends IComponent>
RreplaceDescendantById(R root, java.lang.String sourceId, CheckedFunction<T,T> targetFunction)
Replaces the descendant of the given root with the new child from the given source, if any.static <R extends IComponent>
RreplaceDescendantById(R root, java.lang.String sourceId, IComponent<?> target)
Replaces the descendant of the given root with the new child from the given source, if any.
-
-
-
Method Detail
-
proxyIComponent
public static <T extends Component,I extends IComponent> I proxyIComponent(T t)
Makes a proxy ofComponent
intoIComponent
.- Parameters:
t
- a ZKComponent
- Returns:
- a proxy of
IComponent
-
proxyIChildren
public static java.util.List<? extends IComponent> proxyIChildren(Component instance)
-
proxyIChild
public static IComponent proxyIChild(Component instance)
-
proxyIChild
public static IComponent proxyIChild(Component instance, java.lang.Class<? extends Component> skipClass)
-
createComponents
public static <T extends IComponent> java.util.List<T> createComponents(PageDefinition pagedef, java.util.Map<?,?> arg)
CreatesIComponent
s fromComponent
s that don't belong to any page from the specified page definition.- Parameters:
pagedef
- the page definition to use. It cannot be null.arg
- a map of parameters that is accessible by the arg variable in EL, or byExecution.getArg()
. Ignored if null.- Returns:
- the first component being created.
- Since:
- 2.4.0
- See Also:
createComponents(String, Map)
-
createComponents
public static <T extends IComponent> java.util.List<T> createComponents(java.lang.String uri, java.util.Map<?,?> arg)
CreatesIComponent
s fromComponent
s that don't belong to any page from a page file specified by an URI.It loads the page definition from the specified URI (by use
Execution.getPageDefinition(java.lang.String)
), and then invokescreateComponents(PageDefinition,Map)
to create components.- Parameters:
arg
- a map of parameters that is accessible by the arg variable in EL, or byExecution.getArg()
. Ignored if null.- See Also:
createComponents(PageDefinition, Map)
-
createComponentsDirectly
public static <T extends IComponent> java.util.List<T> createComponentsDirectly(java.lang.String content, java.lang.String extension, java.util.Map<?,?> arg)
CreatesIComponent
s fromComponent
s that don't belong to any page from the raw content specified by a string.The raw content is parsed to a page definition by use of
Execution.getPageDefinitionDirectly(String, String)
, and then invokescreateComponents(PageDefinition,Map)
to create components.- Parameters:
content
- the raw content of the page. It must be in ZUML.extension
- the default extension if the content doesn't specify an language. In other words, if the content doesn't specify an language,LanguageDefinition.getByExtension(java.lang.String)
is called. If extension is null and the content doesn't specify a language, the language called "xul/html" is assumed.arg
- a map of parameters that is accessible by the arg variable in EL, or byExecution.getArg()
. Ignored if null.- See Also:
createComponents(PageDefinition, Map)
,createComponents(String, Map)
-
newReplacer
public static <T extends IComponent> IReplacer<T> newReplacer(T root)
Constructs a replacer for replacing the descendant of the IComponent tree in a bulk execution for multiple replacements. By default, the implementation uses BFS algorithm to traverse the whole tree to seek the replacement target.- Parameters:
root
- The root IComponent tree.- Returns:
- A replacer implementation of
IReplacer
-
replaceDescendant
public static <R extends IComponent,T extends IComponent> R replaceDescendant(R root, T source, T target)
Replaces the descendant of the given root with the new child from the given source, if any.- Parameters:
root
- The root IComponent tree.source
- The replaced source.target
- The replaced target.- Returns:
- The new IComponent tree.
-
replaceDescendantById
public static <R extends IComponent> R replaceDescendantById(R root, java.lang.String sourceId, IComponent<?> target)
Replaces the descendant of the given root with the new child from the given source, if any.- Parameters:
root
- The root IComponent tree.sourceId
- The id of the replaced source.target
- The replaced target.- Returns:
- The new IComponent tree.
-
replaceDescendantById
public static <R extends IComponent,T extends IComponent> R replaceDescendantById(R root, java.lang.String sourceId, CheckedFunction<T,T> targetFunction)
Replaces the descendant of the given root with the new child from the given source, if any.- Parameters:
root
- The root IComponent tree.sourceId
- The id of the replaced source.targetFunction
- The replacement function by passing the result of the source and returning the new replacement. If null, it means to remove the replaced source.- Returns:
- The new IComponent tree.
-
-