/** * Creates an immutable copy of a {@link Value} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable Value instance */ public static ImmutableValue copyOf(Value instance) { if (instance instanceof ImmutableValue) { return (ImmutableValue) instance; } return ImmutableValue.builder() .from(instance) .build(); }