Class TargetStackUtil


  • public class TargetStackUtil
    extends Object

    Utility method for manipulating GlimpseTargetStack instances.

    In order to uniquely name a GlimpseLayout, the stack containing the GlimpseLayout and all of its parent layouts down to the underlying GlimpseCanvas must be provided (because the GlimpseLayout may be reused and could have multiple parents).

    Author:
    ulman
    • Constructor Detail

      • TargetStackUtil

        public TargetStackUtil()
    • Method Detail

      • newTargetStack

        public static GlimpseTargetStack newTargetStack​(GlimpseTargetStack stack)
        Creates a new GlimpseTargetStack which is an exact copy of the given stack.
        Parameters:
        stack - the stack to copy
        Returns:
        a deep copy of the provided stack
      • newUnmodifiableTargetStack

        public static GlimpseTargetStack newUnmodifiableTargetStack​(GlimpseTargetStack stack)
        Creates a new GlimpseTargetStack which is an exact copy of the given stack and is unmodifiable.
        Parameters:
        stack - the stack to copy
        Returns:
        a deep copy of the provided stack
      • newTargetStack

        public static GlimpseTargetStack newTargetStack​(GlimpseTarget... targets)
        Creates a new target stack which is the concatenation of the provided GlimpseTargets. The first provided GlimpseTarget is placed at the bottom of the new GlimpseTargetStack.
        Parameters:
        targets - the GlimpseTargets to concatenate
        Returns:
        the newly constructed GlimpseTargetStack
      • endsWith

        public static boolean endsWith​(GlimpseTargetStack query,
                                       GlimpseTargetStack suffix)
        Returns true if the query stack ends with the sequence of GlimpseTargets defined by the prefix stack. Ignores the GlimpseBounds.
        Parameters:
        query - the GlimpseTargetStack to investigate
        suffix - a GlimpseTargetStack to search for at the end of the query stack
        Returns:
        whether the query stack ends with the GlimpseTargets in the prefix stack
      • contains

        public static boolean contains​(GlimpseTargetStack query,
                                       GlimpseTarget target)
        Returns true if the query target stack contains the provided target.
        Parameters:
        query - the GlimpseTargetStack to investigate
        target - the GlimpseTarget to look for in the query stack
        Returns:
        true if the query stack contains the target
      • startsWith

        public static boolean startsWith​(GlimpseTargetStack query,
                                         GlimpseTargetStack prefix)
        Returns true if the query stack starts with the sequence of GlimpseTargets defined by the prefix stack. Ignores the GlimpseBounds.
        Parameters:
        query - the GlimpseTargetStack to investigate
        prefix - a GlimpseTargetStack to search for at the start of the query stack
        Returns:
        whether the query stack starts with the GlimpseTargets in the prefix stack