add byKey method to CondensedDistributionRecipe
[cdmlib.git] / cdmlib-ext / src / main / java / eu / etaxonomy / cdm / ext / geo / CondensedDistributionRecipe.java
1 /**
2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.cdm.ext.geo;
10
11 import eu.etaxonomy.cdm.model.metadata.IKeyLabel;
12
13 /**
14 * @author a.kohlbecker
15 * @since Jun 24, 2015
16 *
17 * @deprecated the usage of this class is deprecated, please use {@link CondensedDistributionConfiguration} instead
18 */
19 @Deprecated
20 public enum CondensedDistributionRecipe implements IKeyLabel{
21
22 /**
23 * The recipe for creation of the condensed distribution strings
24 * as used in Euro+Med.
25 *
26 * For reference see:
27 * <ul>
28 * <li>{@link http://ww2.bgbm.org/EuroPlusMed/explanations.asp}</li>
29 * <li>{@link http://dev.e-taxonomy.eu/trac/ticket/3907}</li>
30 * </ul>
31 */
32 EuroPlusMed("EuroPlusMed", "Euro + Med"),
33 FloraCuba("FloraCuba", "Flora Cuba");
34
35 private String label;
36 private String key;
37
38 private CondensedDistributionRecipe(String key, String label) {
39 this.key = key;
40 this.label = label;
41 }
42
43 @Override
44 public String getLabel() {
45 return label;
46 }
47
48 @Override
49 public String getKey() {
50 return key;
51 }
52
53 public CondensedDistributionConfiguration toConfiguration(){
54 if (this == FloraCuba){
55 return CondensedDistributionConfiguration.NewCubaInstance();
56 } else {
57 return CondensedDistributionConfiguration.NewDefaultInstance();
58 }
59 }
60
61 public CondensedDistributionRecipe byKey(String key) {
62 if (key == null){
63 return null;
64 }else{
65 for (CondensedDistributionRecipe rec: values()){
66 if (rec.getKey().equalsIgnoreCase(key)){
67 return rec;
68 }
69 }
70 }
71 return null;
72 }
73 }