-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb8553f
commit 07ca4a5
Showing
5 changed files
with
59 additions
and
38 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
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
40 changes: 40 additions & 0 deletions
40
matching-ws/src/main/java/life/catalogue/matching/util/IUCNUtils.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,40 @@ | ||
package life.catalogue.matching.util; | ||
|
||
public class IUCNUtils { | ||
|
||
public static String formatIucn(String original){ | ||
if (original == null) { | ||
return null; | ||
} | ||
// Trim the string | ||
String trimmed = original.trim(); | ||
// Convert to uppercase | ||
String uppercased = trimmed.toUpperCase(); | ||
// Replace any whitespace with a single underscore | ||
return uppercased.replaceAll("\\s+", "_"); | ||
} | ||
|
||
public enum IUCN { | ||
EXTINCT("EX"), | ||
EXTINCT_IN_THE_WILD("EW"), | ||
CRITICALLY_ENDANGERED ("CR"), | ||
ENDANGERED ("EN"), | ||
VULNERABLE ("VU"), | ||
NEAR_THREATENED ("NT"), | ||
CONSERVATION_DEPENDENT ("CD"), | ||
LEAST_CONCERN ("LC"), | ||
DATA_DEFICIENT ("DD"), | ||
NOT_EVALUATED ("NE"); | ||
|
||
private final String code; | ||
|
||
IUCN(String code) { | ||
this.code = code; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
} | ||
} |
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