WrappingPersistence implements Persistence<O, A> { @Override public ObjectStore<O> createObjectStore() { return new CollectionWrappingObjectStore<O>(backingCollection); } WrappingPersistence(Collection<O> backingCollection);  WrappingPersistence(Collection<O> backingCollection, SimpleAttribute<O, A> primaryKeyAttribute); @Override boolean supportsIndex(Index<O> index); @Override ObjectStore<O> createObjectStore(); @Override void openRequestScopeResources(QueryOptions queryOptions); @Override void closeRequestScopeResources(QueryOptions queryOptions); @Override SimpleAttribute<O, A> getPrimaryKeyAttribute(); static WrappingPersistence<O, A> aroundCollectionOnPrimaryKey(Collection<O> collection, SimpleAttribute<O, A> primaryKeyAttribute); @SuppressWarnings("unchecked") static WrappingPersistence<O, ? extends Comparable> aroundCollection(Collection<O> collection);  }
@Test public void testCreateObjectStore() throws Exception { HashSet<Car> backingCollection = new HashSet<Car>(); WrappingPersistence<Car, Integer> wrappingPersistence = WrappingPersistence.aroundCollectionOnPrimaryKey(backingCollection, Car.CAR_ID); ObjectStore<Car> objectStore = wrappingPersistence.createObjectStore(); assertTrue(objectStore instanceof CollectionWrappingObjectStore); assertEquals(backingCollection, ((CollectionWrappingObjectStore)objectStore).getBackingCollection()); }