Class EventCode<T extends EventCode<T>>
- Type Parameters:
T
-
- All Implemented Interfaces:
Serializable
,Comparable<T>
- Direct Known Subclasses:
SignalCode
public abstract class EventCode<T extends EventCode<T>>
extends SimpleValueObject<String>
implements Comparable<T>
A common base class for representing codes divided by colons (:).
Example:user:created
- Since:
- 6.1.0
- See Also:
- API:
- This is a public API.
-
Method Summary
Modifier and TypeMethodDescriptionAppend the given part to the codeAppend the given part to the codeint
Counts the parts of a code.getPart
(int pos) Gets a part of the code.long
getPartAsNumber
(int pos) Gets a part of the code as numberboolean
isEmpty()
Methods inherited from class ch.ivyteam.ivy.model.SimpleValueObject
equals, hashCode, toString
-
Method Details
-
isEmpty
public boolean isEmpty()- Returns:
true
if code is empty- API:
- This public API is available in Java.
-
append
Append the given part to the code- Parameters:
part
-- Returns:
- the newly created code
- API:
- This public API is available in Java.
-
append
Append the given part to the code- Parameters:
part
-- Returns:
- the newly created code
- API:
- This public API is available in Java.
-
countParts
public int countParts()Counts the parts of a code.
Example:
import ch.ivyteam.ivy.process.model.value.SignalCode; Number count = new SignalCode("user:created:33").countParts(); // count is 3
- Returns:
- the number of parts
- API:
- This public API is available in Java.
-
getPart
Gets a part of the code.
Example:
import ch.ivyteam.ivy.process.model.value.SignalCode; String part = new SignalCode("user:created").getPart(1); // part is "created"
- Parameters:
pos
- The position of the part that is requested. Counting starts with 0.- Returns:
- The requested part
- Throws:
IllegalArgumentException
- if position is not in range- API:
- This public API is available in Java.
-
getPartAsNumber
public long getPartAsNumber(int pos) Gets a part of the code as number
Example:
import ch.ivyteam.ivy.process.model.value.SignalCode; Number num = new SignalCode("signal:code:42").getPartAsNumber(2); // num is 42
- Parameters:
pos
- The position of the part that is requested. Counting starts with 0.- Returns:
- The requested part as number
- Throws:
IllegalArgumentException
- if position is not in rangeNumberFormatException
- if part cannot be converted to number- API:
- This public API is available in Java.
-