Class AbstractProjectableModel

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String NO_DRIVER  
      protected static java.lang.String NO_DRIVER_SERVICE  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <B extends Behaviour>
      B
      as​(java.lang.Class<B> projectionClass)
      Returns the specified projection of this entity if such projection is supported.
      protected DriverData asData()
      Returns self as an immutable driver data instance.
      protected void bindAndCheckDriver()
      Attempts to bind the driver, if not already bound and checks that the driver is bound.
      protected void bindDriver()
      Attempts to binds the driver, if not already bound.
      Driver driver()
      Returns the currently bound driver or null if no driver is bound.
      protected static DriverService driverService()
      Returns the currently bound driver service reference.
      <B extends Behaviour>
      boolean
      is​(java.lang.Class<B> projectionClass)
      Returns true if this entity is capable of being projected as the specified class.
      protected Driver locateDriver()
      Locates the driver to be used by this entity.
      static void setDriverService​(java.lang.Object key, DriverService driverService)
      Injects the driver service reference for use during projections into various behaviours.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractProjectableModel

        public AbstractProjectableModel()
      • AbstractProjectableModel

        public AbstractProjectableModel​(ProviderId providerId,
                                        Annotations[] annotations)
        Creates a model entity attributed to the specified provider and optionally annotated.
        Parameters:
        providerId - identity of the provider
        annotations - optional key/value annotations
    • Method Detail

      • setDriverService

        public static void setDriverService​(java.lang.Object key,
                                            DriverService driverService)
        Injects the driver service reference for use during projections into various behaviours.

        This is a privileged call; unauthorized invocations will result in illegal state exception

        Parameters:
        key - opaque admin key object
        driverService - injected driver service
        Throws:
        java.lang.IllegalStateException - when invoked sans authorization
      • driverService

        protected static DriverService driverService()
        Returns the currently bound driver service reference.
        Returns:
        driver service
      • driver

        public Driver driver()
        Returns the currently bound driver or null if no driver is bound.
        Returns:
        bound driver; null if none
      • as

        public <B extends Behaviour> B as​(java.lang.Class<B> projectionClass)
        Description copied from interface: Projectable
        Returns the specified projection of this entity if such projection is supported.
        Specified by:
        as in interface Projectable
        Type Parameters:
        B - type of behaviour
        Parameters:
        projectionClass - requested projection class
        Returns:
        projection instance
      • is

        public <B extends Behaviour> boolean is​(java.lang.Class<B> projectionClass)
        Description copied from interface: Projectable
        Returns true if this entity is capable of being projected as the specified class.
        Specified by:
        is in interface Projectable
        Type Parameters:
        B - type of behaviour
        Parameters:
        projectionClass - requested projection class
        Returns:
        true if the requested projection is supported
      • locateDriver

        protected Driver locateDriver()
        Locates the driver to be used by this entity.

        The default implementation derives the driver based on the driver annotation value.

        Returns:
        driver for alternate projections of this model entity or null if no driver is expected or driver is not found
      • bindDriver

        protected final void bindDriver()
        Attempts to binds the driver, if not already bound.
      • bindAndCheckDriver

        protected final void bindAndCheckDriver()
        Attempts to bind the driver, if not already bound and checks that the driver is bound.
        Throws:
        java.lang.IllegalStateException - if driver cannot be bound
      • asData

        protected DriverData asData()
        Returns self as an immutable driver data instance.
        Returns:
        self as driver data