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