@Test public void getDefaultName() { AwsClientFactory factory = new AwsClientFactory(config); Assert.assertEquals("ec2", factory.getDefaultName(AmazonEC2.class)); Assert.assertEquals("ec2", factory.getDefaultName(DescribeAddressesRequest.class)); }
String getDefaultName(Class<?> cls) { final String prefix = "com.amazonaws.services."; String pkg = cls.getPackage().getName(); return pkg.startsWith(prefix) ? firstOnly(pkg.substring(prefix.length())) : null; }
AwsClientFactory implements AutoCloseable { String getDefaultName(Class<?> cls) { final String prefix = "com.amazonaws.services."; String pkg = cls.getPackage().getName(); return pkg.startsWith(prefix) ? firstOnly(pkg.substring(prefix.length())) : null; } }
AwsClientFactory implements AutoCloseable { String getDefaultName(Class<?> cls) { final String prefix = "com.amazonaws.services."; String pkg = cls.getPackage().getName(); return pkg.startsWith(prefix) ? firstOnly(pkg.substring(prefix.length())) : null; } @Inject  AwsClientFactory(Config config); }
AwsClientFactory implements AutoCloseable { String getDefaultName(Class<?> cls) { final String prefix = "com.amazonaws.services."; String pkg = cls.getPackage().getName(); return pkg.startsWith(prefix) ? firstOnly(pkg.substring(prefix.length())) : null; } @Inject  AwsClientFactory(Config config); T newInstance(Class<T> cls); T newInstance(String name, Class<T> cls); T newInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T newInstance(String name, Class<T> cls, String accountId); T getInstance(Class<T> cls); T getInstance(String name, Class<T> cls); T getInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T getInstance(String name, Class<T> cls, String accountId); @Override void close(); }
AwsClientFactory implements AutoCloseable { String getDefaultName(Class<?> cls) { final String prefix = "com.amazonaws.services."; String pkg = cls.getPackage().getName(); return pkg.startsWith(prefix) ? firstOnly(pkg.substring(prefix.length())) : null; } @Inject  AwsClientFactory(Config config); T newInstance(Class<T> cls); T newInstance(String name, Class<T> cls); T newInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T newInstance(String name, Class<T> cls, String accountId); T getInstance(Class<T> cls); T getInstance(String name, Class<T> cls); T getInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T getInstance(String name, Class<T> cls, String accountId); @Override void close();  }