/** * Returns an instance of {@code PurgeNamespace}. * * @param namespace the namespace to be purged. * @param dittoHeaders the headers of the command. * @return the instance. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code namespace} is empty. */ public static PurgeNamespace of(final CharSequence namespace, final DittoHeaders dittoHeaders) { return new PurgeNamespace(namespace, dittoHeaders); }
@Override public PurgeNamespace setDittoHeaders(final DittoHeaders dittoHeaders) { if (Objects.equals(getDittoHeaders(), dittoHeaders)) { return this; } return new PurgeNamespace(getNamespace(), dittoHeaders); }
/** * Creates a new {@code PurgeNamespace} from a JSON object. * * @param jsonObject the JSON object of which the PurgeNamespace is to be created. * @param dittoHeaders the headers. * @return the command. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonMissingFieldException if {@code jsonObject} did not contain * {@link org.eclipse.ditto.signals.commands.namespaces.NamespaceCommand.JsonFields#NAMESPACE}. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} was not in the expected * format. */ public static PurgeNamespace fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<PurgeNamespace>(TYPE, jsonObject).deserialize(() -> { final String namespace = jsonObject.getValueOrThrow(NamespaceCommand.JsonFields.NAMESPACE); return new PurgeNamespace(namespace, dittoHeaders); }); }