Interface Projection<T>
- Type Parameters:
T
- The type of the original domain class describing the data available in this projection.
- All Superinterfaces:
ReferenceAware<T>
,Serializable
Represents a projection class mapping to a persisted domain class. This is usually implemented
concretely (especially during projection auto-generation) with additional fields describing
interesting attributes of the persisted domain (or synthetic attributes) incoming and outgoing
from the service API.
- Author:
- Jeff Fischer
-
Method Summary
Modifier and TypeMethodDescriptiondefault <H> H
as()
Convenience method for casting a Projection instance to a supertype of implemented interface.static <H> List<H>
Convenience method for casting to/from List whose generic type is a superclass of the projection to/from a List typed to this projection type.static <H> Set<H>
Convenience method for casting to/from Set whose generic type is a superclass of the projection to/from a Set typed to this projection type.static <H> org.springframework.data.domain.Page<H>
cast
(org.springframework.data.domain.Page<?> page) Convenience method for casting to/from Page whose generic type is a superclass of the projection to/from a Page typed to this projection type.default T
expose()
Projections are generated automatically by the system at runtime based on the related domain class.static <H extends Projection<?>>
HConvenience method for casting to a Projection instance from a supertype.static <T> Projection<T>
RetrieveProjection
instance referencing the persistence domain class type.static <T> Projection<T>
RetrieveProjection
instance referencing the persistence domain class type.getId()
Projections are expected to have an id field as a first class citizen.void
Projections are expected to have an id field as a first class citizen.Methods inherited from interface com.broadleafcommerce.common.extension.projection.ReferenceAware
getProjectionReference
-
Method Details
-
get
RetrieveProjection
instance referencing the persistence domain class type. SeeProjectionFactory
for more information on dynamic projections.- Type Parameters:
T
- The persistence domain class type- Parameters:
from
- The persistence domain class the projection instances references- Returns:
- The instantiated instance implementing Projection.
-
get
RetrieveProjection
instance referencing the persistence domain class type. SeeProjectionFactory
for more information on dynamic projections.- Type Parameters:
T
- The persistence domain class type- Parameters:
from
- The persistence domain class the projection instances referencesid
- The id value to set on the projection instance (seegetId()
)- Returns:
- The instantiated instance implementing Projection.
-
from
Convenience method for casting to a Projection instance from a supertype.- Type Parameters:
H
- The return type expected by the calling context- Returns:
- The object to cast to the projection type
-
cast
@Nullable static <H> org.springframework.data.domain.Page<H> cast(@Nullable org.springframework.data.domain.Page<?> page) Convenience method for casting to/from Page whose generic type is a superclass of the projection to/from a Page typed to this projection type.- Type Parameters:
H
- The return type expected by the calling context- Parameters:
page
- The projection or superclass typed Page instance- Returns:
- The Page instance cast to the type expected by the caller
-
cast
Convenience method for casting to/from List whose generic type is a superclass of the projection to/from a List typed to this projection type.- Type Parameters:
H
- The return type expected by the calling context- Parameters:
list
- The projection or superclass typed List instance- Returns:
- The List instance cast to the type expected by the caller
-
cast
Convenience method for casting to/from Set whose generic type is a superclass of the projection to/from a Set typed to this projection type.- Type Parameters:
H
- The return type expected by the calling context- Parameters:
set
- The projection or superclass typed Set instance- Returns:
- The Set instance cast to the type expected by the caller
-
getId
String getId()Projections are expected to have an id field as a first class citizen. For projections related to Trackable domain, this id will relate to the contextId field.- Returns:
- The identification field reported for the related domain class
-
setId
Projections are expected to have an id field as a first class citizen. For projections related to Trackable domain, this id will relate to the contextId field.- Parameters:
id
- The identification field reported for the related domain class
-
expose
Projections are generated automatically by the system at runtime based on the related domain class. As such, the API internally exposed on the projection is similar to the related domain class API. This method provides exposure of the domain class API, but invocations are instead transparently invoked against the projection instance. SeeInvocationUtils
for more information on what is taking place behind the scenes.- Returns:
- An instance of this projection callable from the API of
<T>
.
-
as
default <H> H as()Convenience method for casting a Projection instance to a supertype of implemented interface. This is useful when passing a projection to a business tier service that expects the supertype.- Type Parameters:
H
- The return type expected by the calling context- Returns:
- The projection cast to the return type expected by the calling context
-