Search in sources :

Example 1 with TypeName

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

the class SubscriptionService method selectBoundedContext.

private BoundedContext selectBoundedContext(Subscription subscription) {
    final TypeName typeName = TypeName.of(subscription.getTopic().getTarget().getType());
    final TypeUrl type = typeName.toUrl();
    final BoundedContext result = typeToContextMap.get(type);
    return result;
}
Also used : TypeName(io.spine.type.TypeName) TypeUrl(io.spine.type.TypeUrl)

Example 2 with TypeName

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

the class AggregateStateIdStringifier method idTypeFromString.

private static Class idTypeFromString(String idTypeString) {
    final Class result;
    if (idTypeString.contains(TYPE_NAME_DIVIDER)) {
        final TypeName typeName = TypeName.of(idTypeString);
        result = typeName.getJavaClass();
    } else {
        try {
            result = Class.forName(JAVA_LANG_PACKAGE_NAME + idTypeString);
        } catch (ClassNotFoundException e) {
            throw Exceptions.illegalStateWithCauseOf(e);
        }
    }
    return result;
}
Also used : TypeName(io.spine.type.TypeName)

Example 3 with TypeName

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

the class SubscriptionService method selectBoundedContext.

private BoundedContext selectBoundedContext(Target target) {
    final TypeName typeName = TypeName.of(target.getType());
    final TypeUrl type = typeName.toUrl();
    final BoundedContext result = typeToContextMap.get(type);
    return result;
}
Also used : TypeName(io.spine.type.TypeName) TypeUrl(io.spine.type.TypeUrl)

Example 4 with TypeName

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

the class InvalidCommandException method onInapplicableTenantId.

public static InvalidCommandException onInapplicableTenantId(Command command) {
    final CommandEnvelope cmd = CommandEnvelope.of(command);
    final TypeName typeName = TypeName.of(cmd.getMessage());
    final String errMsg = format("The command (class: %s, type: %s, id: %s) was posted to single-tenant " + "CommandBus, but has tenant_id: %s attribute set in the command context.", cmd.getMessageClass(), typeName, cmd.getCommandId(), cmd.getTenantId());
    final Error error = inapplicableTenantError(cmd.getMessage(), errMsg);
    return new InvalidCommandException(errMsg, command, error);
}
Also used : TypeName(io.spine.type.TypeName) CommandEnvelope(io.spine.envelope.CommandEnvelope) CommandValidationError(io.spine.base.CommandValidationError) Error(io.spine.base.Error) Identifiers.idToString(io.spine.base.Identifiers.idToString)

Example 5 with TypeName

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

the class Queries method typeOf.

/**
     * Extract the type of {@link Target} for the given {@link Query}.
     *
     * <p>Returns null 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 TypeName typeName = TypeName.of(target.getType());
    final TypeUrl type = typeName.toUrl();
    return type;
}
Also used : Targets.composeTarget(io.spine.client.Targets.composeTarget) TypeName(io.spine.type.TypeName) TypeUrl(io.spine.type.TypeUrl)

Aggregations

TypeName (io.spine.type.TypeName)5 TypeUrl (io.spine.type.TypeUrl)3 CommandValidationError (io.spine.base.CommandValidationError)1 Error (io.spine.base.Error)1 Identifiers.idToString (io.spine.base.Identifiers.idToString)1 Targets.composeTarget (io.spine.client.Targets.composeTarget)1 CommandEnvelope (io.spine.envelope.CommandEnvelope)1