[#3477] Add Field.as(Field) to rename a field to another field's name
This commit is contained in:
parent
f865f9e72b
commit
14aa9bcbc8
@ -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>
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user