[#3477] Add Field.as(Field) to rename a field to another field's name

This commit is contained in:
Lukas Eder 2014-07-29 14:50:10 +02:00
parent f865f9e72b
commit 14aa9bcbc8
2 changed files with 18 additions and 0 deletions

View File

@ -143,6 +143,19 @@ public interface Field<T> extends GroupField {
@Support
Field<T> as(String alias);
/**
* Create an alias for this field based on another field's name.
* <p>
* Note that the case-sensitivity of the returned field depends on
* {@link Settings#getRenderNameStyle()}. By default, field aliases are
* quoted, and thus case-sensitive!
*
* @param otherField The other field whose name this field is aliased with.
* @return The field alias.
*/
@Support
Field<T> as(Field<?> otherField);
/**
* {@inheritDoc}
* <p>

View File

@ -153,6 +153,11 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
return new FieldAlias<T>(this, alias);
}
@Override
public final Field<T> as(Field<?> otherField) {
return as(otherField.getName());
}
@Override
public final String getName() {
return name;