Skill#

One skill a Worker has, with its value. Use 0/1 for a skill a worker either has or doesn't, and an integer grade for a skill with levels. Create one with new Skill() and the withId / withValue setters, then put it in Worker.skills.

A SkillMatch compares this value when SkillLayer.slots picks candidates. A skill the worker doesn't list counts as 0 there.

Declaration#

package org.dhtmlx.plen;

public class Skill extends ValueRecord implements DeepCloneable<Skill>

Every field is public and mutable, and has a withX(value) setter that assigns it and returns this. equals, hashCode and toString come from ValueRecord and compare id and value.

Constructors#

Skill()#

public Skill()

Creates a skill with id = null and value = 1.0. Set id before use.

Fields#

Field Type Default Description
id Id null Skill id. Must be unique within one worker's skills.
value double 1.0 Skill value: 0/1 for a yes/no skill, an integer grade otherwise. Must be finite.
public Id id;
public double value;

public Skill withId(Id value)
public Skill withValue(double value)

SkillLayer.slots and SkillLayer.validatePool reject a duplicate id or a non-finite value with a MatchException.Invalid at pool.workers[i].skills[j].id or .value. See Errors.

Methods#

deepClone#

public Skill deepClone()

Returns a new skill with the same id and value.

copy#

public Skill copy()

Returns a shallow copy. A skill holds only an immutable Id and a double, so the result equals deepClone().

Example#

import java.util.List;
import org.dhtmlx.plen.*;

public class SkillExample {
    public static void main(String[] args) throws Exception {
        Worker bob = new Worker()
                .withResource(Id.str("bob"))
                .withSkills(List.of(
                        new Skill().withId(Id.str("backend")),           // has the skill (value = 1.0)
                        new Skill().withId(Id.str("qa")).withValue(2))); // QA grade 2

        System.out.println(bob);
    }
}