[Canonical page](<https://docs.dhtmlx.com/planning-engine/java/api/assign/pool/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# Pool

The workers that [`SkillLayer.slots`](<https://docs.dhtmlx.com/planning-engine/java/api/skill-layer-slots.md>) may put on tasks. Each worker is a project resource with its skills. Create one with `new Pool()`, fill it with `withWorkers(...)`, and pass it to `SkillLayer.slots` together with the requirements.

## Declaration

```java
public class Pool extends ValueRecord implements DeepCloneable<Pool>
```

## Constructors

### Pool()

```java
public Pool()
```

Creates an empty pool: `workers` is an empty `Vec`.

## Fields

| Field | Type | Default | Description |
|---|---|---|---|
| `workers` | [`Vec`](<https://docs.dhtmlx.com/planning-engine/java/api/support/vec.md>)`<`[`Worker`](<https://docs.dhtmlx.com/planning-engine/java/api/assign/worker.md>)`>` | empty | The workers, in preference order. |

### workers

```java
public Vec<Worker> workers = new Vec<Worker>();
```

The order is the preference order: a slot's `allowed` list keeps the workers in pool order, and that order breaks ties between equally scored candidates.

Each worker must name a resource of the project, and a resource can appear only once. [`SkillLayer.slots`](<https://docs.dhtmlx.com/planning-engine/java/api/skill-layer-slots.md>) and [`SkillLayer.validatePool`](<https://docs.dhtmlx.com/planning-engine/java/api/skill-layer-slots.md#skilllayervalidatepool>) check this and throw [`MatchException.Invalid`](<https://docs.dhtmlx.com/planning-engine/java/api/errors/match-exception.md>) with a `pool.workers[i]…` path; see [Errors](<https://docs.dhtmlx.com/planning-engine/java/api/skill-layer-slots.md#errors>).

## Methods

### withWorkers

```java
public Pool withWorkers(Vec<Worker> value)
public Pool withWorkers(java.util.Collection<? extends Worker> value)
```

Sets `workers` and returns this pool. 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

```java
public Pool deepClone()
```

Returns a deep copy. The `workers` list and every [`Worker`](<https://docs.dhtmlx.com/planning-engine/java/api/assign/worker.md>) in it are copied, so nothing is shared with the original.

### copy

```java
public Pool copy()
```

Returns a shallow copy. The copy holds the same `workers` list as the original.

### equals, hashCode, toString

Inherited from [`ValueRecord`](<https://docs.dhtmlx.com/planning-engine/java/api/support/value-record.md>). Two pools are equal when `workers` holds equal workers in the same order. `toString()` returns `Pool{workers=[…]}`.

## Example

Three workers. `ann` comes first, so she's preferred over `bob` when both fit a slot equally well.

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

public class PoolExample {
  public static void main(String[] args) throws Exception {
    Pool pool = new Pool().withWorkers(List.of(
        new Worker().withResource(Id.str("ann"))
            .withSkills(List.of(new Skill().withId(Id.str("backend")).withValue(3))),
        new Worker().withResource(Id.str("bob"))
            .withSkills(List.of(
                new Skill().withId(Id.str("backend")).withValue(2),
                new Skill().withId(Id.str("frontend")))),
        new Worker().withResource(Id.str("cid"))
            .withSkills(List.of(new Skill().withId(Id.str("frontend"))))));

    System.out.println(pool.workers.size()); // 3
  }
}
```

## Related

- [`Worker`](<https://docs.dhtmlx.com/planning-engine/java/api/assign/worker.md>) - one worker in the pool
- [`SkillLayer.slots`](<https://docs.dhtmlx.com/planning-engine/java/api/skill-layer-slots.md>) - the call that reads the pool
- [`Requirement`](<https://docs.dhtmlx.com/planning-engine/java/api/assign/requirement.md>) - what each task needs from the pool
- [`MatchException`](<https://docs.dhtmlx.com/planning-engine/java/api/errors/match-exception.md>) - thrown for an invalid pool
- [Skills and requirements](<https://docs.dhtmlx.com/planning-engine/java/resources-and-assignment/skills-and-requirements.md#pools-and-skills>) - building a pool of workers
