Worker#
A project resource that can be assigned, together with its skill values. Workers go into Pool.workers, which SkillLayer.slots reads. Create one with new Worker() and the fluent withX setters.
Declaration#
Constructors#
Worker()#
public
Creates a worker with resource set to null and an empty skills list. Set resource before passing the worker on.
Fields#
| Field | Type | Default | Description |
|---|---|---|---|
resource |
Id |
null |
Id of a resource in the project's accepted state. Required. When the worker satisfies a requirement, this id goes into the slot's allowed list. |
skills |
Vec<Skill> |
empty | The worker's skill values, one Skill per skill id. For how a skill missing from the list compares, see SkillMatch. |
resource must name a resource of the project and appear only once in the pool. Skill ids must be unique within skills, and each value must be finite. SkillLayer.slots and SkillLayer.validatePool check this and throw MatchException.Invalid at pool.workers[i].resource, pool.workers[i].skills[j].id or pool.workers[i].skills[j].value. See Errors.
Methods#
withResource#
public Worker
Sets resource and returns this worker.
withSkills#
public Worker
public Worker
Sets skills and returns this worker. The Vec overload stores the given list itself. The Collection overload copies the elements into a new Vec, so List.of(...) works; null sets the field to null.
deepClone#
public Worker
Returns a deep copy. The skills list and every Skill in it are copied, so nothing is shared with the original. resource is an immutable Id and is shared.
copy#
public Worker
Returns a shallow copy. The copy holds the same skills list as the original.
equals, hashCode, toString#
Inherited from ValueRecord. Two workers are equal when resource is equal and skills holds equal skills in the same order. toString() lists the fields, as in Worker{resource=ann, skills=[…]}.
Example#
;
;
Related#
Pool- the list of workersSkill- one skill value of a workerSkillLayer.slots- the call that reads the workersMatchException- thrown for an invalid worker- Skills and requirements - building a pool of workers