Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public enum OrderType
- {
- Coop = 0,
- Normal = 1,
- Package = 2,
- SubInvoicing = 3,
- }
- public enum OrderType
- {
- Coop,
- Normal,
- Package,
- SubInvoicing
- }
- public class OrderTypeMap
- {
- private static Map<String, Integer> typeMap = new Map<String, Integer>
- {
- 'Coop' => 0,
- 'Normal' => 1,
- 'Package' => 2,
- 'SubInvoicing' => 3
- };
- public Integer Value(String s)
- {
- return typeMap.get(s);
- }
- }
- Integer i = OrderTypeMap.Value(OrderType.Normal.name());
- public class Foo {
- public enum OrderType
- {
- Coop,
- Normal,
- Package,
- SubInvoicing
- }
- public Map<OrderType,Integer> OrderTypeMap = ( new Map<OrderType,Integer>{
- Coop => 1,
- Normal => 2,
- Package => 3,
- SubInvoicing => 4 } );
- ...
- }
- public class Foo {
- public static OrderTypeEnum OrderType = new OrderTypeEnum();
- public class OrderTypeEnum
- {
- public Integer Coop { get { return 1; } }
- public Integer Normal { get { return 2; } }
- public Integer Package { get { return 3; } }
- public Integer SubInvoicing { get { return 4; } }
- }
- ...
- }
- Foo.OrderType ot = Foo.OrderType.Coop;
- if(Foo.OrderTypeMap.get(ot) == 1)
- ...
- Integer ot = Foo.OrderType.Coop;
- if(ot == Foo.OrderType.Coop)
- ...
- public class Foo {
- public static OrderTypeEnum OrderType = new OrderTypeEnum(null);
- public class OrderTypeEnum
- {
- public final Integer value;
- OrderTypeEnum(Integer value) { this.value = value; }
- public OrderTypeEnum Coop { get { return new OrderTypeEnum(1); } }
- public OrderTypeEnum Normal { get { return new OrderTypeEnum(2); } }
- public OrderTypeEnum Package { get { return new OrderTypeEnum(3); } }
- public OrderTypeEnum SubInvoicing { get { return new OrderTypEnum(4); } }
- public Boolean equals(Object that) {
- return (that instanceof OrderTypeEnum)?((OrderTypeEnum)that.value == value):(that == value);
- }
- public Integer hashCode() {return value;}
- }
- ...
- }
- Foo.OrderTypeEnum ot = Foo.OrderType.Coop;
- if(ot == 1)
- ...
- if(ot == Foo.OrderType.Coop)
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement