SHARE
TWEET

Untitled

a guest Jun 25th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public enum OrderType
  2. {
  3.     Coop = 0,
  4.     Normal = 1,
  5.     Package = 2,
  6.     SubInvoicing = 3,
  7. }
  8.      
  9. public enum OrderType
  10. {
  11.     Coop,
  12.     Normal,
  13.     Package,
  14.     SubInvoicing
  15. }
  16.      
  17. public class OrderTypeMap
  18. {
  19.   private static Map<String, Integer> typeMap = new Map<String, Integer>
  20.   {
  21.     'Coop' => 0,
  22.     'Normal' => 1,
  23.     'Package' => 2,
  24.     'SubInvoicing' => 3
  25.   };
  26.  
  27.   public Integer Value(String s)
  28.   {
  29.     return typeMap.get(s);
  30.   }
  31. }
  32.      
  33. Integer i = OrderTypeMap.Value(OrderType.Normal.name());
  34.      
  35. public class Foo {
  36.     public enum OrderType
  37.     {
  38.         Coop,
  39.         Normal,
  40.         Package,
  41.         SubInvoicing
  42.     }
  43.  
  44.     public Map<OrderType,Integer> OrderTypeMap = ( new Map<OrderType,Integer>{
  45.         Coop => 1,
  46.         Normal => 2,
  47.         Package => 3,
  48.         SubInvoicing => 4 } );
  49.  
  50. ...
  51. }
  52.      
  53. public class Foo {
  54.     public static OrderTypeEnum OrderType = new OrderTypeEnum();
  55.  
  56.     public class OrderTypeEnum
  57.     {
  58.         public Integer Coop { get { return 1; } }
  59.         public Integer Normal { get { return 2; } }
  60.         public Integer Package { get { return 3; } }
  61.         public Integer SubInvoicing { get { return 4; } }
  62.     }
  63.  
  64. ...
  65. }
  66.      
  67. Foo.OrderType ot = Foo.OrderType.Coop;
  68. if(Foo.OrderTypeMap.get(ot) == 1)
  69. ...
  70.      
  71. Integer ot = Foo.OrderType.Coop;
  72. if(ot == Foo.OrderType.Coop)
  73. ...
  74.      
  75. public class Foo {
  76.     public static OrderTypeEnum OrderType = new OrderTypeEnum(null);
  77.  
  78.     public class OrderTypeEnum
  79.     {
  80.         public final Integer value;
  81.         OrderTypeEnum(Integer value) { this.value = value; }
  82.         public OrderTypeEnum Coop { get { return new OrderTypeEnum(1); } }
  83.         public OrderTypeEnum Normal { get { return new OrderTypeEnum(2); } }
  84.         public OrderTypeEnum Package { get { return new OrderTypeEnum(3); } }
  85.         public OrderTypeEnum SubInvoicing { get { return new OrderTypEnum(4); } }
  86.         public Boolean equals(Object that) {
  87.             return (that instanceof OrderTypeEnum)?((OrderTypeEnum)that.value == value):(that == value);
  88.         }
  89.         public Integer hashCode() {return value;}
  90.     }
  91.  
  92. ...
  93. }
  94.      
  95. Foo.OrderTypeEnum ot = Foo.OrderType.Coop;
  96. if(ot == 1)
  97. ...
  98. if(ot == Foo.OrderType.Coop)
  99. ...
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top