All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gorm.tools.mango.MangoQueryCriteriaEvent.groovy Maven / Gradle / Ivy

/*
* Copyright 2019 Yak.Works - Licensed under the Apache License, Version 2.0 (the "License")
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
package gorm.tools.mango

import groovy.transform.CompileStatic

import org.springframework.context.ApplicationEvent
import org.springframework.core.ResolvableType
import org.springframework.core.ResolvableTypeProvider

//import org.springframework.core.GenericTypeResolver

/**
 * Event fired right before the criteriaMap and criteriaClosure are applied.
 * Allows to intercept and modify whats in the criteriaMap.
 */
@CompileStatic
class MangoQueryCriteriaEvent extends ApplicationEvent implements ResolvableTypeProvider {

    Class entityClass // the domain class this is for

    //MangoDetachedCriteria criteria

    MangoQueryCriteriaEvent(Class entityClass, MangoDetachedCriteria criteria) {
        super(criteria)
        this.entityClass = entityClass
        //this.criteria = criteria
    }

    MangoDetachedCriteria getMangoCriteria(){
        (MangoDetachedCriteria) getSource()
    }

    /**
     * done per the spring docs so that listeners can bind to the generic of the event.
     */
    @Override
    ResolvableType getResolvableType() {
        // return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forInstance(getEntity()))
        return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forClass(entityClass))
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy