Package it.tidalwave.util.spi
Class PriorityAsSupport
- java.lang.Object
-
- it.tidalwave.util.spi.AsSupport
-
- it.tidalwave.util.spi.PriorityAsSupport
-
- All Implemented Interfaces:
it.tidalwave.util.As
public class PriorityAsSupport extends it.tidalwave.util.spi.AsSupport implements it.tidalwave.util.AsA specialisation ofAsSupportthat deals with multiple roles of the same type by prioritising them; they are ordered from most relevant to least relevant (where relevance is associated to specialisation, that is most specialised roles, or roles associated via@DciRoleto most specialised datum classes, are most relevant). FIXME: could be seen as a replacement toAsSupport?- Author:
- Fabrizio Giudici
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePriorityAsSupport.RoleProvider
-
Constructor Summary
Constructors Constructor Description PriorityAsSupport(java.lang.Object owner)PriorityAsSupport(java.lang.Object owner, PriorityAsSupport.RoleProvider additionalRoleProvider, java.util.Collection<java.lang.Object> rolesOrFactories)PriorityAsSupport(java.lang.Object owner, java.util.Collection<java.lang.Object> rolesOrFactories)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tas(java.lang.Class<T> type)Returned roles can be associated both to this type and to the delegate; the one with the higher priority is returned.<T> Tas(java.lang.Class<T> type, it.tidalwave.util.As.NotFoundBehaviour<T> notFoundBehaviour)Returned roles can be associated both to this type and to the delegate; the one with the higher priority is returned.<T> java.util.Collection<T>asMany(java.lang.Class<T> type)Returned roles can be associated both to this type and to the delegate; the one with the higher priority is returned.<T> java.util.Optional<T>maybeAs(java.lang.Class<T> type)Returned roles can be associated both to this type and to the delegate; the one with the higher priority is returned.
-
-
-
Constructor Detail
-
PriorityAsSupport
public PriorityAsSupport(java.lang.Object owner)
-
PriorityAsSupport
public PriorityAsSupport(@Nonnull java.lang.Object owner, @Nonnull java.util.Collection<java.lang.Object> rolesOrFactories)
-
PriorityAsSupport
public PriorityAsSupport(@Nonnull java.lang.Object owner, @Nonnull PriorityAsSupport.RoleProvider additionalRoleProvider, @Nonnull java.util.Collection<java.lang.Object> rolesOrFactories)
-
-
Method Detail
-
as
@Nonnull public <T> T as(@Nonnull java.lang.Class<T> type)Returned roles can be associated both to this type and to the delegate; the one with the higher priority is returned. SeeasMany(java.lang.Class)for further details.- Specified by:
asin interfaceit.tidalwave.util.As- Overrides:
asin classit.tidalwave.util.spi.AsSupport- See Also:
asMany(java.lang.Class)
-
as
@Nonnull public <T> T as(@Nonnull java.lang.Class<T> type, @Nonnull it.tidalwave.util.As.NotFoundBehaviour<T> notFoundBehaviour)Returned roles can be associated both to this type and to the delegate; the one with the higher priority is returned. SeeasMany(java.lang.Class)for further details.- Specified by:
asin interfaceit.tidalwave.util.As- Overrides:
asin classit.tidalwave.util.spi.AsSupport- See Also:
asMany(java.lang.Class)
-
maybeAs
@Nonnull public <T> java.util.Optional<T> maybeAs(@Nonnull java.lang.Class<T> type)Returned roles can be associated both to this type and to the delegate; the one with the higher priority is returned. SeeasMany(java.lang.Class)for further details.- Specified by:
maybeAsin interfaceit.tidalwave.util.As- See Also:
asMany(java.lang.Class)
-
asMany
@Nonnull public <T> java.util.Collection<T> asMany(@Nonnull java.lang.Class<T> type)Returned roles can be associated both to this type and to the delegate; the one with the higher priority is returned. The ones associated to this type come with higher priority (this makes sense, being this class a decorator, specific roles could be associated to it). But given that the default implementation of asMany() doesn't guarantee ant order (see TFT-192) there's something to take care of. Currently this method contains some hardwired priority logics.- Specified by:
asManyin interfaceit.tidalwave.util.As- Overrides:
asManyin classit.tidalwave.util.spi.AsSupport
-
-