org.sfm.querydsl.TupleElementKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
package org.sfm.querydsl;
import com.mysema.query.types.Expression;
import com.mysema.query.types.Path;
import com.mysema.query.types.PathMetadata;
import com.mysema.query.types.PathType;
import org.sfm.map.MappingException;
import org.sfm.map.FieldKey;
public class TupleElementKey implements FieldKey {
private final Expression> expression;
private final int index;
private final String name;
public TupleElementKey(Expression> expression, int index) {
if (expression instanceof Path>) {
@SuppressWarnings("rawtypes")
PathMetadata> metadata = ((Path) expression).getMetadata();
if (metadata.getPathType() == PathType.PROPERTY) {
name = metadata.getElement().toString();
} else {
throw new MappingException("Unexpected expression " + expression);
}
} else {
throw new MappingException("Unexpected expression " + expression);
}
this.expression = expression;
this.index = index;
}
public Expression> getExpression() {
return expression;
}
public int getIndex() {
return index;
}
@Override
public String getName() {
return name;
}
@Override
public TupleElementKey alias(String alias) {
throw new UnsupportedOperationException();
}
@Override
public String toString() {
return "TupleElementKey{" +
"expression=" + expression +
", index=" + index +
", name='" + name + '\'' +
'}';
}
}