/** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the <em>Jackson</em>-binding infrastructure */ @Deprecated @JsonCreator(mode = JsonCreator.Mode.DELEGATING) static ImmutableContainer fromJson(Json json) { ImmutableContainer.Builder builder = ImmutableContainer.builder(); if (json.childs != null) { builder.addAllChilds(json.childs); } if (json.isSharedIsSet) { builder.isShared(json.isShared); } if (json.name != null) { builder.name(json.name); } if (json.description != null) { builder.description(json.description); } return builder.build(); }
/** * Creates an immutable copy of a {@link Container} 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 Container instance */ public static ImmutableContainer copyOf(Container instance) { if (instance instanceof ImmutableContainer) { return (ImmutableContainer) instance; } return ImmutableContainer.builder() .from(instance) .build(); }
/** * Build the container if the parameter is an ImmutableContainer.Builder or return directly the MutableContainer. */ public static IContainer toContainer(final Object current) { if (current instanceof ImmutableContainer.Builder) { return ((ImmutableContainer.Builder) current).build(); } else if (current instanceof ImmutableContainerForMulti.Builder) { return ((ImmutableContainerForMulti.Builder) current).build(); } return (IContainer) current; }