Skip to content

Commit

Permalink
Merge pull request #23 from MeasureAuthoringTool/MAT-7963_DropDownLis…
Browse files Browse the repository at this point in the history
…tOfDependencies

Mat 7963 drop down list of dependencies
  • Loading branch information
gregory-akins authored Dec 2, 2024
2 parents ee9d819 + 4ce636e commit 82703ed
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import java.util.Set;

import org.apache.commons.lang3.StringUtils;

@Data
@Builder
public class CqlBuilderLookup {
Expand All @@ -21,5 +23,20 @@ public static class Lookup {
private String libraryAlias;
private String logic;
private int startLine;

@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
CqlBuilderLookup.Lookup lookup = (CqlBuilderLookup.Lookup) o;

if (StringUtils.equals(lookup.getName(), this.getName())
&& StringUtils.equals(lookup.getLibraryAlias(), this.getLibraryAlias())
&& lookup.getLibraryName().equals(this.getLibraryName())) {
return true;
}
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package gov.cms.madie.cql_elm_translator.dto;

import java.util.Comparator;

import org.apache.commons.lang3.StringUtils;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CqlBuilderLookupComparator<T> implements Comparator<CqlBuilderLookup.Lookup> {

/***
* This is required because the name/line numbers can conflict between line
* numbers
*/
public int compare(CqlBuilderLookup.Lookup lookup1, CqlBuilderLookup.Lookup lookup2) {

int result;

if (StringUtils.equalsIgnoreCase(lookup1.getName(), lookup2.getName())
&& StringUtils.equalsIgnoreCase(lookup1.getLibraryAlias(), lookup2.getLibraryAlias())) {
result = 0;
} else if (lookup1.getStartLine() == lookup2.getStartLine()) {
// if the names are different but the lines are the same
result = lookup1.getStartLine() - lookup2.getStartLine() + 1;
} else {
result = lookup1.getStartLine() - lookup2.getStartLine();
}

return result;
}
}

0 comments on commit 82703ed

Please sign in to comment.