1 28 29 package com.idaremedia.antx.parameters; 30 31 import com.idaremedia.antx.helpers.Strings; 32 import com.idaremedia.antx.helpers.Tk; 33 34 56 57 public final class FixturePassthru extends EnumSkeleton 58 { 59 60 public static final int ALL_INDEX = 0; 61 62 public static final int NONE_INDEX = ALL_INDEX+1; 63 64 public static final int PROPERTIES_INDEX = NONE_INDEX+1; 65 66 public static final int REFERENCES_INDEX = PROPERTIES_INDEX+1; 67 68 69 70 public static final FixturePassthru ALL= 71 new FixturePassthru("all",ALL_INDEX); 72 73 74 public static final FixturePassthru NONE= 75 new FixturePassthru("none",NONE_INDEX); 76 77 78 public static final FixturePassthru PROPERTIES= 79 new FixturePassthru("properties",PROPERTIES_INDEX); 80 81 82 public static final FixturePassthru REFERENCES= 83 new FixturePassthru("references",REFERENCES_INDEX); 84 85 86 89 public FixturePassthru() 90 { 91 super(); 92 } 93 94 95 100 private FixturePassthru(String v, int i) 101 { 102 super(v); 103 } 104 105 106 111 public String [] getValues() 112 { 113 return new String [] {"all", "none", 114 "properties", "references"}; 115 }; 116 117 118 119 125 public static FixturePassthru from(int i) 126 { 127 if (i==ALL.index) { return ALL; } 128 if (i==PROPERTIES.index) { return PROPERTIES; } 129 if (i==REFERENCES.index) { return REFERENCES; } 130 if (i==NONE.index) { return NONE; } 131 return null; 132 } 133 134 135 142 public static FixturePassthru from(int i, FixturePassthru dflt) 143 { 144 FixturePassthru choice= from(i); 145 return (choice==null) ? dflt : choice; 146 } 147 148 149 154 public static FixturePassthru from(String s) 155 { 156 if (s!=null && s.length()>1) { 157 s = Tk.lowercaseFrom(s); 158 if (Character.isDigit(s.charAt(0))) { 159 try { return from(Integer.parseInt(s)); } 160 catch(Exception nfx) {} 161 } else { 162 if (ALL.value.equals(s)) { return ALL; } 163 if (PROPERTIES.value.equals(s)) { return PROPERTIES; } 164 if (REFERENCES.value.equals(s)) { return REFERENCES; } 165 if (Strings.DEFAULT.equals(s)) { return PROPERTIES; } 166 if (NONE.value.equals(s)) { return NONE; } 167 } 168 } 169 return null; 170 } 171 172 173 180 public static FixturePassthru from(String s, FixturePassthru dflt) 181 { 182 FixturePassthru choice= from(s); 183 return (choice==null) ? dflt : choice; 184 } 185 } 186 187 188 | Popular Tags |