Repository: zest-java Updated Branches: refs/heads/develop dc30f4b41 -> 31c28431c
runtime: minor changes to TypeLookup, mostly javadoc Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/31c28431 Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/31c28431 Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/31c28431 Branch: refs/heads/develop Commit: 31c28431c2a79bde20afac97745172893f43c364 Parents: dc30f4b Author: Paul Merlin <[email protected]> Authored: Wed Nov 30 11:42:50 2016 +0100 Committer: Paul Merlin <[email protected]> Committed: Wed Nov 30 11:42:50 2016 +0100 ---------------------------------------------------------------------- .../apache/zest/api/structure/TypeLookup.java | 22 +++-- .../zest/runtime/structure/TypeLookupImpl.java | 89 +------------------- 2 files changed, 17 insertions(+), 94 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/31c28431/core/api/src/main/java/org/apache/zest/api/structure/TypeLookup.java ---------------------------------------------------------------------- diff --git a/core/api/src/main/java/org/apache/zest/api/structure/TypeLookup.java b/core/api/src/main/java/org/apache/zest/api/structure/TypeLookup.java index 2ea55bf..332bb31 100644 --- a/core/api/src/main/java/org/apache/zest/api/structure/TypeLookup.java +++ b/core/api/src/main/java/org/apache/zest/api/structure/TypeLookup.java @@ -23,6 +23,7 @@ package org.apache.zest.api.structure; import java.lang.reflect.Type; import java.util.List; import java.util.stream.Stream; +import org.apache.zest.api.composite.AmbiguousTypeException; import org.apache.zest.api.composite.ModelDescriptor; import org.apache.zest.api.composite.TransientDescriptor; import org.apache.zest.api.entity.EntityDescriptor; @@ -45,8 +46,9 @@ public interface TypeLookup * @param type Looked up Type * * @return First matching Object Model + * @throws AmbiguousTypeException when a type ambiguity is found */ - ObjectDescriptor lookupObjectModel( Class<?> type ); + ObjectDescriptor lookupObjectModel( Class<?> type ) throws AmbiguousTypeException; /** * Lookup first Transient Model matching the given Type. @@ -62,8 +64,9 @@ public interface TypeLookup * @param type Looked up Type * * @return First matching Transient Model + * @throws AmbiguousTypeException when a type ambiguity is found */ - TransientDescriptor lookupTransientModel( Class<?> type ); + TransientDescriptor lookupTransientModel( Class<?> type ) throws AmbiguousTypeException; /** * Lookup first Value Model matching the given Type. @@ -79,8 +82,9 @@ public interface TypeLookup * @param type Looked up Type * * @return First matching Value Model + * @throws AmbiguousTypeException when a type ambiguity is found */ - ValueDescriptor lookupValueModel( Class<?> type ); + ValueDescriptor lookupValueModel( Class<?> type ) throws AmbiguousTypeException; /** * Lookup first Entity Model matching the given Type. @@ -99,8 +103,9 @@ public interface TypeLookup * @param type Looked up Type * * @return First matching Entity Model + * @throws AmbiguousTypeException when a type ambiguity is found */ - EntityDescriptor lookupEntityModel( Class<?> type ); + EntityDescriptor lookupEntityModel( Class<?> type ) throws AmbiguousTypeException; /** * Lookup all Entity Models matching the given Type. @@ -123,8 +128,9 @@ public interface TypeLookup * @param type Looked up Type * * @return All matching Entity Models + * @throws AmbiguousTypeException when a type ambiguity is found */ - List<EntityDescriptor> lookupEntityModels( Class<?> type ); + List<EntityDescriptor> lookupEntityModels( Class<?> type ) throws AmbiguousTypeException; /** * Lookup first ServiceDescriptor/ImportedServiceDescriptor matching the given Type. @@ -136,8 +142,9 @@ public interface TypeLookup * @param serviceType Looked up Type * * @return First matching Service + * @throws AmbiguousTypeException when a type ambiguity is found */ - ModelDescriptor lookupServiceModel( Type serviceType ); + ModelDescriptor lookupServiceModel( Type serviceType ) throws AmbiguousTypeException; /** * Lookup all ServiceDescriptors matching the given Type. @@ -157,8 +164,9 @@ public interface TypeLookup * @param type Looked up Type * * @return All matching ServiceReferences + * @throws AmbiguousTypeException when a type ambiguity is found */ - List<? extends ModelDescriptor> lookupServiceModels( Type type ); + List<? extends ModelDescriptor> lookupServiceModels( Type type ) throws AmbiguousTypeException; /** * @return All visible Objects, in visibility order http://git-wip-us.apache.org/repos/asf/zest-java/blob/31c28431/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java ---------------------------------------------------------------------- diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java index f3e8a4e..cd077b0 100644 --- a/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java +++ b/core/runtime/src/main/java/org/apache/zest/runtime/structure/TypeLookupImpl.java @@ -66,7 +66,7 @@ class TypeLookupImpl private final ModuleDescriptor moduleModel; /** - * Create a new TypeLookup bound to the given moduleModel. + * Create a new TypeLookup bound to the given ModuleModel. * * @param module ModuleModel bound to this TypeLookup */ @@ -89,21 +89,6 @@ class TypeLookupImpl servicesReferences = new ConcurrentHashMap<>(); } - /** - * Lookup first Object Model matching the given Type. - * - * <p>First, if Object Models exactly match the given type, the closest one (Visibility then Assembly order) is returned. - * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p> - * - * <p>Second, if Object Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned. - * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p> - * - * <p>Type lookup is done lazily and cached.</p> - * - * @param type Looked up Type - * - * @return First matching Object Model - */ @Override public ObjectDescriptor lookupObjectModel( final Class<?> type ) { @@ -119,21 +104,6 @@ class TypeLookupImpl } ); } - /** - * Lookup first Transient Model matching the given Type. - * - * <p>First, if Transient Models exactly match the given type, the closest one (Visibility then Assembly order) is returned. - * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p> - * - * <p>Second, if Transient Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned. - * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p> - * - * <p>Type lookup is done lazily and cached.</p> - * - * @param type Looked up Type - * - * @return First matching Transient Model - */ @Override public TransientDescriptor lookupTransientModel( final Class<?> type ) { @@ -149,21 +119,6 @@ class TypeLookupImpl } ); } - /** - * Lookup first Value Model matching the given Type. - * - * <p>First, if Value Models exactly match the given type, the closest one (Visibility then Assembly order) is returned. - * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p> - * - * <p>Second, if Value Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned. - * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p> - * - * <p>Type lookup is done lazily and cached.</p> - * - * @param type Looked up Type - * - * @return First matching Value Model - */ @Override public ValueDescriptor lookupValueModel( final Class<?> type ) { @@ -179,24 +134,6 @@ class TypeLookupImpl } ); } - /** - * Lookup first Entity Model matching the given Type. - * - * <p>First, if Entity Models exactly match the given type, the closest one (Visibility then Assembly order) is returned. - * Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p> - * - * <p>Second, if Entity Models match a type assignable to the given type, the closest one (Visibility then Assembly order) is returned. - * Multiple <b>assignable</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p> - * - * <p>Type lookup is done lazily and cached.</p> - * - * <p><b>Should be used for creational use cases only.</b> For non-creational use cases see - * {@link #lookupEntityModels(java.lang.Class)}.</p> - * - * @param type Looked up Type - * - * @return First matching Entity Model - */ @Override public EntityDescriptor lookupEntityModel( final Class<?> type ) { @@ -212,28 +149,6 @@ class TypeLookupImpl } ); } - /** - * Lookup all Entity Models matching the given Type. - * - * <p>Returned Iterable contains, in order, Entity Models that: </p> - * - * <ul> - * <li>exactly match the given type, in Visibility then Assembly order ;</li> - * <li>match a type assignable to the given type, in Visibility then Assembly order.</li> - * </ul> - * - * <p>Multiple <b>exact</b> matches with the same Visibility are <b>forbidden</b> and result in an AmbiguousTypeException.</p> - * <p>Multiple <b>assignable</b> matches are <b>allowed</b> to enable polymorphic fetches and queries.</p> - * - * <p>Type lookup is done lazily and cached.</p> - * - * <p><b>Should be used for non-creational use cases only.</b> For creational use cases see - * {@link #lookupEntityModel(java.lang.Class)}.</p> - * - * @param type Looked up Type - * - * @return All matching Entity Models - */ @Override public List<EntityDescriptor> lookupEntityModels( final Class type ) { @@ -368,7 +283,7 @@ class TypeLookupImpl return getAllServices().stream(); } - public List<? extends ModelDescriptor> getAllServices() + private List<? extends ModelDescriptor> getAllServices() { return allServices.computeIfAbsent( () -> concat(
