org.jinq.jpa.transform.ScalaMethodChecker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jinq-jpa-scala Show documentation
Show all versions of jinq-jpa-scala Show documentation
Scala version of Jinq's functional-style queries for JPA
package org.jinq.jpa.transform;
import java.util.List;
import java.util.Set;
import scala.Function1;
import scala.Function2;
import ch.epfl.labos.iu.orm.queryll2.symbolic.MethodSignature;
import ch.epfl.labos.iu.orm.queryll2.symbolic.TypedValue;
import ch.epfl.labos.iu.orm.queryll2.symbolic.BasicSymbolicInterpreter.OperationSideEffect;
public class ScalaMethodChecker extends MethodChecker
{
ScalaMethodChecker(Set> safeMethodAnnotations,
Set safeMethods,
Set safeStaticMethods,
boolean isObjectEqualsSafe, boolean isCollectionContainsSafe)
{
super(safeMethodAnnotations, safeMethods, safeStaticMethods, isObjectEqualsSafe, isCollectionContainsSafe);
}
@Override
public OperationSideEffect isMethodSafe(MethodSignature m, TypedValue base,
List args)
{
OperationSideEffect effect = super.isMethodSafe(m, base, args);
if (effect != OperationSideEffect.UNSAFE)
return effect;
try
{
Class> c = Class.forName(m.getOwnerType().getClassName());
if ("".equals(m.name) &&
(Function1.class.isAssignableFrom(c) || Function2.class.isAssignableFrom(c)) )
return OperationSideEffect.SAFE;
} catch (ClassNotFoundException e)
{
// We could not analyze the method, so we can't figure out if it's safe
return OperationSideEffect.UNSAFE;
}
return effect;
}
@Override
public boolean isPutFieldAllowed()
{
return true;
}
@Override
public boolean isFluentChaining(MethodSignature sig)
{
if (ScalaMetamodelUtil.STRINGBUILDER_APPEND.equals(sig)) return true;
return super.isFluentChaining(sig);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy