public interface As
Objects implementing this interface can provide am adapter of the required type. The adapter can be found with a
variety of approaches that depend on the implementation. This capability can be used to implement a design based
on the Data, Context and Interaction pattern (DCI). For further details, please look at the
project website, where a tutorial is available.
- Author:
- Fabrizio Giudici
- Status: stable API
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault <T> TReturns a role for this object of the specified type.default <T> TReturns an adapter to this object of the specified type.default <T> Collection<T> Returns the requested role or an emptyOptional.<T> Collection<T> Searches for multiple adapters of the given type and returns them.static AsCreates anAsimplementation delegate for the given object (or returns the object itself if it is the default implementation ofAs).static AsCreates anAsimplementation delegate for the given object.static AsforObject(Object object, Collection<Object> roles) Creates anAsimplementation delegate for the given object.default <T> Optional<T> Returns the requested role or an emptyOptional.<T> Optional<T> Returns the requested role or an emptyOptional.static <T> As.Type<T> Creates a role type reference.
-
Method Details
-
forObject
Creates anAsimplementation delegate for the given object (or returns the object itself if it is the default implementation ofAs).- Parameters:
object- the object- Returns:
- the implementation
- Since:
- 3.2-ALPHA-12
-
forObject
Creates anAsimplementation delegate for the given object. It accepts a single pre-instantiated role, or aRoleFactorythat will be invoked to create additional roles.- Parameters:
object- the objectrole- the role orRoleFactory- Returns:
- the implementation
- Since:
- 3.2-ALPHA-13
-
forObject
Creates anAsimplementation delegate for the given object. It accepts a collection of pre-instantiated roles, or instances ofRoleFactorythat will be invoked to create additional roles.- Parameters:
object- the objectroles- roles orRoleFactoryinstances- Returns:
- the implementation
- Since:
- 3.2-ALPHA-13
-
as
Returns an adapter to this object of the specified type. If the implementation can find multiple compliant adapters, only one will be returned.- Type Parameters:
T- the static type- Parameters:
type- the dynamic type- Returns:
- the adapter
- Throws:
AsException- if no adapter is found
-
maybeAs
Returns the requested role or an emptyOptional.- Type Parameters:
T- the static type- Parameters:
type- the dynamic type- Returns:
- the optional role
- Since:
- 3.2-ALPHA-3
-
asMany
Searches for multiple adapters of the given type and returns them.- Type Parameters:
T- the static type- Parameters:
type- the dynamic type- Returns:
- a collection of adapters, possibly empty
-
type
Creates a role type reference.- Type Parameters:
T- the static type- Parameters:
type- the dynamic type- Returns:
- the type reference
- Since:
- 3.2-ALPHA-12
-
as
Returns a role for this object of the specified type. If the implementation can find multiple compliant roles, only one will be returned.- Type Parameters:
T- the static type- Parameters:
type- the type reference- Returns:
- the role
- Since:
- 3.2-ALPHA-12
-
maybeAs
Returns the requested role or an emptyOptional.- Type Parameters:
T- the static type- Parameters:
type- the type reference- Returns:
- the optional role
- Since:
- 3.2-ALPHA-12
-
asMany
Returns the requested role or an emptyOptional.- Type Parameters:
T- the static type- Parameters:
type- the type reference- Returns:
- the roles
- Since:
- 3.2-ALPHA-12
-