From b65487f318e4751755f37265cf0dc74a2b770e26 Mon Sep 17 00:00:00 2001 From: Charlie Groves Date: Thu, 10 Apr 2008 01:18:32 +0000 Subject: [PATCH] Cut the number of times a service class needs to be specified to two git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4993 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/java/com/threerings/presents/client/Client.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/java/com/threerings/presents/client/Client.java b/src/java/com/threerings/presents/client/Client.java index a151c1468..af2e5643d 100644 --- a/src/java/com/threerings/presents/client/Client.java +++ b/src/java/com/threerings/presents/client/Client.java @@ -283,7 +283,7 @@ public class Client * {@link InvocationService} derivation. null is returned if no such service * could be found. */ - public InvocationService getService (Class sclass) + public T getService (Class sclass) { if (_bstrap == null) { return null; @@ -292,7 +292,8 @@ public class Client for (int ii = 0; ii < scount; ii++) { InvocationService service = _bstrap.services.get(ii); if (sclass.isInstance(service)) { - return service; + @SuppressWarnings("unchecked") T asSclass = (T)service; + return asSclass; } } return null; @@ -303,9 +304,9 @@ public class Client * not available. Useful to avoid redundant error checking when you know that the shit will hit * the fan if a particular invocation service is not available. */ - public InvocationService requireService (Class sclass) + public T requireService (Class sclass) { - InvocationService isvc = getService(sclass); + T isvc = getService(sclass); if (isvc == null) { throw new RuntimeException( sclass.getName() + " isn't available. I can't bear to go on.");