io.crnk.jpa.internal.query.backend.querydsl.QuerydslTupleImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of crnk-jpa Show documentation
Show all versions of crnk-jpa Show documentation
JSON API framework for Java
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