uri-resolver/src/main/java/org/gcube/datatransfer/resolver/geoportal/TargetAppGeoportalCodes.java

123 lines
2.5 KiB
Java
Raw Normal View History

2023-03-23 15:54:00 +01:00
/**
*
*/
package org.gcube.datatransfer.resolver.geoportal;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
2023-03-24 14:00:24 +01:00
import org.gcube.datatransfer.resolver.services.GeoportalResolver;
2023-03-23 15:54:00 +01:00
/**
2023-03-24 09:49:57 +01:00
* The Enum TargetAppGeoportalCodes.
2023-03-23 15:54:00 +01:00
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
2023-03-24 09:49:57 +01:00
* Mar 24, 2023
2023-03-23 15:54:00 +01:00
*/
2023-03-24 09:49:57 +01:00
public enum TargetAppGeoportalCodes {
2023-03-23 15:54:00 +01:00
2023-03-24 14:00:24 +01:00
GEO(GeoportalResolver.GEO, "geoportal", "Geoportal"),
GEO_DV(GeoportalResolver.GEO_DV, "data-viewer", "Geoportal Viewer"),
GEO_DE(GeoportalResolver.GEO_DE, "data-entry", "Geoportal Entry");
2023-03-23 15:54:00 +01:00
private String id; // the code id
2023-03-24 09:49:57 +01:00
private String name; // the code value
2023-03-23 15:54:00 +01:00
private String description;
/**
* Instantiates a new resource catalogue codes.
*
* @param id the id
2023-03-24 09:49:57 +01:00
* @param name the target app
2023-03-23 15:54:00 +01:00
* @param description the description
*/
2023-03-24 09:49:57 +01:00
private TargetAppGeoportalCodes(String id, String name, String description) {
2023-03-23 15:54:00 +01:00
this.id = id;
2023-03-24 09:49:57 +01:00
this.name = name;
2023-03-23 15:54:00 +01:00
this.description = description;
}
/**
* Gets the id.
*
* @return the id
*/
public String getId() {
return id;
}
/**
* Gets the target app.
*
* @return the target app
*/
public String getTarget_app() {
2023-03-24 09:49:57 +01:00
return name;
2023-03-23 15:54:00 +01:00
}
/**
* Gets the description.
*
* @return the description
*/
public String getDescription() {
return description;
}
/**
* Codes.
*
* @return the list
*/
public static List<String> codes() {
2023-03-24 09:49:57 +01:00
return Arrays.asList(TargetAppGeoportalCodes.values()).stream().map(TargetAppGeoportalCodes::getId)
2023-03-23 15:54:00 +01:00
.collect(Collectors.toList());
}
/**
2023-03-24 09:49:57 +01:00
* Value of id.
2023-03-23 15:54:00 +01:00
*
* @param id the id
2023-03-24 09:49:57 +01:00
* @return the target app geoportal codes
2023-03-23 15:54:00 +01:00
*/
2023-03-24 09:49:57 +01:00
public static TargetAppGeoportalCodes valueOfId(String id) {
2023-03-23 15:54:00 +01:00
if (id == null || id.isEmpty())
return null;
2023-03-24 09:49:57 +01:00
List<TargetAppGeoportalCodes> codes = Arrays.asList(TargetAppGeoportalCodes.values()).stream()
2023-03-23 15:54:00 +01:00
.filter(value -> value.getId().compareTo(id) == 0).collect(Collectors.toList());
if (codes == null || codes.isEmpty())
return null;
return codes.get(0);
}
/**
2023-03-24 09:49:57 +01:00
* Value of name.
2023-03-23 15:54:00 +01:00
*
2023-03-24 09:49:57 +01:00
* @param name the name
* @return the target app geoportal codes
2023-03-23 15:54:00 +01:00
*/
2023-03-24 09:49:57 +01:00
public static TargetAppGeoportalCodes valueOfName(String name) {
if (name == null || name.isEmpty())
2023-03-23 15:54:00 +01:00
return null;
2023-03-24 09:49:57 +01:00
List<TargetAppGeoportalCodes> codes = Arrays.asList(TargetAppGeoportalCodes.values()).stream()
.filter(value -> value.getTarget_app().compareTo(name) == 0).collect(Collectors.toList());
2023-03-23 15:54:00 +01:00
if (codes == null || codes.isEmpty())
return null;
return codes.get(0);
}
}