/** * Constructs a new {@code AbstractErrorRegistry} for the specified {@code parseStrategies}. * * @param parseStrategies the parse strategies. * @param fallbackErrorRegistry the {@link ErrorRegistry} to be used as fallback * @throws NullPointerException if any argument is {@code null}. */ protected AbstractErrorRegistry(final Map<String, JsonParsable<T>> parseStrategies, final ErrorRegistry<T> fallbackErrorRegistry) { super(mergeParseRegistries(parseStrategies, fallbackErrorRegistry)); }
@Override protected JsonTypeNotParsableException doBuild(final DittoHeaders dittoHeaders, final String message, final String description, final Throwable cause, final URI href) { return new JsonTypeNotParsableException(dittoHeaders, message, description, cause, href); } }
/** * Returns the entity as JSON. * * @return the entity as JSON. */ default Optional<JsonValue> getEntity() { return getEntity(JsonSchemaVersion.LATEST); }
private static ShardedMessageEnvelope createEnvelope(final EntityId entityId, final Signal<?> signal) { return ShardedMessageEnvelope.of( entityId.toString(), signal.getType(), signal.toJson(signal.getImplementedSchemaVersion(), FieldType.regularOrSpecial()), signal.getDittoHeaders()); } }
@Override public String entityId(final Object message) { if (message instanceof ShardedMessageEnvelope) { return ((ShardedMessageEnvelope) message).getId(); } else if (message instanceof WithId) { return ((WithId) message).getId(); } else if (message instanceof ShardRegion.StartEntity) { return ((ShardRegion.StartEntity) message).entityId(); } return null; }
@Override public ShardedMessageEnvelope setDittoHeaders(final DittoHeaders dittoHeaders) { return of(id, type, message, dittoHeaders); }
/** * A mutable builder for a {@code JsonTypeNotParsableException}. * * @param type the not supported type. * @param registryName the name of the registry which did not support the type. * @return the builder. */ public static Builder newBuilder(final String type, final String registryName) { return new Builder(type, registryName); }
private String getMessageThingId(final WithThingId withThingId) { return withThingId.getThingId(); }
private Builder() { description(DEFAULT_DESCRIPTION); }
/** * Returns a new {@code ShardedMessageEnvelope} for the specified {@code id} and {@code message}. * * @param id the identifier. * @param type the type of the message. * @param message the message. * @param dittoHeaders the command headers. * @return the ShardedMessageEnvelope. */ public static ShardedMessageEnvelope of(final String id, final String type, final JsonObject message, final DittoHeaders dittoHeaders) { return new ShardedMessageEnvelope(id, type, message, dittoHeaders); }
private static DateTimeFormatter caseInsensitiveAnd(final DateTimeFormatter... formatters) { return new DateTimeFormatterBuilder() .parseCaseInsensitive() .append(and(formatters)) .toFormatter(); }
@Override public String entityId(final Object message) { if (message instanceof ShardedMessageEnvelope) { return ((ShardedMessageEnvelope) message).getId(); } else if (message instanceof WithId) { return ((WithId) message).getId(); } else if (message instanceof ShardRegion.StartEntity) { return ((ShardRegion.StartEntity) message).entityId(); } return null; }
/** * Returns the entity as JSON. * * @return the entity as JSON. */ default Optional<JsonValue> getEntity() { return getEntity(JsonSchemaVersion.LATEST); }
@Override public ShardedMessageEnvelope setDittoHeaders(final DittoHeaders dittoHeaders) { return of(id, type, message, dittoHeaders); }
/** * Constructs a new {@code AbstractErrorRegistry} for the specified {@code parseStrategies}. * * @param parseStrategies the parse strategies. * @param fallbackErrorRegistry the {@link ErrorRegistry} to be used as fallback * @throws NullPointerException if any argument is {@code null}. */ protected AbstractErrorRegistry(final Map<String, JsonParsable<T>> parseStrategies, final ErrorRegistry<T> fallbackErrorRegistry) { super(mergeParseRegistries(parseStrategies, fallbackErrorRegistry)); }
@Override protected JsonTypeNotParsableException doBuild(final DittoHeaders dittoHeaders, final String message, final String description, final Throwable cause, final URI href) { return new JsonTypeNotParsableException(dittoHeaders, message, description, cause, href); } }
/** * A mutable builder for a {@code JsonTypeNotParsableException}. * * @param type the not supported type. * @param registryName the name of the registry which did not support the type. * @return the builder. */ public static Builder newBuilder(final String type, final String registryName) { return new Builder(type, registryName); }
private String getMessageThingId(final WithThingId withThingId) { return withThingId.getThingId(); }
private Builder() { description(DEFAULT_DESCRIPTION); }
/** * Returns a new {@code ShardedMessageEnvelope} for the specified {@code id} and {@code message}. * * @param id the identifier. * @param type the type of the message. * @param message the message. * @param dittoHeaders the command headers. * @return the ShardedMessageEnvelope. */ public static ShardedMessageEnvelope of(final String id, final String type, final JsonObject message, final DittoHeaders dittoHeaders) { return new ShardedMessageEnvelope(id, type, message, dittoHeaders); }