@Override public BlockNamespace setDittoHeaders(final DittoHeaders dittoHeaders) { return new BlockNamespace(getNamespace(), dittoHeaders); }
private void blockNamespace(final BlockNamespace command) { final String namespace = command.getNamespace(); final ActorRef sender = getSender(); final ActorRef self = getSelf(); blockedNamespaces.add(namespace) .thenAccept(_void -> { final BlockNamespaceResponse response = BlockNamespaceResponse.getInstance(namespace, command.getResourceType(), command.getDittoHeaders()); sender.tell(response, self); }) .exceptionally(error -> handleError(error, command, sender)); }
/** * Returns an instance of {@code BlockNamespace}. * * @param namespace the namespace to be blocked. * @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 BlockNamespace of(final CharSequence namespace, final DittoHeaders dittoHeaders) { return new BlockNamespace(namespace, dittoHeaders); }
/** * Creates a new {@code BlockNamespace} from a JSON object. * * @param jsonObject the JSON object of which the BlockNamespace 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 BlockNamespace fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { return new CommandJsonDeserializer<BlockNamespace>(TYPE, jsonObject).deserialize(() -> { final String namespace = jsonObject.getValueOrThrow(NamespaceCommand.JsonFields.NAMESPACE); return new BlockNamespace(namespace, dittoHeaders); }); }