1 28 29 package com.idaremedia.antx.flowcontrol.match; 30 31 import com.idaremedia.antx.parameters.EnumSkeleton; 32 33 42 43 final class ChoiceType extends EnumSkeleton 44 { 45 46 static final int NONE_INDEX = 0; 47 48 static final int SAME_INDEX = NONE_INDEX+1; 49 50 static final int LIKE_INDEX = SAME_INDEX+1; 51 52 static final int MEETS_INDEX = LIKE_INDEX+1; 53 54 55 56 static final ChoiceType NONE= 57 new ChoiceType("none",NONE_INDEX,false); 58 59 60 static final ChoiceType SAME= 61 new ChoiceType("equals",SAME_INDEX,true); 62 63 64 static final ChoiceType LIKE= 65 new ChoiceType("like",LIKE_INDEX,true); 66 67 68 static final ChoiceType MEETS= 69 new ChoiceType("meets",MEETS_INDEX,false); 70 71 72 77 private ChoiceType(String v, int i, boolean landr) 78 { 79 super(v); 80 m_landr = landr; 81 } 82 83 84 89 public String [] getValues() 90 { 91 return new String [] {"none", "equals", "like", "meets"}; 92 }; 93 94 95 96 100 boolean needsLeftAndRight() 101 { 102 return m_landr; 103 } 104 105 106 110 static ChoiceType from(Class c) 111 { 112 if (c!=null) { 113 if (MatchEquals.class.isAssignableFrom(c)) { 114 return SAME; 115 } 116 if (MatchLike.class.isAssignableFrom(c)) { 117 return LIKE; 118 } 119 if (MatchCondition.class.isAssignableFrom(c)) { 120 return MEETS; 121 } 122 } 123 return null; 124 } 125 126 127 134 static ChoiceType from(Class c, ChoiceType dflt) 135 { 136 ChoiceType choice= from(c); 137 return (choice==null) ? dflt : choice; 138 } 139 140 141 private final boolean m_landr;} 143 144 | Popular Tags |