Introduce a new method, getDefaultName(), so that null alias logic
doesn't happen in the constructor. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@981618 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -23,7 +23,7 @@ public final class FieldDef extends Atom {
|
||||
private final StaticValue value;
|
||||
|
||||
public FieldDef(StaticValue value, String alias) {
|
||||
this.alias = alias == null ? value.getDefaultName() : alias;
|
||||
this.alias = alias;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@ public final class FieldDef extends Atom {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public String getDefaultName() {
|
||||
return alias == null ? value.getDefaultName() : alias;
|
||||
}
|
||||
|
||||
public StaticValue getValue() {
|
||||
return value;
|
||||
}
|
||||
@@ -38,7 +42,7 @@ public final class FieldDef extends Atom {
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof FieldDef) {
|
||||
FieldDef other = (FieldDef) o;
|
||||
return alias.equals(other.alias) && value.equals(other.value);
|
||||
return equalsHelper(alias, other.alias) && value.equals(other.value);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -46,7 +50,7 @@ public final class FieldDef extends Atom {
|
||||
|
||||
public StringBuilder appendTo(StringBuilder sb) {
|
||||
value.appendTo(sb);
|
||||
if (!equalsHelper(value.getDefaultName(), alias)) {
|
||||
if (alias != null) {
|
||||
sb.append(" AS ").append(alias);
|
||||
}
|
||||
return sb;
|
||||
|
||||
@@ -513,8 +513,8 @@ private void SelectField(Map<String, FieldDef> fieldDefs, List<FieldAll> fieldAl
|
||||
fieldAlls.add(fieldAll); return;
|
||||
}
|
||||
| fieldDef=FieldDef() {
|
||||
if (fieldDefs.containsKey(fieldDef.getAlias())) throw new ParseException("duplicate alias(" + fieldDef.getAlias() + ")");
|
||||
fieldDefs.put(fieldDef.getAlias(), fieldDef);
|
||||
if (fieldDefs.containsKey(fieldDef.getDefaultName())) throw new ParseException("duplicate alias(" + fieldDef.getDefaultName() + ")");
|
||||
fieldDefs.put(fieldDef.getDefaultName(), fieldDef);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user