Id#
The id of a task, link, resource, assignment or calendar. An Id holds either a number or a string. Create one with Id.num or Id.str.
Two ids are equal when their key() values are equal, so Id.num(1) and Id.str("1") are the same id.
Declaration#
Id is immutable and has no public constructor.
Methods#
isNum#
public boolean
Returns true for a numeric id.
isStr#
public boolean
Returns true for a string id.
numValue#
public Double
Returns the number of a numeric id, or null for a string id.
strValue#
public String
Returns the text of a string id, or null for a numeric id.
key#
public String
Returns the id as text. A string id is returned as is. A number is printed the way JavaScript's String(n) prints it:
| Number | Key |
|---|---|
1 |
"1" |
1.5 |
"1.5" |
0 and -0 |
"0" |
1e21 |
"1e+21" |
1e-7 |
"1e-7" |
Double.NaN |
"NaN" |
equals, hashCode and toString all use this key.
Errors: throws IllegalStateException when the id is an infinite number.
norm#
public String
Same as key().
equals#
public boolean
Returns true when other is an Id with the same key: Id.num(1).equals(Id.str("1")) is true. String keys compare case-sensitively. Every NaN id equals every other NaN id. equals(null) and a non-Id argument return false.
A number beyond double precision is stored rounded, so Id.num(9007199254740993L) equals Id.str("9007199254740992").
Errors: throws IllegalStateException when the key of either id is needed and that id is an infinite number.
hashCode#
public int
Hash of the key, so equal ids hash the same and Id works as a HashMap or HashSet key.
Errors: throws IllegalStateException for an infinite number.
toString#
public String
Returns the key.
Static methods#
num#
public static Id
Creates a numeric id.
str#
public static Id
Creates a string id. The empty string is a valid id.
Errors: throws NullPointerException when s is null.
Validation#
An id in project data must be a finite number or a string. A NaN or infinite numeric id throws InputException with path "id" when the data is loaded.
Example#
;
;
Related#
TaskData- task ids and parentsSchedulingConfig.rootId- the id that means no parent- Ids - creating ids and key semantics
- Ids and dates - ids in project data