SofaProtoUtils { public static boolean checkIfUseGeneric(ConsumerConfig consumerConfig) { Class proxyClass = consumerConfig.getProxyClass(); Class enclosingClass = proxyClass.getEnclosingClass(); if (enclosingClass != null) { try { enclosingClass.getDeclaredMethod("getSofaStub", Channel.class, CallOptions.class, int.class); return false; } catch (NoSuchMethodException e) { return true; } } return true; }  static boolean isProtoClass(Object object); static Set<String> getMethodNames(String interfaceId); static boolean checkIfUseGeneric(ConsumerConfig consumerConfig); static String getFullNameWithUniqueId(String fullMethodName, String uniqueId);  }
@Test public void testCheckIfUseGeneric() { ConsumerConfig asTrue = new ConsumerConfig(); asTrue.setInterfaceId(NeedGeneric.NeedGenericInterface.class.getName()); ConsumerConfig asFalse = new ConsumerConfig(); asFalse.setInterfaceId(DoNotNeedGeneric.NoNotNeedGenericInterface.class.getName()); Assert.assertTrue(SofaProtoUtils.checkIfUseGeneric(asTrue)); Assert.assertFalse(SofaProtoUtils.checkIfUseGeneric(asFalse)); }