Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Gary O'Neall <[email protected]>
  • Loading branch information
goneall committed Dec 16, 2023
1 parent dacb5ef commit a1803eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
import org.spdx.licenseTemplate.LicenseTemplateRule;

/**
* @deprecated The <code>TemplateRegexMatcher</code> class should be used in place of this class. This class will be removed in the next major release.
*
* Filter the template output to create a list of strings filtering out optional and/or var text
* @author Gary O'Neall
*
*/
@Deprecated
public class FilterTemplateOutputHandler implements ILicenseTemplateOutputHandler {

public static final String REGEX_ESCAPE = "~~~";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
* @author Gary O'Neall
*
*/
@SuppressWarnings("deprecation")
public class LicenseCompareHelper {

static final Logger logger = LoggerFactory.getLogger(LicenseCompareHelper.class);
Expand Down Expand Up @@ -638,6 +639,7 @@ private static boolean isLicenseSetsEqual(LicenseSet license1, LicenseSet licens
}

/**
* @deprecated The <code>TemplateRegexMatcher</code> class should be used in place of this method. This method will be removed in the next major release.
* Get the text of a license minus any optional text - note: this include the default variable text
* @param licenseTemplate license template containing optional and var tags
* @param includeVarText if true, include the default variable text; if false remove the variable text
Expand Down Expand Up @@ -685,6 +687,7 @@ public static List<String> getNonOptionalLicenseText(String licenseTemplate,
}

/**
* @deprecated The <code>TemplateRegexMatcher</code> class should be used in place of this method. This method will be removed in the next major release.
* Creates a regular expression pattern to match the start of a license text
* This method should be replaced by the <code>TemplateRegexMatcher</code> class and methods
* @param nonOptionalText List of strings of non-optional text from the license template (see {@literal List<String> getNonOptionalLicenseText})
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/spdx/utility/compare/TemplateRegexMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public class TemplateRegexMatcher implements ILicenseTemplateOutputHandler {

static final String REGEX_GLOBAL_MODIFIERS = "(?im)"; // ignore case and muti-line

static abstract class RegexElement {
interface RegexElement {
}

static class RegexList extends RegexElement {
static class RegexList implements RegexElement {
private List<RegexElement> elements = new ArrayList<>();

public void addElement(RegexElement element) {
Expand Down Expand Up @@ -92,7 +92,7 @@ public String toString() {
}
}

static class RegexToken extends RegexElement {
static class RegexToken implements RegexElement {
private String token;

public RegexToken(String token) {
Expand All @@ -111,7 +111,7 @@ public String toString() {
}
}

static class RegexPattern extends RegexElement {
static class RegexPattern implements RegexElement {
private String pattern;

public RegexPattern(String pattern) {
Expand Down Expand Up @@ -194,7 +194,7 @@ public String getStartRegex(int wordLimit) {
}
}
// Need to check if the string starts with a greedy regex and change to non-greedy
if (result.getElements().size() > 0) {
if (!result.getElements().isEmpty()) {
RegexElement firstElement = result.getElements().get(0);
if (firstElement instanceof RegexPattern) {
String pattern = ((RegexPattern)firstElement).pattern;
Expand Down Expand Up @@ -248,7 +248,7 @@ public boolean isTemplateMatchWithinText(String text) throws SpdxCompareExceptio
* @return the text matching the beginning and end regular expressions for the template. Null if there is no match.
* @throws SpdxCompareException
*/
private @Nullable String findTemplateWithinText(String text) throws SpdxCompareException {
private @Nullable String findTemplateWithinText(String text) {
// Get match status
String result = null;
int startIndex = -1;
Expand Down

0 comments on commit a1803eb

Please sign in to comment.