Class Immutables


  • public final class Immutables
    extends java.lang.Object
    An immutables utils.
    Author:
    jumperchen
    • Constructor Detail

      • Immutables

        public Immutables()
    • Method Detail

      • proxyIChildren

        public static java.util.List<? extends IComponent> proxyIChildren​(Component instance)
      • createComponents

        public static <T extends IComponent> java.util.List<T> createComponents​(PageDefinition pagedef,
                                                                                java.util.Map<?,​?> arg)
        Creates IComponents from Components 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 by Execution.getArg(). Ignored if null.
        Returns:
        the first component being created.
        Since:
        2.4.0
        See Also:
        createComponents(String, Map)
      • newReplacer

        public static <T extends IComponentIReplacer<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.