Package com.aquima.interactions.composer
Class RuntimeKey
java.lang.Object
com.aquima.interactions.composer.RuntimeKey
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionRuntimeKey
(String key) 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 TypeMethodDescriptionint
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.boolean
getId()
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
hashCode()
boolean
This method will return a boolean indicating if this key is a child key of some other key.boolean
isChildOf
(RuntimeKey key) 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).keyForChild
(String id) Creates a new runtime key for a child element.boolean
sharesScope
(RuntimeKey other) This method will return true when this key shares the same scope as the key provided.toString()
-
Constructor Details
-
RuntimeKey
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
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
-
keyForChild
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
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
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
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
This method will return the complete key-string containing both prefix and id.- Returns:
- the complete key-string containing both prefix and id.
-
hashCode
public int hashCode() -
equals
-
compareTo
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 interfaceComparable<RuntimeKey>
- Parameters:
other
- The RuntimeKey this instance should be compared to.- Returns:
- integer containing the compare result.
-