@Test public void testFeatures() { final CloudFrontDistributionConfiguration d = new CloudFrontDistributionConfiguration( new S3Session(new Host(new S3Protocol(), new S3Protocol().getDefaultHostname())), new DisabledX509TrustManager(), new DefaultX509KeyManager(), Collections.emptyMap()); assertNotNull(d.getFeature(Purge.class, Distribution.DOWNLOAD)); assertNotNull(d.getFeature(Purge.class, Distribution.WEBSITE_CDN)); assertNull(d.getFeature(Purge.class, Distribution.STREAMING)); assertNull(d.getFeature(Purge.class, Distribution.WEBSITE)); assertNotNull(d.getFeature(Index.class, Distribution.DOWNLOAD)); assertNotNull(d.getFeature(Index.class, Distribution.WEBSITE_CDN)); assertNull(d.getFeature(Index.class, Distribution.STREAMING)); assertNull(d.getFeature(Index.class, Distribution.WEBSITE)); assertNotNull(d.getFeature(DistributionLogging.class, Distribution.DOWNLOAD)); assertNotNull(d.getFeature(Cname.class, Distribution.DOWNLOAD)); }
@Override @SuppressWarnings("unchecked") public <T> T getFeature(final Class<T> type, final Distribution.Method method) { if(type == Purge.class || type == Index.class) { if(method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.WEBSITE_CDN) || method.equals(Distribution.CUSTOM)) { return (T) this; } } if(type == DistributionLogging.class) { if(method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.STREAMING) || method.equals(Distribution.CUSTOM)) { return (T) this; } } if(type == Cname.class) { return (T) this; } return null; }
CloudFrontDistributionConfiguration implements DistributionConfiguration, Purge, Index, DistributionLogging, Cname { @Override @SuppressWarnings("unchecked") public <T> T getFeature(final Class<T> type, final Distribution.Method method) { if(type == Purge.class || type == Index.class) { if(method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.WEBSITE_CDN) || method.equals(Distribution.CUSTOM)) { return (T) this; } } if(type == DistributionLogging.class) { if(method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.STREAMING) || method.equals(Distribution.CUSTOM)) { return (T) this; } } if(type == Cname.class) { return (T) this; } return null; } }
CloudFrontDistributionConfiguration implements DistributionConfiguration, Purge, Index, DistributionLogging, Cname { @Override @SuppressWarnings("unchecked") public <T> T getFeature(final Class<T> type, final Distribution.Method method) { if(type == Purge.class || type == Index.class) { if(method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.WEBSITE_CDN) || method.equals(Distribution.CUSTOM)) { return (T) this; } } if(type == DistributionLogging.class) { if(method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.STREAMING) || method.equals(Distribution.CUSTOM)) { return (T) this; } } if(type == Cname.class) { return (T) this; } return null; } CloudFrontDistributionConfiguration(final S3Session session, final X509TrustManager trust, final X509KeyManager key,
                                               final Map<Path, Distribution> distributions); }
CloudFrontDistributionConfiguration implements DistributionConfiguration, Purge, Index, DistributionLogging, Cname { @Override @SuppressWarnings("unchecked") public <T> T getFeature(final Class<T> type, final Distribution.Method method) { if(type == Purge.class || type == Index.class) { if(method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.WEBSITE_CDN) || method.equals(Distribution.CUSTOM)) { return (T) this; } } if(type == DistributionLogging.class) { if(method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.STREAMING) || method.equals(Distribution.CUSTOM)) { return (T) this; } } if(type == Cname.class) { return (T) this; } return null; } CloudFrontDistributionConfiguration(final S3Session session, final X509TrustManager trust, final X509KeyManager key,
                                               final Map<Path, Distribution> distributions); @Override String getName(); @Override String getName(final Distribution.Method method); @Override String getHostname(); @Override DescriptiveUrlBag toUrl(final Path file); @Override List<Distribution.Method> getMethods(final Path container); @Override Distribution read(final Path file, final Distribution.Method method, final LoginCallback prompt); @Override void write(final Path file, final Distribution distribution, final LoginCallback prompt); @Override @SuppressWarnings("unchecked") T getFeature(final Class<T> type, final Distribution.Method method); @Override void invalidate(final Path container, final Distribution.Method method, final List<Path> files, final LoginCallback prompt); }
CloudFrontDistributionConfiguration implements DistributionConfiguration, Purge, Index, DistributionLogging, Cname { @Override @SuppressWarnings("unchecked") public <T> T getFeature(final Class<T> type, final Distribution.Method method) { if(type == Purge.class || type == Index.class) { if(method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.WEBSITE_CDN) || method.equals(Distribution.CUSTOM)) { return (T) this; } } if(type == DistributionLogging.class) { if(method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.STREAMING) || method.equals(Distribution.CUSTOM)) { return (T) this; } } if(type == Cname.class) { return (T) this; } return null; } CloudFrontDistributionConfiguration(final S3Session session, final X509TrustManager trust, final X509KeyManager key,
                                               final Map<Path, Distribution> distributions); @Override String getName(); @Override String getName(final Distribution.Method method); @Override String getHostname(); @Override DescriptiveUrlBag toUrl(final Path file); @Override List<Distribution.Method> getMethods(final Path container); @Override Distribution read(final Path file, final Distribution.Method method, final LoginCallback prompt); @Override void write(final Path file, final Distribution distribution, final LoginCallback prompt); @Override @SuppressWarnings("unchecked") T getFeature(final Class<T> type, final Distribution.Method method); @Override void invalidate(final Path container, final Distribution.Method method, final List<Path> files, final LoginCallback prompt);  }