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

io.crnk.jpa.internal.query.backend.querydsl.QuerydslTupleImpl Maven / Gradle / Ivy

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

import com.querydsl.core.Tuple;
import com.querydsl.core.types.Expression;
import io.crnk.jpa.query.querydsl.QuerydslTuple;

import java.util.Arrays;
import java.util.Map;

public class QuerydslTupleImpl implements QuerydslTuple {

	private Tuple tuple;

	private Map selectionBindings;

	private int numEntriesToIgnore;

	public QuerydslTupleImpl(Tuple tuple, Map selectionBindings) {
		this.tuple = tuple;
		this.selectionBindings = selectionBindings;
	}

	@Override
	public  T get(int index, Class type) {
		return tuple.get(index + numEntriesToIgnore, type);
	}

	@Override
	public  T get(Expression expr) {
		return tuple.get(expr);
	}

	@Override
	public int size() {
		return tuple.size() - numEntriesToIgnore;
	}

	@Override
	public Object[] toArray() {
		Object[] data = tuple.toArray();
		if (numEntriesToIgnore > 0) {
			return Arrays.copyOfRange(data, numEntriesToIgnore, data.length);
		} else {
			return data;
		}
	}

	@Override
	public  T get(String name, Class clazz) {
		Integer index = selectionBindings.get(name);
		if (index == null) {
			throw new IllegalArgumentException("selection " + name + " not found");
		}
		return get(index.intValue(), clazz);
	}

	@Override
	public void reduce(int numEntriesToIgnore) {
		this.numEntriesToIgnore = numEntriesToIgnore;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy