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

public interface Projection<T> extends Serializable, ReferenceAware<T>
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 Type
    Method
    Description
    default <H> H
    as()
    Convenience method for casting a Projection instance to a supertype of implemented interface.
    static <H> List<H>
    cast(List<?> list)
    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>
    cast(Set<?> set)
    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
    Projections are generated automatically by the system at runtime based on the related domain class.
    static <H extends Projection<?>>
    H
    from(Object val)
    Convenience method for casting to a Projection instance from a supertype.
    static <T> Projection<T>
    get(Class<T> from)
    Retrieve Projection instance referencing the persistence domain class type.
    static <T> Projection<T>
    get(Class<T> from, String id)
    Retrieve Projection instance referencing the persistence domain class type.
    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

      static <T> Projection<T> get(Class<T> from)
      Retrieve Projection instance referencing the persistence domain class type. See ProjectionFactory 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

      static <T> Projection<T> get(Class<T> from, String id)
      Retrieve Projection instance referencing the persistence domain class type. See ProjectionFactory for more information on dynamic projections.
      Type Parameters:
      T - The persistence domain class type
      Parameters:
      from - The persistence domain class the projection instances references
      id - The id value to set on the projection instance (see getId())
      Returns:
      The instantiated instance implementing Projection.
    • from

      @Nullable static <H extends Projection<?>> H from(@Nullable Object val)
      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

      @Nullable static <H> List<H> cast(@Nullable List<?> list)
      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

      @Nullable static <H> Set<H> cast(@Nullable Set<?> set)
      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

      void setId(String id)
      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

      default T 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. See InvocationUtils 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