class BundleImpl implements Bundle {

    @Override
    public <A> A adapt(final Class<A> type) {
        if (BundleWiring.class == type) {
            if (bundleWiring == null) {
                synchronized (this) {
                    if (bundleWiring == null) {
                        bundleWiring = new BundleWiringImpl(this, registry);
                    }
                }
            }
            return type.cast(bundleWiring);
        }
        if (BundleRevision.class == type) {
            if (bundleRevision == null) {
                synchronized (this) {
                    if (bundleRevision == null) {
                        bundleRevision = new BundleRevisionImpl(this);
                    }
                }
            }
            return type.cast(bundleRevision);
        }
        if (BundleRevisions.class == type) {
            return type.cast(new BundleRevisions() {
                @Override
                public Bundle getBundle() {
                    return BundleImpl.this;
                }

                @Override
                public List<BundleRevision> getRevisions() {
                    return singletonList(bundleRevision);
                }
            });
        }
        if (BundleContext.class == type) {
            return type.cast(context);
        }
        if (ServiceReferenceDTO[].class == type) {
            return type.cast(Stream.of(getRegisteredServices())
                    .map(s -> {
                        final ServiceReferenceDTO dto = new ServiceReferenceDTO();
                        dto.bundle = getBundleId();
                        dto.id = Long.class.cast(s.getProperty(Constants.SERVICE_ID));
                        dto.properties = list(s.getProperties().keys()).stream()
                                .collect(toMap(identity(), s::getProperty));
                        dto.usingBundles = ofNullable(s.getUsingBundles())
                                .map(bundles -> Stream.of(bundles).mapToLong(Bundle::getBundleId).toArray())
                                .orElseGet(() -> new long[0]);
                        return dto;
                    })
                    .toArray(ServiceReferenceDTO[]::new));
        }
        return null;
    }

      BundleImpl(final Manifest manifest, final File file, final BundleContextImpl context,
               final Ripener.Configuration configuration, final long id,
               final Collection<String> includedResources, final BundleRegistry registry);

}