Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Enum or other collection
    primarykey
    data
    text
    <p>We currently have two customer codes "CUSTA" and "CUSTB". CUSTA can perform operations A1, A2, A3, A4, A5, A6. CUSTB can perform operations B1, B2, B3, B4, B5, B6 based on some conditions. Currently they are not expecting any more customer codes but I would like the design to be flexible. These can be stored in database but as I mentioned because it is not likely for a long time to have another customer code, it needs to be represented in code.</p> <p>The application logic basic algorithm looks like</p> <pre><code>if ConditionX is true then if customerCode is "CUSTA" then applicableOperation = 'A1' else if customerCode is "CUSTB" then applicableOperation = 'B1' end else if ConditionY is true then if customerCode is "CUSTA" then applicableOperation = 'A2' else if customerCode is "CUSTB" then applicableOperation = 'B2' end else </code></pre> <p>............... .................</p> <p>I can write switch statements etc..to clean up the algorithm but my main concern is how to represent "CUSTA", "CUSTB", "A1","A2","A3","A4"..."A6","B1","B2"..."B6". Does the customer code be enum like </p> <pre><code>public enum CustomerCode { CUSTA, CUSTB } public enum OperationsForA{ A1, A2, A3,...A6 } public enum OperationsForB{ B1, B2, B3...B6} </code></pre> <p>Shall I create a <code>Map</code> where key is CustomerCode and add respective operations as values. </p> <p>What would be the best solution to address this problem. Also it should be flexible to add "CUSTC" , for example, in the future. </p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload