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

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

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

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

import com.querydsl.core.Tuple;
import com.querydsl.core.types.Expression;

import io.katharsis.jpa.query.querydsl.QuerydslTuple;

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 = toArray();
		if(numEntriesToIgnore > 0){
			return Arrays.copyOfRange(data, numEntriesToIgnore, data.length - numEntriesToIgnore);
		}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