-
-
Save rowillia/248c1b1eaa70b00dc788 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package infer_test; | |
public class Test { | |
public static final String[] PREFIXES = {"A", "B"}; | |
private String currentValue; | |
private String newerValue; | |
private static class Strings { | |
public static boolean isNullOrBlank(String string) { | |
return string == null || string.trim().length() == 0; | |
} | |
public static boolean hasAnyPrefix(String newerValue, String... prefixes) { | |
if (newerValue == null) { | |
return false; | |
} | |
for (String prefix : prefixes) { | |
if (newerValue.startsWith(prefix)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
} | |
public String getValue() { | |
if (Strings.isNullOrBlank(currentValue) && !Strings.isNullOrBlank(newerValue)) { | |
if (Strings.hasAnyPrefix(newerValue, PREFIXES)) { | |
return "a"; | |
} | |
} | |
return newerValue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment