http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java index 68040d9..949bf4f 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/service/ConfigurationTest.java @@ -62,8 +62,7 @@ public class ConfigurationTest throws Exception { UnitOfWork unit = unitOfWorkFactory.newUnitOfWork(); - EntityBuilder<HelloWorldConfiguration> entityBuilder = unit.newEntityBuilder( HelloWorldConfiguration.class, service - .identity() ); + EntityBuilder<HelloWorldConfiguration> entityBuilder = unit.newEntityBuilder( HelloWorldConfiguration.class, service.identity() ); HelloWorldConfiguration config = entityBuilder.instance(); config.phrase().set( "Hey" ); config.name().set( "Universe" ); @@ -88,8 +87,7 @@ public class ConfigurationTest { UnitOfWork unit = unitOfWorkFactory.newUnitOfWork(); - EntityBuilder<HelloWorldConfiguration> entityBuilder = unit.newEntityBuilder( HelloWorldConfiguration.class, service - .identity() ); + EntityBuilder<HelloWorldConfiguration> entityBuilder = unit.newEntityBuilder( HelloWorldConfiguration.class, service.identity() ); config = entityBuilder.instance(); config.phrase().set( "Hello" ); config.name().set( "World" );
http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceVisibilityTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceVisibilityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceVisibilityTest.java index cb4d87b..b4559ba 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceVisibilityTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/service/ServiceVisibilityTest.java @@ -20,6 +20,8 @@ package org.apache.zest.runtime.service; +import org.apache.zest.api.identity.Identity; +import org.apache.zest.api.identity.StringIdentity; import org.apache.zest.api.unitofwork.UnitOfWorkFactory; import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler; import org.junit.After; @@ -45,6 +47,8 @@ import org.apache.zest.test.EntityTestAssembler; public class ServiceVisibilityTest { + public static final Identity TEST_IDENTITY = new StringIdentity( "123" ); + private Energy4Java zest; private Module module; private Application app; @@ -182,7 +186,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.moduleApplicationVisible(); } finally @@ -200,7 +204,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.moduleLayerVisible(); } finally @@ -218,7 +222,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.moduleModuleVisible(); } finally @@ -236,7 +240,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.besideApplicationVisible(); } finally @@ -254,7 +258,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.besideLayerVisible(); } finally @@ -272,7 +276,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.besideModuleVisible(); } finally @@ -290,7 +294,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.belowApplicationVisible(); } finally @@ -308,7 +312,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.belowLayerVisible(); } finally @@ -326,7 +330,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.belowModuleVisible(); } finally @@ -344,7 +348,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.aboveApplicationVisible(); } finally @@ -362,7 +366,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.aboveLayerVisible(); } finally @@ -380,7 +384,7 @@ public class ServiceVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.aboveModuleVisible(); } finally http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/structure/TypeToCompositeLookupTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/structure/TypeToCompositeLookupTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/structure/TypeToCompositeLookupTest.java index 2ab5373..f7da054 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/structure/TypeToCompositeLookupTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/structure/TypeToCompositeLookupTest.java @@ -20,12 +20,13 @@ package org.apache.zest.runtime.structure; import java.util.Iterator; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.unitofwork.UnitOfWorkFactory; import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler; import org.junit.Test; import org.apache.zest.api.activation.ActivationException; import org.apache.zest.api.composite.AmbiguousTypeException; -import org.apache.zest.api.entity.Identity; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.service.ServiceReference; import org.apache.zest.api.structure.Module; @@ -51,9 +52,7 @@ public class TypeToCompositeLookupTest public interface Foo { - String bar(); - } public static class BasicFooImpl @@ -276,17 +275,17 @@ public class TypeToCompositeLookupTest assertEquals( CATHEDRAL, basicFoo.bar() ); assertEquals( CATHEDRAL, foo.bar() ); - String someOtherFooIdentity = ( (Identity) someOtherFoo ).identity().get(); - String basicFooIdentity = ( (Identity) basicFoo ).identity().get(); - String fooIdentity = ( (Identity) foo ).identity().get(); + Identity someOtherFooIdentity = ((HasIdentity) someOtherFoo).identity().get(); + Identity basicFooIdentity = ((HasIdentity) basicFoo).identity().get(); + Identity fooIdentity = ((HasIdentity) foo).identity().get(); uow.complete(); uow = uowf.newUnitOfWork(); - uow.get( SomeOtherFoo.class, someOtherFooIdentity ); + uow.get( SomeOtherFoo.class, someOtherFooIdentity ); uow.get( BasicFoo.class, basicFooIdentity ); - uow.get( Foo.class, fooIdentity ); + uow.get( Foo.class, fooIdentity ); uow.discard(); } @@ -328,8 +327,8 @@ public class TypeToCompositeLookupTest // Specific Type used assertEquals( BAZAR, uow.newEntityBuilder( BasicFoo.class ).newInstance().bar() ); - String someOtherFooIdentity = ( (Identity) someOtherFoo ).identity().get(); - String basicFooIdentity = ( (Identity) basicFoo ).identity().get(); + Identity someOtherFooIdentity = ((HasIdentity) someOtherFoo).identity().get(); + Identity basicFooIdentity = ((HasIdentity) basicFoo).identity().get(); uow.complete(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/transients/TransientVisibilityTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/transients/TransientVisibilityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/transients/TransientVisibilityTest.java index 889d898..e07b8b2 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/transients/TransientVisibilityTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/transients/TransientVisibilityTest.java @@ -25,6 +25,8 @@ import org.apache.zest.api.composite.NoSuchTransientException; import org.apache.zest.api.composite.TransientBuilder; import org.apache.zest.api.composite.TransientComposite; import org.apache.zest.api.entity.EntityComposite; +import org.apache.zest.api.identity.Identity; +import org.apache.zest.api.identity.StringIdentity; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.service.ServiceComposite; @@ -46,6 +48,7 @@ import org.junit.Test; public class TransientVisibilityTest { + public static final Identity TEST_IDENTITY = new StringIdentity( "123" ); private Energy4Java zest; private Module module; private Application app; @@ -183,7 +186,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.moduleApplicationVisible(); } finally @@ -201,7 +204,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.moduleLayerVisible(); } finally @@ -219,7 +222,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.moduleModuleVisible(); } finally @@ -237,7 +240,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.besideApplicationVisible(); } finally @@ -255,7 +258,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.besideLayerVisible(); } finally @@ -273,7 +276,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.besideModuleVisible(); } finally @@ -291,7 +294,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.belowApplicationVisible(); } finally @@ -309,7 +312,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.belowLayerVisible(); } finally @@ -327,7 +330,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.belowModuleVisible(); } finally @@ -345,7 +348,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.aboveApplicationVisible(); } finally @@ -363,7 +366,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.aboveLayerVisible(); } finally @@ -381,7 +384,7 @@ public class TransientVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTITY); entity.aboveModuleVisible(); } finally http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java index 816166b..7c223f8 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/PrivateEntityUnitOfWorkTest.java @@ -24,7 +24,9 @@ import org.apache.zest.api.association.Association; import org.apache.zest.api.association.ManyAssociation; import org.apache.zest.api.entity.EntityBuilder; import org.apache.zest.api.entity.EntityComposite; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.Identity; +import org.apache.zest.api.identity.StringIdentity; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.property.Property; @@ -50,6 +52,8 @@ import static org.junit.Assert.fail; */ public class PrivateEntityUnitOfWorkTest { + private static final Identity TEST_IDENTITY = new StringIdentity( "1" ); + @Structure private UnitOfWorkFactory uowf; @@ -98,16 +102,16 @@ public class PrivateEntityUnitOfWorkTest catch( NoSuchEntityTypeException e ) { // Ok - ProductCatalog catalog = unitOfWork.newEntity( ProductCatalog.class, "1" ); + ProductCatalog catalog = unitOfWork.newEntity( ProductCatalog.class, TEST_IDENTITY); unitOfWork.complete(); } unitOfWork = uowf.newUnitOfWork(); - String id; + Identity id; try { - ProductCatalog catalog = unitOfWork.get( ProductCatalog.class, "1" ); - id = ( (Identity) catalog.newProduct() ).identity().get(); + ProductCatalog catalog = unitOfWork.get( ProductCatalog.class, TEST_IDENTITY); + id = catalog.newProduct().identity().get(); unitOfWork.complete(); } finally @@ -118,7 +122,7 @@ public class PrivateEntityUnitOfWorkTest unitOfWork = uowf.newUnitOfWork(); try { - ProductCatalog catalog = unitOfWork.get( ProductCatalog.class, "1" ); + ProductCatalog catalog = unitOfWork.get( ProductCatalog.class, TEST_IDENTITY); Product product = catalog.findProduct( id ); product.price().set( 100 ); unitOfWork.complete(); @@ -133,7 +137,7 @@ public class PrivateEntityUnitOfWorkTest { Product newProduct(); - Product findProduct( String id ); + Product findProduct( Identity id ); } @Mixins( ProductCatalogEntity.ProductRepositoryMixin.class ) @@ -164,10 +168,10 @@ public class PrivateEntityUnitOfWorkTest return eb.newInstance(); } - public Product findProduct( String id ) + public Product findProduct( Identity id ) { UnitOfWork uow = uowf.currentUnitOfWork(); - return uow.get( Product.class, id ); + return uow.get( Product.class, id ); } } } @@ -243,7 +247,7 @@ public class PrivateEntityUnitOfWorkTest Property<Float> weight(); } - public interface Product + public interface Product extends HasIdentity { Property<String> name(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/RemovalTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/RemovalTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/RemovalTest.java index 485b185..394d4f4 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/RemovalTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/unitofwork/RemovalTest.java @@ -20,6 +20,8 @@ package org.apache.zest.runtime.unitofwork; +import org.apache.zest.api.identity.Identity; +import org.apache.zest.api.identity.StringIdentity; import org.junit.Test; import org.apache.zest.api.entity.EntityBuilder; import org.apache.zest.api.entity.EntityComposite; @@ -37,7 +39,10 @@ import static org.junit.Assert.fail; public class RemovalTest extends AbstractZestTest { - public void assemble( ModuleAssembly module ) + + private static final Identity TEST_IDENTITY = new StringIdentity( "123" ); + + public void assemble(ModuleAssembly module ) throws AssemblyException { new EntityTestAssembler().assemble( module ); @@ -51,12 +56,12 @@ public class RemovalTest UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); try { - EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, "123" ); + EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, TEST_IDENTITY); builder.instance().name().set( "Niclas" ); builder.newInstance(); uow.complete(); uow = unitOfWorkFactory.newUnitOfWork(); - Abc abc = uow.get( Abc.class, "123" ); + Abc abc = uow.get( Abc.class, TEST_IDENTITY); assertEquals( "Niclas", abc.name().get() ); } finally @@ -72,17 +77,17 @@ public class RemovalTest UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); try { - EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, "123" ); + EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, TEST_IDENTITY); builder.instance().name().set( "Niclas" ); builder.newInstance(); uow.complete(); uow = unitOfWorkFactory.newUnitOfWork(); - Abc abc = uow.get( Abc.class, "123" ); + Abc abc = uow.get( Abc.class, TEST_IDENTITY); assertEquals( "Niclas", abc.name().get() ); uow.remove( abc ); uow.complete(); uow = unitOfWorkFactory.newUnitOfWork(); - uow.get( Abc.class, "123" ); + uow.get( Abc.class, TEST_IDENTITY); fail( "This '123' entity should not exist." ); } catch( NoSuchEntityException e ) @@ -102,7 +107,7 @@ public class RemovalTest UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); try { - EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, "123" ); + EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, TEST_IDENTITY); builder.instance().name().set( "Niclas" ); Abc abc = builder.newInstance(); uow.complete(); @@ -111,7 +116,7 @@ public class RemovalTest uow.remove( abc ); uow.complete(); uow = unitOfWorkFactory.newUnitOfWork(); - uow.get( Abc.class, "123" ); + uow.get( Abc.class, TEST_IDENTITY); fail( "This '123' entity should not exist." ); } catch( NoSuchEntityException e ) @@ -131,13 +136,13 @@ public class RemovalTest UnitOfWork uow = unitOfWorkFactory.newUnitOfWork(); try { - EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, "123" ); + EntityBuilder<Abc> builder = uow.newEntityBuilder( Abc.class, TEST_IDENTITY); builder.instance().name().set( "Niclas" ); Abc abc = builder.newInstance(); uow.remove( abc ); uow.complete(); uow = unitOfWorkFactory.newUnitOfWork(); - uow.get( Abc.class, "123" ); + uow.get( Abc.class, TEST_IDENTITY); fail( "This '123' entity should not exist." ); } catch( NoSuchEntityException e ) http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/value/AssociationToValueTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/AssociationToValueTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/AssociationToValueTest.java index e9dfdf3..8be089f 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/value/AssociationToValueTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/AssociationToValueTest.java @@ -26,7 +26,8 @@ import java.util.Set; import java.util.function.BiFunction; import org.apache.zest.api.association.ManyAssociation; import org.apache.zest.api.association.NamedAssociation; -import org.apache.zest.api.entity.Identity; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.StringIdentity; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.mixin.Mixins; @@ -120,7 +121,7 @@ public class AssociationToValueTest extends AbstractZestTest serviceFinder.findService( Runnable.class ).get().run(); } - public interface Person extends Identity + public interface Person extends HasIdentity { ManyAssociation<Person> children(); @@ -154,7 +155,7 @@ public class AssociationToValueTest extends AbstractZestTest public Person findPersonByName( String name ) { UnitOfWork uow = unitOfWorkFactory.currentUnitOfWork(); - return uow.toValue( Person.class, uow.get( Person.class, name ) ); + return uow.toValue( Person.class, uow.get( Person.class, new StringIdentity( name ) ) ); } } @@ -209,7 +210,7 @@ public class AssociationToValueTest extends AbstractZestTest private Person createPerson( String name ) { UnitOfWork uow = uowf.currentUnitOfWork(); - return uow.newEntity( Person.class, name ); + return uow.newEntity( Person.class, new StringIdentity( name ) ); } } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java index 2567f18..f05d0a1 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueInjectionDeserializationTest.java @@ -20,6 +20,7 @@ package org.apache.zest.runtime.value; +import org.apache.zest.api.identity.Identity; import org.junit.Assert; import org.junit.Test; import org.apache.zest.api.entity.EntityBuilder; @@ -66,7 +67,7 @@ public class ValueInjectionDeserializationTest EntityBuilder<Niclas> eb = uow.newEntityBuilder( Niclas.class ); eb.instance().value().set( value ); Niclas niclas1 = eb.newInstance(); - String id = niclas1.identity().get(); + Identity id = niclas1.identity().get(); uow.complete(); uow = unitOfWorkFactory.newUnitOfWork(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueSerializationRegressionTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueSerializationRegressionTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueSerializationRegressionTest.java index 5fe09b0..d581d5e 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueSerializationRegressionTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueSerializationRegressionTest.java @@ -19,11 +19,12 @@ */ package org.apache.zest.runtime.value; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.StringIdentity; import org.junit.Test; import org.apache.zest.api.association.Association; import org.apache.zest.api.association.ManyAssociation; import org.apache.zest.api.association.NamedAssociation; -import org.apache.zest.api.entity.Identity; import org.apache.zest.api.property.Property; import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException; import org.apache.zest.api.value.ValueBuilder; @@ -54,17 +55,17 @@ public class ValueSerializationRegressionTest extends AbstractZestTest throws UnitOfWorkCompletionException { ValueBuilder<DualFaced> builder = valueBuilderFactory.newValueBuilder( DualFaced.class ); - builder.prototype().identity().set( "1234" ); + builder.prototype().identity().set( new StringIdentity( "1234" ) ); builder.prototype().name().set( "Hedhman" ); DualFaced value = builder.newInstance(); } - public interface SimpleEntity extends Identity + public interface SimpleEntity extends HasIdentity { Property<String> name(); } - public interface DualFaced extends Identity + public interface DualFaced extends HasIdentity { Property<String> name(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueVisibilityTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueVisibilityTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueVisibilityTest.java index e484eff..44e247c 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueVisibilityTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueVisibilityTest.java @@ -20,20 +20,18 @@ package org.apache.zest.runtime.value; -import org.apache.zest.api.unitofwork.UnitOfWorkFactory; -import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; import org.apache.zest.api.common.Visibility; import org.apache.zest.api.composite.TransientComposite; import org.apache.zest.api.entity.EntityComposite; +import org.apache.zest.api.identity.Identity; +import org.apache.zest.api.identity.StringIdentity; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.mixin.Mixins; import org.apache.zest.api.service.ServiceComposite; import org.apache.zest.api.structure.Application; import org.apache.zest.api.structure.Module; import org.apache.zest.api.unitofwork.UnitOfWork; +import org.apache.zest.api.unitofwork.UnitOfWorkFactory; import org.apache.zest.api.value.NoSuchValueException; import org.apache.zest.api.value.ValueBuilder; import org.apache.zest.api.value.ValueComposite; @@ -42,11 +40,16 @@ import org.apache.zest.bootstrap.Assembler; import org.apache.zest.bootstrap.AssemblyException; import org.apache.zest.bootstrap.Energy4Java; import org.apache.zest.bootstrap.ModuleAssembly; +import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler; import org.apache.zest.test.EntityTestAssembler; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; public class ValueVisibilityTest { + public static final Identity TEST_IDENTIY = new StringIdentity( "123" ); private Energy4Java zest; private Module module; private Application app; @@ -184,7 +187,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.moduleApplicationVisible(); } finally @@ -202,7 +205,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.moduleLayerVisible(); } finally @@ -220,7 +223,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.moduleModuleVisible(); } finally @@ -238,7 +241,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.besideApplicationVisible(); } finally @@ -256,7 +259,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.besideLayerVisible(); } finally @@ -274,7 +277,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.besideModuleVisible(); } finally @@ -292,7 +295,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.belowApplicationVisible(); } finally @@ -310,7 +313,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.belowLayerVisible(); } finally @@ -328,7 +331,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.belowModuleVisible(); } finally @@ -346,7 +349,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.aboveApplicationVisible(); } finally @@ -364,7 +367,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.aboveLayerVisible(); } finally @@ -382,7 +385,7 @@ public class ValueVisibilityTest UnitOfWork unitOfWork = uowf.newUnitOfWork(); try { - FromEntity entity = unitOfWork.newEntity( FromEntity.class, "123" ); + FromEntity entity = unitOfWork.newEntity( FromEntity.class, TEST_IDENTIY); entity.aboveModuleVisible(); } finally http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java index 1e3dcad..40ccef6 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/value/ValueWithAssociationTest.java @@ -19,6 +19,9 @@ */ package org.apache.zest.runtime.value; +import org.apache.zest.api.identity.HasIdentity; +import org.apache.zest.api.identity.Identity; +import org.apache.zest.api.identity.StringIdentity; import org.junit.Test; import org.apache.zest.api.association.Association; import org.apache.zest.api.association.AssociationStateHolder; @@ -28,7 +31,6 @@ import org.apache.zest.api.common.Optional; import org.apache.zest.api.entity.EntityBuilder; import org.apache.zest.api.entity.EntityComposite; import org.apache.zest.api.entity.EntityReference; -import org.apache.zest.api.entity.Identity; import org.apache.zest.api.property.Property; import org.apache.zest.api.unitofwork.UnitOfWork; import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException; @@ -63,8 +65,8 @@ public class ValueWithAssociationTest extends AbstractZestTest public void givenEntityInStoreWhenFetchEntityReferenceExpectSuccess() throws UnitOfWorkCompletionException { - String identity1; - String identity2; + Identity identity1; + Identity identity2; DualFaced value; try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork()) { @@ -94,14 +96,14 @@ public class ValueWithAssociationTest extends AbstractZestTest ManyAssociation<?> simples = holder.allManyAssociations().iterator().next(); NamedAssociation<?> namedSimples = holder.allNamedAssociations().iterator().next(); - assertThat( spi.entityReferenceOf( simple ), equalTo( EntityReference.parseEntityReference( identity1 ) ) ); + assertThat( spi.entityReferenceOf( simple ), equalTo( EntityReference.create( identity1 ) ) ); assertThat( spi.entityReferenceOf( simples ) .iterator() - .next(), equalTo( EntityReference.parseEntityReference( identity1 ) ) ); + .next(), equalTo( EntityReference.create( identity1 ) ) ); assertThat( spi.entityReferenceOf( namedSimples ) .iterator() .next() - .getValue(), equalTo( EntityReference.parseEntityReference( identity1 ) ) ); + .getValue(), equalTo( EntityReference.create( identity1 ) ) ); DualFaced resurrected = uow.toEntity( DualFaced.class, value ); assertThat( resurrected.simple(), equalTo( entity.simple() ) ); @@ -115,7 +117,7 @@ public class ValueWithAssociationTest extends AbstractZestTest throws UnitOfWorkCompletionException { ValueBuilder<DualFaced> builder = valueBuilderFactory.newValueBuilder( DualFaced.class ); - builder.prototype().identity().set( "1234" ); + builder.prototype().identity().set( new StringIdentity( "1234" ) ); builder.prototype().name().set( "Hedhman" ); DualFaced value = builder.newInstance(); @@ -127,8 +129,8 @@ public class ValueWithAssociationTest extends AbstractZestTest try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork()) { - DualFaced entity = uow.get( DualFaced.class, "1234" ); - assertThat( entity.identity().get(), equalTo( "1234" ) ); + DualFaced entity = uow.get( DualFaced.class, new StringIdentity( "1234" ) ); + assertThat( entity.identity().get(), equalTo( new StringIdentity( "1234" ) ) ); assertThat( entity.name().get(), equalTo( "Hedhman" ) ); uow.complete(); } @@ -138,8 +140,8 @@ public class ValueWithAssociationTest extends AbstractZestTest public void givenValueWithIdentityAlreadyInStoreWhenConvertingToEntityExpectExistingEntityToBeUpdated() throws UnitOfWorkCompletionException { - String identity1; - String identity2; + Identity identity1; + Identity identity2; try (UnitOfWork uow = unitOfWorkFactory.newUnitOfWork()) { EntityBuilder<SimpleName> builder1 = uow.newEntityBuilder( SimpleName.class ); @@ -184,12 +186,12 @@ public class ValueWithAssociationTest extends AbstractZestTest } } - public interface SimpleName extends Identity + public interface SimpleName extends HasIdentity { Property<String> name(); } - public interface DualFaced extends Identity + public interface DualFaced extends HasIdentity { Property<String> name(); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java b/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java index 55d03f8..3c574bd 100644 --- a/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java +++ b/core/runtime/src/test/java/org/apache/zest/runtime/visibility/VisibilityInUnitOfWorkTest.java @@ -20,6 +20,8 @@ package org.apache.zest.runtime.visibility; import org.apache.zest.api.common.Visibility; +import org.apache.zest.api.identity.Identity; +import org.apache.zest.api.identity.StringIdentity; import org.apache.zest.api.injection.scope.Service; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.mixin.Mixins; @@ -42,6 +44,10 @@ import org.junit.Test; public class VisibilityInUnitOfWorkTest { + + public static final Identity TEST_IDENTITY1 = new StringIdentity( "123" ); + public static final Identity TEST_IDENTITY2 = new StringIdentity( "345" ); + @Test public void givenTwoModulesWithServiceAndEntityInOneAndEntityInOtherWhenOtherEntityAccessServiceWhichUsesItsEntityExpectServiceToHaveVisibility() throws Exception @@ -69,14 +75,14 @@ public class VisibilityInUnitOfWorkTest public void create() { UnitOfWork uow = uowf.currentUnitOfWork(); - YourEntity entity = uow.newEntity( YourEntity.class, "345" ); + YourEntity entity = uow.newEntity( YourEntity.class, TEST_IDENTITY2); } @Override public YourEntity get() { UnitOfWork uow = uowf.currentUnitOfWork(); - return uow.get( YourEntity.class, "345" ); + return uow.get( YourEntity.class, TEST_IDENTITY2); } } } @@ -124,8 +130,8 @@ public class VisibilityInUnitOfWorkTest { try (UnitOfWork uow = uowf.newUnitOfWork()) { - uow.newEntity( MyEntity.class, "123" ); - MyEntity entity1 = uow.get( MyEntity.class, "123" ); + uow.newEntity( MyEntity.class, TEST_IDENTITY1 ); + MyEntity entity1 = uow.get( MyEntity.class, TEST_IDENTITY1 ); service.create(); YourEntity entity2 = service.get(); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/spi/service/importer/ServiceInstanceImporterTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/spi/service/importer/ServiceInstanceImporterTest.java b/core/runtime/src/test/java/org/apache/zest/spi/service/importer/ServiceInstanceImporterTest.java index 8bb716c..f5a6290 100644 --- a/core/runtime/src/test/java/org/apache/zest/spi/service/importer/ServiceInstanceImporterTest.java +++ b/core/runtime/src/test/java/org/apache/zest/spi/service/importer/ServiceInstanceImporterTest.java @@ -20,6 +20,7 @@ package org.apache.zest.spi.service.importer; +import org.apache.zest.api.identity.StringIdentity; import org.hamcrest.CoreMatchers; import org.junit.Assert; import org.junit.Test; @@ -45,7 +46,7 @@ public class ServiceInstanceImporterTest { module.importedServices( TestService.class ). identifiedBy( "test" ). - setMetaInfo( "testimporter" ). + setMetaInfo( new StringIdentity( "testimporter" ) ). importedBy( ImportedServiceDeclaration.SERVICE_IMPORTER ); module.services( TestImporterService.class ).identifiedBy( "testimporter" ); http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/runtime/src/test/java/org/apache/zest/test/performance/entitystore/memory/MemoryEntityStoreTest.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/test/java/org/apache/zest/test/performance/entitystore/memory/MemoryEntityStoreTest.java b/core/runtime/src/test/java/org/apache/zest/test/performance/entitystore/memory/MemoryEntityStoreTest.java index 926587a..51cd822 100644 --- a/core/runtime/src/test/java/org/apache/zest/test/performance/entitystore/memory/MemoryEntityStoreTest.java +++ b/core/runtime/src/test/java/org/apache/zest/test/performance/entitystore/memory/MemoryEntityStoreTest.java @@ -57,7 +57,7 @@ public class MemoryEntityStoreTest { for( EntityState changedState : changedStates ) { - System.out.println( changedState.status().name() + ":" + changedState.identity() ); + System.out.println( changedState.status().name() + ":" + changedState.entityReference() ); } } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/entitystore/memory/MemoryMapEntityStoreMixin.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/entitystore/memory/MemoryMapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/entitystore/memory/MemoryMapEntityStoreMixin.java index 0f298ae..893e17a 100644 --- a/core/spi/src/main/java/org/apache/zest/entitystore/memory/MemoryMapEntityStoreMixin.java +++ b/core/spi/src/main/java/org/apache/zest/entitystore/memory/MemoryMapEntityStoreMixin.java @@ -163,7 +163,7 @@ public class MemoryMapEntityStoreMixin JSONTokener tokener = new JSONTokener( item ); JSONObject entity = (JSONObject) tokener.nextValue(); String id = entity.getString( JSONKeys.IDENTITY ); - store.put( new EntityReference( id ), item ); + store.put( EntityReference.parseEntityReference( id ), item ); } catch( JSONException e ) { http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/cache/Cache.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/cache/Cache.java b/core/spi/src/main/java/org/apache/zest/spi/cache/Cache.java index 0df9292..80b0c43 100644 --- a/core/spi/src/main/java/org/apache/zest/spi/cache/Cache.java +++ b/core/spi/src/main/java/org/apache/zest/spi/cache/Cache.java @@ -22,7 +22,7 @@ package org.apache.zest.spi.cache; /** * Interface to interact with Cache implementations. * The Cache interface has the simple put/get/remove method to make implementations very easy and straight forward. - * The key is always a String, since it is intended to be used for the EntityComposite's identity, and not totally + * The key is always a String, since it is intended to be used for the EntityComposite's reference, and not totally * generic. * * @param <T> The Value type to be stored in the cache. http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/cache/CachePool.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/cache/CachePool.java b/core/spi/src/main/java/org/apache/zest/spi/cache/CachePool.java index c3f18f0..c4bf38d 100644 --- a/core/spi/src/main/java/org/apache/zest/spi/cache/CachePool.java +++ b/core/spi/src/main/java/org/apache/zest/spi/cache/CachePool.java @@ -43,7 +43,7 @@ public interface CachePool * If the cache does not exist already, then a new Cache should be created and returned. For each fetchCache() * call, a reference count on the Cache must be increased. * - * @param cacheId The identity of the cache. If the same id is given as a previous fetch, the same cache will be + * @param cacheId The reference of the cache. If the same id is given as a previous fetch, the same cache will be * returned. * @param valueType * @param <T> http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java b/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java index 734f5d5..2e26571 100644 --- a/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java @@ -31,11 +31,11 @@ import org.apache.zest.api.time.SystemTime; public interface EntityState { /** - * Returns the identity of the entity that this EntityState represents. + * Returns the reference of the entity that this EntityState represents. * - * @return the identity of the entity that this EntityState represents. + * @return the reference of the entity that this EntityState represents. */ - EntityReference identity(); + EntityReference entityReference(); /** * Version of the entity. This is managed by the EntityStore. http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entity/QualifiedIdentity.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entity/QualifiedIdentity.java b/core/spi/src/main/java/org/apache/zest/spi/entity/QualifiedIdentity.java deleted file mode 100644 index a4d9f9b..0000000 --- a/core/spi/src/main/java/org/apache/zest/spi/entity/QualifiedIdentity.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * - */ - -package org.apache.zest.spi.entity; - -import java.io.Serializable; -import org.apache.zest.api.ZestAPI; -import org.apache.zest.api.entity.EntityComposite; -import org.apache.zest.api.util.Classes; - -import static org.apache.zest.functional.Iterables.first; - -/** - * A Qualified Identity is the combination of the Composite type name and the identity of a specific - * Entity instance. When stringified, these two are separated by the ":" character. Example: - * <pre> - * com.mycompany.mydomain.SomeEntity:123456 - * </pre> - * where "com.mycompany.mydomain.SomeEntity" is the Composite type, and "123456" is the identity. - */ -public final class QualifiedIdentity - implements Serializable -{ - public static QualifiedIdentity parseURI( String uri ) - { - String str = uri.substring( "urn:zest:entity:".length() ); - int idx = str.indexOf( "/" ); - String type = str.substring( 0, idx ).replace( "-", "$" ); - String identity = str.substring( idx + 1 ); - return new QualifiedIdentity( identity, type ); - } - - public static QualifiedIdentity parseQualifiedIdentity( String id ) - { - return new QualifiedIdentity( id ); - } - - public static QualifiedIdentity qualifiedIdentityOf( Object o ) - { - return new QualifiedIdentity( (EntityComposite) o ); - } - - private static final long serialVersionUID = 1L; - - // Associations who have been set to "null" should use this as the representation in the EntityState - public static final QualifiedIdentity NULL = new QualifiedIdentity( "null", "none" ); - - private String identity; - private String compositeType; - - public QualifiedIdentity( EntityComposite entityComposite ) - { - this( entityComposite.identity().get(), ZestAPI.FUNCTION_DESCRIPTOR_FOR - .apply( entityComposite ) - .types().findFirst().get().getName() ); - } - - public QualifiedIdentity( String identity, Class<?> clazz ) - { - this.identity = identity; - this.compositeType = clazz.getName(); - } - - public QualifiedIdentity( String identity, String clazz ) - { - this.identity = identity; - this.compositeType = clazz; - } - - protected QualifiedIdentity( String qualifiedIdentity ) - { - int separatorIndex = qualifiedIdentity.indexOf( ":" ); - if( separatorIndex == -1 ) - { - throw new IllegalArgumentException( "Supplied string is not a qualified identity: " + qualifiedIdentity ); - } - this.compositeType = qualifiedIdentity.substring( 0, separatorIndex ); - this.identity = qualifiedIdentity.substring( separatorIndex + 1 ); - } - - public final String identity() - { - return identity; - } - - public final String type() - { - return compositeType; - } - - public final String toURI() - { - return "urn:zest:entity:" + Classes.normalizeClassToURI( compositeType ) + "/" + identity; - } - - @Override - @SuppressWarnings( "AccessingNonPublicFieldOfAnotherObject" ) - public boolean equals( Object o ) - { - if( this == o ) - { - return true; - } - if( o == null || getClass() != o.getClass() ) - { - return false; - } - QualifiedIdentity that = (QualifiedIdentity) o; - return compositeType.equals( that.compositeType ) && identity.equals( that.identity ); - } - - @Override - public int hashCode() - { - int result; - result = identity.hashCode(); - result = 31 * result + compositeType.hashCode(); - return result; - } - - @Override - public String toString() - { - return compositeType + ":" + identity; - } -} http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java index 0729c68..0ecd598 100755 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java @@ -27,6 +27,7 @@ import org.apache.zest.api.ZestAPI; import org.apache.zest.api.concern.ConcernOf; import org.apache.zest.api.entity.EntityDescriptor; import org.apache.zest.api.entity.EntityReference; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.injection.scope.Structure; import org.apache.zest.api.injection.scope.This; import org.apache.zest.api.structure.ModuleDescriptor; @@ -82,7 +83,7 @@ public abstract class ConcurrentModificationCheckConcern } @Override - public String identity() + public Identity identity() { return uow.identity(); } @@ -186,7 +187,7 @@ public abstract class ConcurrentModificationCheckConcern try { EntityState entityState = uow.entityStateOf( module, anIdentity ); - versions.rememberVersion( entityState.identity(), entityState.version() ); + versions.rememberVersion( entityState.entityReference(), entityState.version() ); loaded.add( entityState ); return entityState; } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java index 96e4927..ee5d367 100755 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java @@ -24,6 +24,7 @@ import java.time.Instant; import java.util.HashMap; import org.apache.zest.api.entity.EntityDescriptor; import org.apache.zest.api.entity.EntityReference; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.structure.ModuleDescriptor; import org.apache.zest.api.usecase.Usecase; import org.apache.zest.spi.entity.EntityState; @@ -36,14 +37,14 @@ public final class DefaultEntityStoreUnitOfWork { private final ModuleDescriptor module; private EntityStoreSPI entityStoreSPI; - private String identity; + private Identity identity; private HashMap<EntityReference, EntityState> states = new HashMap<>(); private Usecase usecase; private Instant currentTime; public DefaultEntityStoreUnitOfWork( ModuleDescriptor module, EntityStoreSPI entityStoreSPI, - String identity, + Identity identity, Usecase usecase, Instant currentTime ) @@ -56,7 +57,7 @@ public final class DefaultEntityStoreUnitOfWork } @Override - public String identity() + public Identity identity() { return identity; } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityAlreadyExistsException.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityAlreadyExistsException.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityAlreadyExistsException.java index 7b450ab..dc36fec 100644 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityAlreadyExistsException.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityAlreadyExistsException.java @@ -27,17 +27,17 @@ import org.apache.zest.api.entity.EntityReference; public class EntityAlreadyExistsException extends EntityStoreException { - private EntityReference identity; + private EntityReference reference; - public EntityAlreadyExistsException( EntityReference identity ) + public EntityAlreadyExistsException( EntityReference reference) { - super("Entity " + identity + " already exists."); - this.identity = identity; + super("Entity " + reference + " already exists."); + this.reference = reference; } - public EntityReference identity() + public EntityReference reference() { - return identity; + return reference; } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityNotFoundException.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityNotFoundException.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityNotFoundException.java index 9fc3dee..0d50e38 100644 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityNotFoundException.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityNotFoundException.java @@ -27,16 +27,16 @@ import org.apache.zest.api.entity.EntityReference; public class EntityNotFoundException extends EntityStoreException { - private EntityReference identity; + private EntityReference reference; - public EntityNotFoundException( EntityReference identity ) + public EntityNotFoundException( EntityReference reference) { - super("Entity " + identity + " not found"); - this.identity = identity; + super("Entity " + reference + " not found"); + this.reference = reference; } - public EntityReference identity() + public EntityReference reference() { - return identity; + return reference; } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java index d1913b7..19f5d7b 100755 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java @@ -40,7 +40,7 @@ public interface EntityStateVersions { void forgetVersions( Iterable<EntityState> states ); - void rememberVersion( EntityReference identity, String version ); + void rememberVersion( EntityReference reference, String version ); void checkForConcurrentModification( Iterable<EntityState> loaded, Instant currentTime ) throws ConcurrentEntityStateModificationException; @@ -61,14 +61,14 @@ public interface EntityStateVersions { for( EntityState state : states ) { - versions.remove( state.identity() ); + versions.remove( state.entityReference() ); } } @Override - public synchronized void rememberVersion( EntityReference identity, String version ) + public synchronized void rememberVersion( EntityReference reference, String version ) { - versions.put( identity, version ); + versions.put( reference, version ); } @Override @@ -85,11 +85,11 @@ public interface EntityStateVersions continue; } - String storeVersion = versions.get( entityState.identity() ); + String storeVersion = versions.get( entityState.entityReference() ); if( storeVersion == null ) { EntityStoreUnitOfWork unitOfWork = store.newUnitOfWork( entityState.entityDescriptor().module(), Usecase.DEFAULT, currentTime ); - storeVersion = unitOfWork.versionOf( entityState.identity() ); + storeVersion = unitOfWork.versionOf( entityState.entityReference() ); unitOfWork.discard(); } @@ -99,7 +99,7 @@ public interface EntityStateVersions { changed = new ArrayList<>(); } - changed.add( entityState.identity() ); + changed.add( entityState.entityReference() ); } } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java index ab45f9c..cce09f5 100755 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreSPI.java @@ -31,12 +31,12 @@ import org.apache.zest.spi.entity.EntityState; public interface EntityStoreSPI { EntityState newEntityState( EntityStoreUnitOfWork unitOfWork, - EntityReference identity, EntityDescriptor entityDescriptor + EntityReference reference, EntityDescriptor entityDescriptor ); - EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleDescriptor module, EntityReference identity ); + EntityState entityStateOf( EntityStoreUnitOfWork unitOfWork, ModuleDescriptor module, EntityReference reference ); - String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference identity ); + String versionOf( EntityStoreUnitOfWork unitOfWork, EntityReference reference ); StateCommitter applyChanges( EntityStoreUnitOfWork unitOfWork, Iterable<EntityState> state ); } http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java index 5342327..b938937 100755 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java @@ -23,6 +23,7 @@ package org.apache.zest.spi.entitystore; import java.time.Instant; import org.apache.zest.api.entity.EntityDescriptor; import org.apache.zest.api.entity.EntityReference; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.structure.ModuleDescriptor; import org.apache.zest.api.usecase.Usecase; import org.apache.zest.spi.entity.EntityState; @@ -32,17 +33,17 @@ import org.apache.zest.spi.entity.EntityState; */ public interface EntityStoreUnitOfWork { - String identity(); + Identity identity(); Instant currentTime(); /** - * Create new EntityState for a given identity. + * Create new EntityState for a given reference. * <p> * This should only create the EntityState and not insert it into any database, since that should occur during * the {@link EntityStoreUnitOfWork#applyChanges()} call. * </p> - * @param anIdentity the identity of the entity + * @param anIdentity the reference of the entity * @param entityDescriptor entity descriptor * * @return The new entity state. @@ -53,14 +54,14 @@ public interface EntityStoreUnitOfWork throws EntityStoreException; /** - * Get the EntityState for a given identity. Throws {@link EntityNotFoundException} + * Get the EntityState for a given reference. Throws {@link EntityNotFoundException} * if the entity with given {@code anIdentity} is not found. * * * @param module - * @param anIdentity The entity identity. This argument must not be {@code null}. + * @param anIdentity The entity reference. This argument must not be {@code null}. * - * @return Entity state given the composite descriptor and identity. + * @return Entity state given the composite descriptor and reference. * * @throws EntityStoreException thrown if retrieval failed. * @throws EntityNotFoundException if requested entity does not exist http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java index 2827a93..b6faa12 100644 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java @@ -44,7 +44,7 @@ public final class DefaultEntityState private String version; private Instant lastModified; - private final EntityReference identity; + private final EntityReference reference; private final EntityDescriptor entityDescriptor; private final Map<QualifiedName, Object> properties; @@ -53,13 +53,13 @@ public final class DefaultEntityState private final Map<QualifiedName, Map<String, EntityReference>> namedAssociations; public DefaultEntityState( Instant currentTime, - EntityReference identity, + EntityReference reference, EntityDescriptor entityDescriptor ) { this( "", currentTime, - identity, + reference, EntityStatus.NEW, entityDescriptor, new HashMap<>(), @@ -70,7 +70,7 @@ public final class DefaultEntityState public DefaultEntityState( String version, Instant lastModified, - EntityReference identity, + EntityReference reference, EntityStatus status, EntityDescriptor entityDescriptor, Map<QualifiedName, Object> properties, @@ -81,7 +81,7 @@ public final class DefaultEntityState { this.version = version; this.lastModified = lastModified; - this.identity = identity; + this.reference = reference; this.status = status; this.entityDescriptor = entityDescriptor; this.properties = properties; @@ -104,9 +104,9 @@ public final class DefaultEntityState } @Override - public EntityReference identity() + public EntityReference entityReference() { - return identity; + return reference; } @Override @@ -241,7 +241,7 @@ public final class DefaultEntityState @Override public String toString() { - return identity + "(" + return reference + "(" + properties.size() + " properties, " + associations.size() + " associations, " + manyAssociations.size() + " many-associations, " http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java index 2878b76..9cf9e79 100644 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java @@ -23,6 +23,7 @@ import java.time.Instant; import org.apache.zest.api.common.QualifiedName; import org.apache.zest.api.entity.EntityDescriptor; import org.apache.zest.api.entity.EntityReference; +import org.apache.zest.api.identity.Identity; import org.apache.zest.api.property.PropertyDescriptor; import org.apache.zest.api.structure.ModuleDescriptor; import org.apache.zest.api.type.ValueType; @@ -56,7 +57,7 @@ public final class JSONEntityState private final ModuleDescriptor module; private final ValueSerialization valueSerialization; private final String version; - private final EntityReference identity; + private final EntityReference reference; private final EntityDescriptor entityDescriptor; private EntityStatus status; @@ -67,7 +68,7 @@ public final class JSONEntityState ValueSerialization valueSerialization, String version, Instant lastModified, - EntityReference identity, + EntityReference reference, EntityStatus status, EntityDescriptor entityDescriptor, JSONObject state @@ -77,7 +78,7 @@ public final class JSONEntityState this.valueSerialization = valueSerialization; this.version = version; this.lastModified = lastModified; - this.identity = identity; + this.reference = reference; this.status = status; this.entityDescriptor = entityDescriptor; this.state = state; @@ -97,9 +98,9 @@ public final class JSONEntityState } @Override - public EntityReference identity() + public EntityReference entityReference() { - return identity; + return reference; } @Override @@ -138,6 +139,10 @@ public final class JSONEntityState { jsonValue = newValue; } + else if( ValueType.isIdentity( newValue ) ) + { + jsonValue = newValue.toString(); + } else { String serialized = valueSerialization.serialize( newValue ); @@ -205,7 +210,7 @@ public final class JSONEntityState cloneStateIfGlobalStateLoaded(); state.getJSONObject( JSONKeys.ASSOCIATIONS ).put( stateName.name(), newEntity == null ? null - : newEntity.identity() ); + : newEntity.identity().toString() ); markUpdated(); } catch( JSONException e ) @@ -286,7 +291,7 @@ public final class JSONEntityState @Override public String toString() { - return identity + "(" + state + ")"; + return reference + "(" + state + ")"; } public void markUpdated() http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONKeys.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONKeys.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONKeys.java index 6d3151a..f23a64c 100644 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONKeys.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONKeys.java @@ -29,7 +29,7 @@ public interface JSONKeys /** * Identity of the entity. */ - String IDENTITY = "identity"; + String IDENTITY = "reference"; /** * Version of the application which last updated the entity. */ http://git-wip-us.apache.org/repos/asf/zest-java/blob/103c59cb/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationState.java ---------------------------------------------------------------------- diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationState.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationState.java index 4233274..7e669f0 100644 --- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationState.java +++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationState.java @@ -53,7 +53,7 @@ public final class JSONManyAssociationState @Override public boolean contains( EntityReference entityReference ) { - return indexOfReference( entityReference.identity() ) != -1; + return indexOfReference( entityReference.toString() ) != -1; } @Override @@ -61,12 +61,12 @@ public final class JSONManyAssociationState { try { - if( indexOfReference( entityReference.identity() ) != -1 ) + if( indexOfReference( entityReference.identity().toString() ) != -1 ) { return false; } entityState.cloneStateIfGlobalStateLoaded(); - insertReference( idx, entityReference.identity() ); + insertReference( idx, entityReference.identity().toString() ); entityState.markUpdated(); return true; } @@ -79,7 +79,7 @@ public final class JSONManyAssociationState @Override public boolean remove( EntityReference entityReference ) { - int refIndex = indexOfReference( entityReference.identity() ); + int refIndex = indexOfReference( entityReference.identity().toString() ); if( refIndex != -1 ) { entityState.cloneStateIfGlobalStateLoaded(); @@ -95,7 +95,7 @@ public final class JSONManyAssociationState { try { - return new EntityReference( references.getString( i ) ); + return EntityReference.parseEntityReference( references.getString( i ) ); } catch( JSONException e ) { @@ -121,7 +121,7 @@ public final class JSONManyAssociationState { try { - EntityReference ref = new EntityReference( references.getString( idx ) ); + EntityReference ref = EntityReference.parseEntityReference( references.getString( idx ) ); idx++; return ref; } @@ -145,11 +145,11 @@ public final class JSONManyAssociationState return references.toString(); } - private int indexOfReference( Object item ) + private int indexOfReference( String enityIdentityAsString ) { for( int idx = 0; idx < references.length(); idx++ ) { - if( item.equals( references.opt( idx ) ) ) + if( enityIdentityAsString.equals( references.opt( idx ) ) ) { return idx; }
