use of com.google.protobuf.Any in project core-java by SpineEventEngine.
the class MessageMismatch method unpackActual.
/**
* Obtains actual value as a {@code Message} from the passed mismatch.
*
* @throws RuntimeException if the passed instance represent a mismatch of
* non-{@code Message} values
*/
public static Message unpackActual(ValueMismatch mismatch) {
checkNotNull(mismatch);
final Any any = mismatch.getActual();
final Message result = unpack(any);
return result;
}
use of com.google.protobuf.Any in project core-java by SpineEventEngine.
the class MessageMismatch method unpackExpected.
/**
* Obtains expected value as a {@code Message} from the passed mismatch.
*
* @throws RuntimeException if the passed instance represent a mismatch of
* non-{@code Message} values
*/
public static Message unpackExpected(ValueMismatch mismatch) {
checkNotNull(mismatch);
final Any any = mismatch.getExpected();
final Message result = unpack(any);
return result;
}
use of com.google.protobuf.Any in project core-java by SpineEventEngine.
the class StringMismatch method unpackExpected.
/**
* Obtains expected string from the passed mismatch.
*
* @throws RuntimeException if the passed instance represent a mismatch of non-string values
*/
public static String unpackExpected(ValueMismatch mismatch) {
checkNotNull(mismatch);
final Any expected = mismatch.getExpected();
return unpacked(expected);
}
use of com.google.protobuf.Any in project core-java by SpineEventEngine.
the class Rejections method createRejection.
/**
* Creates a new {@code Rejection} instance.
*
* @param messageOrAny the rejection message or {@code Any} containing the message
* @param command the {@code Command}, which triggered the rejection.
* @return created rejection instance
*/
public static Rejection createRejection(Message messageOrAny, Command command) {
checkNotNull(messageOrAny);
checkNotNull(command);
final Any packedMessage = pack(messageOrAny);
final RejectionContext context = RejectionContext.newBuilder().setCommand(command).build();
final Rejection result = Rejection.newBuilder().setMessage(packedMessage).setContext(context).build();
return result;
}
use of com.google.protobuf.Any in project core-java by SpineEventEngine.
the class Rejections method toRejection.
/**
* Converts this {@code ThrowableMessage} into {@link Rejection}.
*
* @param command the command which caused the rejection
*/
public static Rejection toRejection(ThrowableMessage throwable, Command command) {
checkNotNull(throwable);
checkNotNull(command);
final Message rejectionMessage = throwable.getMessageThrown();
final Any packedState = pack(rejectionMessage);
final RejectionContext context = createContext(throwable, command);
final RejectionId id = generateId(command.getId());
final Rejection.Builder builder = Rejection.newBuilder().setId(id).setMessage(packedState).setContext(context);
return builder.build();
}
Aggregations