wrong way to check if an object is an instance of a given type

This commit is contained in:
Gered 2013-10-21 12:33:23 -04:00
parent f7ba75b9ec
commit d5472b2701

View file

@ -24,7 +24,7 @@ public class Services {
if (services.containsKey(type)) if (services.containsKey(type))
throw new UnsupportedOperationException("Another service of this type has already been registered."); throw new UnsupportedOperationException("Another service of this type has already been registered.");
if (type.isAssignableFrom(Service.class)) if (Service.class.isInstance(service))
((Service)service).onRegister(); ((Service)service).onRegister();
services.put(type, service); services.put(type, service);
@ -42,7 +42,7 @@ public class Services {
services.remove(type); services.remove(type);
Gdx.app.log("Services", String.format("Unregistered object of type %s.", type.getSimpleName())); Gdx.app.log("Services", String.format("Unregistered object of type %s.", type.getSimpleName()));
if (type.isAssignableFrom(Service.class)) if (Service.class.isInstance(service))
((Service)service).onUnregister(); ((Service)service).onUnregister();
} }