Package com.github.jmkgreen.morphia.mapping.validation.fieldrules

Source Code of com.github.jmkgreen.morphia.mapping.validation.fieldrules.LazyReferenceMissingDependencies

/**
*
*/
package com.github.jmkgreen.morphia.mapping.validation.fieldrules;

import com.github.jmkgreen.morphia.annotations.Reference;
import com.github.jmkgreen.morphia.mapping.MappedClass;
import com.github.jmkgreen.morphia.mapping.MappedField;
import com.github.jmkgreen.morphia.mapping.lazy.LazyFeatureDependencies;
import com.github.jmkgreen.morphia.mapping.validation.ConstraintViolation;
import com.github.jmkgreen.morphia.mapping.validation.ConstraintViolation.Level;
import java.util.Set;

/**
* @author Uwe Schaefer, (us@thomas-daily.de)
*/
public class LazyReferenceMissingDependencies extends FieldConstraint {

    @Override
    protected void check(MappedClass mc, MappedField mf, Set<ConstraintViolation> ve) {
        Reference ref = mf.getAnnotation(Reference.class);
        if (ref != null) {
            if (ref.lazy()) {
                if (!LazyFeatureDependencies.testDependencyFullFilled())
                    ve.add(new ConstraintViolation(Level.SEVERE, mc, mf, this.getClass(),
                            "Lazy references need CGLib and Proxytoys in the classpath."));
            }
        }
    }

}
TOP

Related Classes of com.github.jmkgreen.morphia.mapping.validation.fieldrules.LazyReferenceMissingDependencies

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.