-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement identifier hiding detection for String literals. Includes s…
…ome minor refactoring for the overall identifier hiding solution.
- Loading branch information
1 parent
9d92e5b
commit 8e8aec0
Showing
6 changed files
with
180 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/HidingIdentifierContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.cqframework.cql.cql2elm; | ||
|
||
import org.cqframework.cql.elm.tracking.Trackable; | ||
|
||
import java.util.Objects; | ||
import java.util.StringJoiner; | ||
|
||
/** | ||
* Simple POJO using for identifier hider that maintains the identifier and Trackable type of the construct being evaluated. | ||
*/ | ||
public class HidingIdentifierContext { | ||
private final String identifier; | ||
private final Class<? extends Trackable> elementSubclass; | ||
|
||
public HidingIdentifierContext(String theIdentifier, Class<? extends Trackable> theElementSubclass) { | ||
identifier = theIdentifier; | ||
elementSubclass = theElementSubclass; | ||
} | ||
|
||
public String getIdentifier() { | ||
return identifier; | ||
} | ||
|
||
public Class<? extends Trackable> getTrackableSubclass() { | ||
return elementSubclass; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object theO) { | ||
if (this == theO) { | ||
return true; | ||
} | ||
if (theO == null || getClass() != theO.getClass()) { | ||
return false; | ||
} | ||
HidingIdentifierContext that = (HidingIdentifierContext) theO; | ||
return Objects.equals(identifier, that.identifier) && Objects.equals(elementSubclass, that.elementSubclass); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(identifier, elementSubclass); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new StringJoiner(", ", HidingIdentifierContext.class.getSimpleName() + "[", "]") | ||
.add("identifier='" + identifier + "'") | ||
.add("elementSubclass=" + elementSubclass) | ||
.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.