Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADQL] make LanguageFeature type comparisons case-insensitive #147

Open
wants to merge 1 commit into
base: adql2.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/adql/parser/feature/LanguageFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private LanguageFeature(final String type, final String form, final FunctionDef
throw new NullPointerException("Missing form/name of the language feature to create!");
this.form = form.trim();

if (TYPE_UDF.equals(this.type) && udfDef == null)
if (TYPE_UDF.equalsIgnoreCase(this.type) && udfDef == null)
throw new NullPointerException("Missing UDF definition! To declare a UDF feature, you MUST use the constructor LanguageFeature(FunctionDef, ...) with a non-NULL FunctionDef instance.");
this.udfDefinition = udfDef;

Expand All @@ -270,12 +270,12 @@ private LanguageFeature(final String type, final String form, final FunctionDef
public boolean equals(final Object obj) {
if ((obj != null) && (obj instanceof LanguageFeature)) {
// If UDF, equals IF SAME NAME and SAME NB PARAMETERS:
if (TYPE_UDF.equals(type) && type.equals(((LanguageFeature)obj).type)) {
if (TYPE_UDF.equalsIgnoreCase(type) && type.equalsIgnoreCase(((LanguageFeature)obj).type)) {
FunctionDef udfDefinition2 = ((LanguageFeature)obj).udfDefinition;
return udfDefinition.name.equalsIgnoreCase(udfDefinition2.name) && (udfDefinition.nbParams == udfDefinition2.nbParams);
}
// Otherwise, equals IF SAME ID:
else if (id.equals(((LanguageFeature)obj).id))
else if (id.equalsIgnoreCase(((LanguageFeature)obj).id))
return true;
}
return false;
Expand All @@ -284,9 +284,9 @@ else if (id.equals(((LanguageFeature)obj).id))
@Override
public int hashCode() {
if (udfDefinition != null)
return Objects.hash(type, udfDefinition.name.toLowerCase(), udfDefinition.nbParams);
return Objects.hash(type == null ? null : type.toLowerCase(), udfDefinition.name.toLowerCase(), udfDefinition.nbParams);
else
return Objects.hash(type, form, -1);
return Objects.hash(type == null ? null : type.toLowerCase(), form, -1);
}

@Override
Expand Down
6 changes: 6 additions & 0 deletions test/adql/parser/feature/TestLanguageFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ public void testEquals() {
// the test order does not matter:
assertTrue(feat2.equals(feat1));

// CASE: equality test with differing capitalisation of type
LanguageFeature feat3 = new LanguageFeature("ivo://stuff", "bar");
LanguageFeature feat4 = new LanguageFeature("ivo://Stuff", "bar");
assertTrue(feat3.equals(feat4));
assertTrue(feat4.equals(feat3));

try {

// CASE: equality test between 2 UDFs with a different name => false
Expand Down