Search in sources :

Example 46 with TypeUrl

use of io.spine.type.TypeUrl in project core-java by SpineEventEngine.

the class Queries method typeOf.

/**
 * Extract the type of {@link Target} for the given {@link Query}.
 *
 * <p>Throws an {@link IllegalStateException} if the {@code Target} type is unknown to
 * the application.
 *
 * @param query the query of interest.
 * @return the URL of the type of the query {@linkplain Query#getTarget() target}
 */
public static TypeUrl typeOf(Query query) {
    checkNotNull(query);
    final Target target = query.getTarget();
    final String type = target.getType();
    final TypeUrl typeUrl = TypeUrl.parse(type);
    checkState(getAllUrls().contains(typeUrl), "Unknown type URL: `%s`.", type);
    return typeUrl;
}
Also used : Targets.composeTarget(io.spine.client.Targets.composeTarget) TypeUrl(io.spine.type.TypeUrl)

Aggregations

TypeUrl (io.spine.type.TypeUrl)46 Test (org.junit.Test)15 Any (com.google.protobuf.Any)14 EntityRecord (io.spine.server.entity.EntityRecord)8 Message (com.google.protobuf.Message)7 BoundedContext (io.spine.server.BoundedContext)5 EntityRecordWithColumns (io.spine.server.entity.storage.EntityRecordWithColumns)3 ClassName (io.spine.type.ClassName)3 Descriptors (com.google.protobuf.Descriptors)2 StringValue (com.google.protobuf.StringValue)2 Error (io.spine.base.Error)2 Query (io.spine.client.Query)2 Ack (io.spine.core.Ack)2 Command (io.spine.core.Command)2 Event (io.spine.core.Event)2 Rejection (io.spine.core.Rejection)2 TenantId (io.spine.core.TenantId)2 Version (io.spine.core.Version)2 TypeConverter.toAny (io.spine.protobuf.TypeConverter.toAny)2 AggregateMessageDispatcher.dispatchCommand (io.spine.server.aggregate.AggregateMessageDispatcher.dispatchCommand)2