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

org.sfm.querydsl.TupleElementKey Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 1.10.3
Show newest version
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 + '\'' +
				'}';
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy