saker.build Documentation TaskDoc JavaDoc
public final class TaskName implements Comparable<TaskName>, Externalizable
Task representing a name that can be used to identify and locate tasks from external sources.

A task name consists of a lowercase name string and arbitrary amount of lowercase qualifiers.
Name parts are in the format matching the following regular expression:

 [a-z_0-9]+(\.[a-z_0-9]+)*
 
With plain words: A dot separated non-empty parts consisting of lowercase latin ABC characters, numbers or underscore. Qualifiers parts are in the format matching the following regular expression:
 [a-z0-9_.]+
 
With plain words: A non-empty string consisting of lowercase latin ABC characters, numbers, underscore or dot.

Qualifiers are stored in a sorted manner ordered by their natural order. Task names are comparable.

Each task name have an unique string representation in the following format:

 task.name[-qualifier]*
 
Examples:
 simple.task.name
 task.with.qualifier-q1
 multi.qualifiers-q1-q2-q3
 
Fields
public static final Pattern
A regular expression for matching valid task name representations.
Constructors
public
Methods
public int
Compares this task name to the parameter.
public boolean
Check if this task name equals the parameter.
public String
Gets the name for this task name.
public static <V> NavigableMap<TaskName, V>
Gets a submap for the argument that contains only the entries that have the same name as the parameter task name.
public NavigableSet<String>
Gets the qualifiers of this task name.
public boolean
Checks if the task name has any qualifiers defined for it.
public int
Returns a hash code value for the object.
public static boolean
Checks if the argument string is a valid qualifier for a task name.
public void
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.
public String
Converts this task name to a string representation.
public static TaskName
Converts the parameter string to a task name.
public static TaskName
valueOf(String name, Collection<String> qualifiers)
Converts the parameters to a task name.
public static TaskName
valueOf(String name, String... qualifiers)
Converts the parameters to a task name.
public TaskName
Gets a task name that has the same name as this, but has no qualifiers.
public void
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
public static final Pattern PATTERN_TASK_NAME
A regular expression for matching valid task name representations.

The name part is checked in a case-insensitive manner.

public int compareTo(TaskName o)
Compares this task name to the parameter.

Task names are ordered by name first, then each qualifier is compared to the corresponding parameter qualifiers at the same position.

Compares this object with the specified object for order.Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.

It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals."

In the foregoing description, the notation sgn(expression) designates the mathematical signum function, which is defined to return one of -1, 0, or 1 according to whether the value of expression is negative, zero or positive.

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
public boolean equals(Object obj)
Check if this task name equals the parameter.

Two task names equal if they have the same name and have the same qualifiers.

This method only returns true if compareTo(TaskName) returns 0.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

true if this object is the same as the obj argument; false otherwise.
public final String getName()
Gets the name for this task name.
The name.
Gets a submap for the argument that contains only the entries that have the same name as the parameter task name.

The result map is a submap that only contains entries for which the name equal to the name of the argument name.

mapThe map.
tasknameThe task name to filter the entries for.
The submap.
NullPointerExceptionIf any of the arguments are null.
Gets the qualifiers of this task name.
The qualifiers. (unmodifiable)
public boolean hasAnyQualifiers()
Checks if the task name has any qualifiers defined for it.
true if there are at least one qualifier.
public int hashCode()
Overridden from: Object
Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the Object.equals(Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)

a hash code value for this object.
public static boolean isValidQualifier(String qualifier)
Checks if the argument string is a valid qualifier for a task name.
qualifierThe qualifier to check.
true if the qualifier has a valid format described by this class.
Overridden from: Externalizable
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
inthe stream to read data from in order to restore the object
IOExceptionif I/O errors occur
ClassNotFoundExceptionIf the class for an object being restored cannot be found.
public String toString()
Converts this task name to a string representation.

The return value passed to valueOf(String) will be equal to this.

See TaskName documentation for the resulting format.

The task name converted to a string.
Converts the parameter string to a task name.

See TaskName documentation for the expected format. The input will be converted to lowercase.

Multiple consecutive '-' will be collapsed, empty qualifiers will not be included.

inputThe input string.
The parsed task name.
NullPointerExceptionIf the argument is null.
IllegalArgumentExceptionIf the input does not match the task name format.
Converts the parameters to a task name.

The input will be converted to lowercase.

The parameters are checked if they match the expected format.

nameThe name of the task.
qualifiersThe qualifiers of the task. Duplicates will be removed.
The parsed task name.
NullPointerExceptionIf the argument is null.
IllegalArgumentExceptionIf the input does not match the task name format.
public static TaskName valueOf(String name, String... qualifiers) throws IllegalArgumentException
Converts the parameters to a task name.

The input will be converted to lowercase.

The parameters are checked if they match the expected format.

nameThe name of the task.
qualifiersThe qualifiers of the task. Duplicates will be removed.
The parsed task name.
IllegalArgumentExceptionIf the input does not match the task name format.
Gets a task name that has the same name as this, but has no qualifiers.

If this task name already has no qualifiers, it is simply returned.

The task name without qualifiers.
public void writeExternal(ObjectOutput out) throws IOException
Overridden from: Externalizable
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
outthe stream to write the object to
IOExceptionIncludes any I/O exceptions that may occur