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

io.crnk.jpa.query.querydsl.QuerydslQueryFactory Maven / Gradle / Ivy

There is a newer version: 2.6.20180522184741
Show newest version
package io.crnk.jpa.query.querydsl;

import io.crnk.jpa.internal.JpaQueryFactoryBase;
import io.crnk.jpa.internal.query.backend.querydsl.QuerydslQueryImpl;
import io.crnk.jpa.query.JpaQueryFactory;

import java.lang.reflect.Type;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class QuerydslQueryFactory extends JpaQueryFactoryBase implements JpaQueryFactory {

	private List interceptors = new CopyOnWriteArrayList<>();

	private QuerydslQueryFactory() {
	}

	public static QuerydslQueryFactory newInstance() {
		return new QuerydslQueryFactory();
	}

	public void addInterceptor(QuerydslTranslationInterceptor interceptor) {
		interceptors.add(interceptor);
	}

	@Override
	public  QuerydslQuery query(Class entityClass) {
		return new QuerydslQueryImpl<>(context.getMetaPartition(), em, entityClass, computedAttrs, interceptors);
	}

	@SuppressWarnings({"rawtypes", "unchecked"})
	@Override
	public  QuerydslQuery query(Class entityClass, String attrName, List entityIds) {
		return new QuerydslQueryImpl(context.getMetaPartition(), em, entityClass, computedAttrs, interceptors, attrName, entityIds);
	}

	public void registerComputedAttribute(Class targetClass, String attributeName, Type attributeType,
										  QuerydslExpressionFactory expressionFactory) {
		computedAttrs.register(targetClass, attributeName, expressionFactory, attributeType);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy