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 Detail

      • 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.
      • 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>.