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


# ValueRecord

The base class of the record types in `org.dhtmlx.plen`: input data, options, change sets and results. It adds a shallow `copy()` and replaces `equals`, `hashCode` and `toString` with versions that read the record's public fields. Application code doesn't create a `ValueRecord` directly. It meets the class through subclasses such as [`TaskData`](<https://docs.dhtmlx.com/planning-engine/java/api/data/task-data.md>), [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/java/api/project/solve-options.md>) or [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/java/api/results/schedule-result.md>).

## Declaration

```java
package org.dhtmlx.plen;

public class ValueRecord implements Cloneable
```

Every member below reads the **public instance fields** of the runtime class, inherited ones included. Static, private, protected and package-private fields are ignored. A subclass can override any of these methods, and its own page says so when it does.

## Methods

### copy

```java
public ValueRecord copy()
```

Returns a shallow copy made with `Object.clone()`. Field values are copied as they are, so the copy and the original share lists ([`Vec`](<https://docs.dhtmlx.com/planning-engine/java/api/support/vec.md>)), maps and nested records. Most subclasses override `copy()` with their own return type (`TaskData copy()`), so no cast is needed. For a copy that shares nothing mutable, use `deepClone()` from [`DeepCloneable<T>`](<https://docs.dhtmlx.com/planning-engine/java/api/data/deep-cloneable.md>).

**Returns** - a new instance of the same runtime class.

### equals

```java
@Override
public boolean equals(Object other)
```

Structural equality. Returns `true` when `other` is the same object, or when it has exactly the same runtime class and every public field is equal by `Objects.deepEquals`. An instance of a subclass is never equal to an instance of its parent class.

Field values compare as follows:

| Field value | Compared by |
|---|---|
| `null` | equal only to `null` |
| `double`, `Double` | `Double.equals`: `-0.0` and `0.0` differ, `NaN` equals `NaN` |
| `Vec`, other lists | the list's `equals`: same size, same elements in the same order |
| nested record | its own `equals`, recursively |
| array | element by element (`Arrays.deepEquals`) |
| anything else | the value's `equals` |

**Returns** - `true` if the records are equal.

### hashCode

```java
@Override
public int hashCode()
```

A hash over the same public fields, consistent with `equals`: equal records have equal hash codes.

Records are mutable, so the hash code changes when a field changes. Don't modify a record while it's a key in a `HashMap` or an element of a `HashSet`.

**Returns** - the hash code.

### toString

```java
@Override
public String toString()
```

Returns the simple class name followed by every public field as `name=value`, for example `Pause{at=2.0, length=1.0, by=null}`. Each value is formatted with `String.valueOf`, so nested records and lists print recursively. Field order follows `Class.getFields()`, which the JVM doesn't guarantee. Use the string for logs and debugging only; it isn't a serialization format.

**Returns** - the text form of the record.

## Example

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

public class ValueRecordExample {
    public static void main(String[] args) throws Exception {
        Pause a = new Pause(2.0, 1.0);
        Pause b = a.copy();

        System.out.println(a.equals(b));                  // true
        System.out.println(a.hashCode() == b.hashCode()); // true

        b.withLength(3.0);
        System.out.println(a.equals(b));                  // false
        System.out.println(b);                            // Pause{at=2.0, length=3.0, by=null}

        System.out.println(new Pause(0.0, 1.0).equals(new Pause(-0.0, 1.0))); // false
    }
}
```

## Related

- [`DeepCloneable<T>`](<https://docs.dhtmlx.com/planning-engine/java/api/data/deep-cloneable.md>) - the deep copy most records add
- [`Vec`](<https://docs.dhtmlx.com/planning-engine/java/api/support/vec.md>) - the list type of record fields
- [Records, ids and dates](<https://docs.dhtmlx.com/planning-engine/java/records-ids-and-dates.md#building-records>) - building records and copying them
