/** * Creates an immutable copy of a {@link Session} 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 Session instance */ public static ImmutableSession copyOf(Session instance) { if (instance instanceof ImmutableSession) { return (ImmutableSession) instance; } return ImmutableSession.builder() .from(instance) .build(); }