Class RuntimeKey

java.lang.Object
com.aquima.interactions.composer.RuntimeKey
All Implemented Interfaces:
Serializable, Comparable<RuntimeKey>

public class RuntimeKey extends Object implements Serializable, Comparable<RuntimeKey>
A runtime key is a unique identifier of an element on a page. The key class provides a few utility methods to determine if elements are in the same scope.
Since:
5.0
Author:
O. Kerpershoek
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a runtime key from a string.
    RuntimeKey(String prefix, String id)
    Constructs the runtime key with a prefix and an ID.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    This method will compare this key to the other key, in such a way that base elements will be put before child elements.
    boolean
     
    This method will return the id without prefix of this key.
    This method will return the complete key-string containing both prefix and id.
    This method will return the prefix of this key without the id.
    int
     
    boolean
    This method will return a boolean indicating if this key is a child key of some other key.
    boolean
    This method will check if the key passed as argument is a parent of this key.
    boolean
    This method will return a boolean indicating if this key is a top level key (page-id).
    Creates a new runtime key for a child element.
    boolean
    This method will return true when this key shares the same scope as the key provided.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RuntimeKey

      public RuntimeKey(String key)
      Constructs a runtime key from a string. When the string contains key separator characters, the key-string will be split into a prefix and an id. When there are no separators present, the string will be considered a top level key.
      Parameters:
      key - String representation of the runtime key.
    • RuntimeKey

      public RuntimeKey(String prefix, String id)
      Constructs the runtime key with a prefix and an ID.
      Parameters:
      prefix - The prefix key string of the parent.
      id - The ID of the element the runtime key refers to.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • keyForChild

      public RuntimeKey keyForChild(String id)
      Creates a new runtime key for a child element. The prefix of the returned key will be identical to the key-string of the current runtime key.
      Parameters:
      id - The id, without prefix, of the child element.
      Returns:
      Runtime key for a child element of the current key.
    • isChildOf

      public boolean isChildOf(RuntimeKey key)
      This method will check if the key passed as argument is a parent of this key. This key is considered a child when the entire key-string of the key passed is part of our prefix.
      Parameters:
      key - The key for which should be checked if it is a parent of this key.
      Returns:
      boolean indicating if this key is a child of the key passed.
    • isRootKey

      public boolean isRootKey()
      This method will return a boolean indicating if this key is a top level key (page-id).
      Returns:
      boolean indicating if this key is a top level key.
    • isChildKey

      public boolean isChildKey()
      This method will return a boolean indicating if this key is a child key of some other key.
      Returns:
      boolean indicating if this key is a child key of some other key.
    • getId

      public String getId()
      This method will return the id without prefix of this key. The id of a runtime is only unique within the set of keys sharing the same prefix.
      Returns:
      The id of the key without prefix.
    • getPrefix

      public String getPrefix()
      This method will return the prefix of this key without the id. The prefix of this key is equal to the key-string of our direct parent.
      Returns:
      The prefix of this key.
    • getKeyString

      public String getKeyString()
      This method will return the complete key-string containing both prefix and id.
      Returns:
      the complete key-string containing both prefix and id.
    • sharesScope

      public boolean sharesScope(RuntimeKey other)
      This method will return true when this key shares the same scope as the key provided. The key is considered of the same scope when both keys are in the same container, or when one of the keys refers to an element that is in a container that is a direct parent of the other element.
      Parameters:
      other - The other runtime key with which the scope should be compared to.
      Returns:
      boolean indicating if the passed key shares the same scope as this key.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(RuntimeKey other)
      This method will compare this key to the other key, in such a way that base elements will be put before child elements.
      Specified by:
      compareTo in interface Comparable<RuntimeKey>
      Parameters:
      other - The RuntimeKey this instance should be compared to.
      Returns:
      integer containing the compare result.