Table of Contents

Java Concurrency - Immutable Object

About

Immutable object in Java Concurrency.

Rules

Library

List<Table> allTables = ImmutableList.copyOf(Table.values());
final String value1;
final Boolean blue;

private Session(String value1, boolean isBlue)
{
   this.value1 = value1;
   this.isBlue = isBlue;
}

public Session withBlue(boolean isBlue)
{
  return new Session(
          this.value1,
          this.isBlue
  );
}

Collections

since Java10, Create new collection instances from existing instances

Stream

Stream New methods toUnmodifiableList, toUnmodifiableSet, and toUnmodifiableMap have been added to the Collectors class in the Stream package.

Documentation / Reference

See Java Tuto - Immutable