Replace more usages of TypeToken#toString
This commit is contained in:
parent
3df3560d91
commit
83163c2a77
5 changed files with 13 additions and 13 deletions
|
|
@ -104,7 +104,7 @@ public class SimpleCommandMeta extends CommandMeta {
|
||||||
}
|
}
|
||||||
if (!GenericTypeReflector.isSuperType(key.getValueType().getType(), value.getClass())) {
|
if (!GenericTypeReflector.isSuperType(key.getValueType().getType(), value.getClass())) {
|
||||||
throw new IllegalArgumentException("Conflicting argument types between key type of "
|
throw new IllegalArgumentException("Conflicting argument types between key type of "
|
||||||
+ key.getValueType().getType() + " and value type of " + value.getClass());
|
+ key.getValueType().getType().getTypeName() + " and value type of " + value.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.of((V) value);
|
return Optional.of((V) value);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
package cloud.commandframework.services;
|
package cloud.commandframework.services;
|
||||||
|
|
||||||
import cloud.commandframework.services.types.Service;
|
import cloud.commandframework.services.types.Service;
|
||||||
|
import io.leangen.geantyref.TypeToken;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
@ -44,7 +45,7 @@ enum ServiceFilterHandler {
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new PipelineException(String
|
throw new PipelineException(String
|
||||||
.format("Failed to evaluate filter '%s' for '%s'",
|
.format("Failed to evaluate filter '%s' for '%s'",
|
||||||
predicate.getClass().getCanonicalName(), service.toString()
|
TypeToken.get(predicate.getClass()).getType().getTypeName(), service
|
||||||
), e);
|
), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ public final class ServicePipeline {
|
||||||
throw new IllegalArgumentException(String
|
throw new IllegalArgumentException(String
|
||||||
.format(
|
.format(
|
||||||
"Service of type '%s' has already been registered",
|
"Service of type '%s' has already been registered",
|
||||||
type.toString()
|
type.getType().getTypeName()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
final ServiceRepository<Context, Result> repository = new ServiceRepository<>(type);
|
final ServiceRepository<Context, Result> repository = new ServiceRepository<>(type);
|
||||||
|
|
@ -121,7 +121,7 @@ public final class ServicePipeline {
|
||||||
final ServiceRepository<?, ?> repository = this.repositories.get(type.getType());
|
final ServiceRepository<?, ?> repository = this.repositories.get(type.getType());
|
||||||
if (repository == null) {
|
if (repository == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
String.format("No service registered for type '%s'", type.toString()));
|
String.format("No service registered for type '%s'", type.getType().getTypeName()));
|
||||||
}
|
}
|
||||||
repository.<Service>registerImplementation(
|
repository.<Service>registerImplementation(
|
||||||
serviceEntry.getKey(),
|
serviceEntry.getKey(),
|
||||||
|
|
@ -199,7 +199,7 @@ public final class ServicePipeline {
|
||||||
(ServiceRepository<Context, Result>) this.repositories.get(type.getType());
|
(ServiceRepository<Context, Result>) this.repositories.get(type.getType());
|
||||||
if (repository == null) {
|
if (repository == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
String.format("No service registered for type '%s'", type.toString()));
|
String.format("No service registered for type '%s'", type.getType().getTypeName()));
|
||||||
}
|
}
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,9 +138,10 @@ public final class ServiceRepository<Context, Response> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String
|
return String.format(
|
||||||
.format("ServiceWrapper{type=%s,implementation=%s}", ServiceRepository.this.serviceType.toString(),
|
"ServiceWrapper{type=%s,implementation=%s}",
|
||||||
TypeToken.get(this.implementation.getClass()).toString()
|
ServiceRepository.this.serviceType.getType().getTypeName(),
|
||||||
|
TypeToken.get(this.implementation.getClass()).getType().getTypeName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,13 +94,11 @@ public final class ServiceSpigot<Context, Result> {
|
||||||
try {
|
try {
|
||||||
result = wrapper.getImplementation().handle(this.context);
|
result = wrapper.getImplementation().handle(this.context);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new PipelineException(
|
throw new PipelineException(String.format("Failed to retrieve result from %s", wrapper), e);
|
||||||
String.format("Failed to retrieve result from %s", wrapper.toString()), e);
|
|
||||||
}
|
}
|
||||||
if (wrapper.getImplementation() instanceof SideEffectService) {
|
if (wrapper.getImplementation() instanceof SideEffectService) {
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(String.format("SideEffectService '%s' returned null", wrapper));
|
||||||
String.format("SideEffectService '%s' returned null", wrapper.toString()));
|
|
||||||
} else if (result == State.ACCEPTED) {
|
} else if (result == State.ACCEPTED) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue