Class ProjectionDryer<T extends Projection>

    • Constructor Detail

      • ProjectionDryer

        public ProjectionDryer()
    • Method Detail

      • addProperties

        protected abstract void addProperties​(Context<?> context,
                                              T t,
                                              Map<String,​Object> properties)
        Called when attempting to save the given projection. Implementations should store the settings they require to build the projection later during this method, and also call their super's method so that it can store its properties.
        context - the context this projection is a member of
        t - the projection to store properties for
        properties - a place to store the properties for a projection
      • instantiate

        protected abstract T instantiate​(Context<?> context,
                                         Map<String,​Object> properties)
        Should createa a Projection for the given context. Implementing classes do not have to add the created projection to the context, that will be done after calling this method.
        context - the context the projection will be a member of
        properties - the properties specified when saving the projection
        a created projection
      • handles

        public abstract boolean handles​(Class<?> type)
        This should return true if the implementation handles projections of the given type.
        type - the type of the projection
        if the implementation handles the given type
      • loadProperties

        protected void loadProperties​(Context<?> context,
                                      T proj,
                                      Map<String,​Object> properties)
        This handles loading of properties into the instantiated projection. Implementations should override this method and load their properties here. If the properties are loaded in their instantiate(Context, Map) method, then if a subclass overrides the instantiate method it will have to duplicate the property loading (or that loading will not be done).

        Implementations should call their super's #loadProperties(Context, T, Map) method so that all properties can be loaded.

        This implementation loads the projection as a context listener (if it originally one) and the context as a projection listener if it was. This then adds the projection to the context.

        context - the context the projection is a member of
        proj - the projection that was instantiated
        properties - the properties that should be used to loaded into the projection
      • getProperties

        public Map<String,​Object> getProperties​(Context<?> context,
                                                      T t)
        Retrieves the serializable properties for a given projection that is a member of the given context. These properties should be reloaded and passed to the buildAndAddProjection(Context, Map) method when deserializing the projection.
        context - the context the projection is a member of
        t - the projection to serialize
        a Map of properties used to recreate the given projection
        See Also:
        for retrieving the dryer of the projection type
      • buildAndAddProjection

        public T buildAndAddProjection​(Context<?> context,
                                       Map<String,​Object> properties)
        Creates a projection based on the given properties. It will also add the created projection to the given context.

        context - the context to build a projection for
        properties - the properties for building the projection
        the created projection
      • addProjectionDryer

        public static void addProjectionDryer​(ProjectionDryer dryer)
        Adds a dryer to be used by the ContextFreezeDryer. This will be added to the front of the dryer list, so it will override any equivalent dryer added before it that dries the same class.
        dryer - a projection dryer
      • getDryer

        public static <T extends ProjectionProjectionDryer<T> getDryer​(Class<T> type)
        Retrieves the last added dryer that handles the given type. If none is found this returns null.
        type - the projection type to dry
        a dryer for the given type