/** * */ package org.gcube.datatransfer.resolver.geoportal; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; /** * The Enum ResourceGeoportalCodes. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * * Mar 23, 2023 */ public enum ResourceGeoportalCodes { GEO("geo", "geoportal-viewer", "Geoportal Viewer"), GEO_V("geo-v", "data-viewer", "Geoportal Viewer"); private String id; // the code id private String target_app; // the code value private String description; /** * Instantiates a new resource catalogue codes. * * @param id the id * @param target_app the target app * @param description the description */ private ResourceGeoportalCodes(String id, String target_app, String description) { this.id = id; this.target_app = target_app; 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() { return target_app; } /** * Gets the description. * * @return the description */ public String getDescription() { return description; } /** * Codes. * * @return the list */ public static List codes() { return Arrays.asList(ResourceGeoportalCodes.values()).stream().map(ResourceGeoportalCodes::getId) .collect(Collectors.toList()); } /** * Value of code id. * * @param id the id * @return the resource geoportal codes */ public static ResourceGeoportalCodes valueOfCodeId(String id) { if (id == null || id.isEmpty()) return null; List codes = Arrays.asList(ResourceGeoportalCodes.values()).stream() .filter(value -> value.getId().compareTo(id) == 0).collect(Collectors.toList()); if (codes == null || codes.isEmpty()) return null; return codes.get(0); } /** * Value of target app. * * @param targetApp the target app * @return the resource geoportal codes */ public static ResourceGeoportalCodes valueOfTargetApp(String targetApp) { if (targetApp == null || targetApp.isEmpty()) return null; List codes = Arrays.asList(ResourceGeoportalCodes.values()).stream() .filter(value -> value.getTarget_app().compareTo(targetApp) == 0).collect(Collectors.toList()); if (codes == null || codes.isEmpty()) return null; return codes.get(0); } }