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