Package org.gbif.api.util
Class ClassificationUtils
- java.lang.Object
-
- org.gbif.api.util.ClassificationUtils
-
public class ClassificationUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
copyLinneanClassification(LinneanClassification source, LinneanClassification target)
Copies all linnean classification based higher taxon names from one instance to another.static void
copyLinneanClassificationKeys(LinneanClassificationKeys source, LinneanClassificationKeys target)
Copies all linnean classification based higher taxon keys from one instance to another.static String
getHigherClassification(LinneanClassification lc)
Concatenates all higher Linnean taxa into a single dwc:higherClassification string, skipping null values.static <T extends LinneanClassification & LinneanClassificationKeys>
@NotNull LinkedHashMap<Integer,String>getHigherClassificationMap(T lc)
An ordered map with entries for all higher Linnean ranks down to species which are not null.static <T extends LinneanClassification & LinneanClassificationKeys>
@NotNull LinkedHashMap<Integer,String>getHigherClassificationMap(T lc, int key, Integer parentKey, String parent)
An ordered map with entries for all higher Linnean ranks down to the actual direct parent of this usage.static String
getHigherRank(LinneanClassification lc, Rank rank)
Gets a higher taxon property by passing the rank of it.static Integer
getHigherRankKey(LinneanClassificationKeys lck, Rank rank)
Gets a higher taxon key by passing the rank of it.static boolean
hasContent(LinneanClassification lc)
static void
setHigherRank(LinneanClassification lc, Rank rank, String name)
Sets a higher taxon property by passing the rank of it.static <T extends LinneanClassification & LinneanClassificationKeys>
voidsetHigherRank(T lc, Rank rank, String name, Integer usageKey)
Sets a higher taxon property by passing the rank of it.static void
setHigherRankKey(LinneanClassificationKeys lck, Rank rank, Integer usageKey)
Sets a higher taxon property by passing the rank of it.
-
-
-
Method Detail
-
getHigherClassification
@Nullable public static String getHigherClassification(LinneanClassification lc)
Concatenates all higher Linnean taxa into a single dwc:higherClassification string, skipping null values.- Parameters:
lc
- the LinneanClassification to join into the higher classification string- Returns:
- the concatenated dwc:higherClassification string
-
getHigherRank
@Nullable public static String getHigherRank(LinneanClassification lc, Rank rank)
Gets a higher taxon property by passing the rank of it. Only Linnean ranks are supported.- Parameters:
lc
- the LinneanClassification holding the taxon property to be retrievedrank
- the higher linnean rank to retrieve- Returns:
- the name of the higher taxon or null if rank doesnt exist
-
setHigherRank
public static void setHigherRank(LinneanClassification lc, Rank rank, String name)
Sets a higher taxon property by passing the rank of it.- Parameters:
lc
- the LinneanClassification on which to set the new propertyrank
- the higher linnean rank to setname
- the higher ranks name
-
getHigherClassificationMap
@NotNull public static <T extends LinneanClassification & LinneanClassificationKeys> @NotNull LinkedHashMap<Integer,String> getHigherClassificationMap(T lc)
An ordered map with entries for all higher Linnean ranks down to species which are not null. The map starts with the highest rank, e.g. the kingdom and maps the name usage key to its canonical name.- Parameters:
lc
- the object that implements both LinneanClassification and LinneanClassificationKeys from which to build the map- Returns:
- map of higher ranks
-
getHigherClassificationMap
@NotNull public static <T extends LinneanClassification & LinneanClassificationKeys> @NotNull LinkedHashMap<Integer,String> getHigherClassificationMap(T lc, int key, Integer parentKey, String parent)
An ordered map with entries for all higher Linnean ranks down to the actual direct parent of this usage. The map starts with the highest rank, e.g. the kingdom and maps the name usage key to its canonical name. The name usage itself is never included, even though a higher rank might point to the usage itself.- Parameters:
lc
- the object that implements both LinneanClassification and LinneanClassificationKeys from which to build the map- Returns:
- map of higher ranks
-
getHigherRankKey
@Nullable public static Integer getHigherRankKey(LinneanClassificationKeys lck, Rank rank)
Gets a higher taxon key by passing the rank of it. Only Linnean ranks are supported.- Parameters:
lck
- the classification that holds the taxon keyrank
- the higher linnean rank to retrieve- Returns:
- the key of the higher taxon or null if rank doesnt exist
-
setHigherRankKey
public static void setHigherRankKey(LinneanClassificationKeys lck, Rank rank, Integer usageKey)
Sets a higher taxon property by passing the rank of it.- Parameters:
lck
- the classification on which to set the taxon propertyrank
- the higher rank to setusageKey
- key of the higher ranks usage
-
setHigherRank
public static <T extends LinneanClassification & LinneanClassificationKeys> void setHigherRank(T lc, Rank rank, String name, Integer usageKey)
Sets a higher taxon property by passing the rank of it.- Parameters:
lc
- the object that implements both LinneanClassification and LinneanClassificationKeys on which to set the taxon propertyrank
- the higher linnean rank to setname
- the higher ranks nameusageKey
- key of the higher ranks usage
-
hasContent
public static boolean hasContent(LinneanClassification lc)
- Returns:
- true if at least one higher rank of the classification is given, i.e. not null or empty
-
copyLinneanClassificationKeys
public static void copyLinneanClassificationKeys(LinneanClassificationKeys source, LinneanClassificationKeys target)
Copies all linnean classification based higher taxon keys from one instance to another.
-
copyLinneanClassification
public static void copyLinneanClassification(LinneanClassification source, LinneanClassification target)
Copies all linnean classification based higher taxon names from one instance to another.
-
-