title: What is the right way to define constants when there is a huge number of constants?
body: <p>I'm working on some code which has a large number of constants to be defined. It primarily deals with <code>Marketplace</code> constants (could be US, UK, INDIA, JAPAN) and associated <code>MarketplaceMerchantMapping</code> which basically maps a <code>MerchantID</code> with a <code>MarketplaceID</code>.</p>
  
  <p>For example:</p>
  
  <pre><code>public enum Marketplace {
  
      US("US"),
      JP("JP"),
      UK("UK"),
      IN("IN"),
      NZ("NZ"),
      CA("CA"),
      FR("FR"),
      ... 
      ...
  
    // This could go up to some 400 marketplaces
  
      private final String stringValue;
  
      public boolean isWest() {
          return this == US || this == CA || this == UK;
      }
  
      public boolean isEast() {
          return this == IN || this == NZ || this == JP;
      }
  
  }
  </code></pre>
  
  <pre><code>public enum MarketplaceMerchantMapping {
  
      USMAP(MarketplaceID.US, MerchantID.US, Marketplace.US),
      JPMAP(MarketplaceID.JP, MerchantID.JP, Marketplace.JP),
      UKMAP(MarketplaceID.UK, MerchantID.UK, Marketplace.UK),
      NZMAP(MarketplaceID.NZ, MerchantID.NZ, Marketplace.NZ),
      INMAP(MarketplaceID.IN, MerchantID.IN, Marketplace.IN),
      CAMAP(MarketplaceID.CA, MerchantID.CA, Marketplace.CA),
      FRMAP(MarketplaceID.FR, MerchantID.FR, Marketplace.FR),
      ...
      ... 
  
     // THis can go up to 400 Marketplaces * Number of merchantIds in each marketplace.
  
  
  }
  </code></pre>
  
  <p>There are other similar constants defined similarly as enums or static constants.</p>
  
  <p>This really is not scalable because every time we add support for a new Marketplace and Merchants, we need to go and update a bunch of files and test them and these config changes themselves take up a lot of developer time.</p>
  
  <p>Ideally, I would like to know if there some way to define these constants in some config file and read those files to create the constants. Is there a way to create such enum constants by reading and parsing some config file?</p>
  
  <p>So that if I have a config file with the following entries:</p>
  
  <p>ConfigFile.cfg:</p>
  
  <pre><code>WestMarketplaces = ("US", "AG", "MX", "CA", ...) // Expand this later as required
  EastMarketplaces = ("IN", "AU", "SG", "JP", ...) // Expand this later as required
  EUMarketplaces = ("UK", "FR", "SP", ...) // Expand this later as required
  
  WestMerchantIds = ("WA", "WB", "WC", "WD", ...) // Expand this later as required
  WestMerchantIds = ("EA", "EB", "EC", "WD", ...) // Expand this later as required
  EUMerchantIds = ("EUA", "EUB", "EUC", "WDD", ...) // Expand this later as required
  
  marketplaceMerchantMapping = {
    "US" = "WA";
    "CA" = "WB";
    "MX" = "WC";
    "AU" = "EA";
    "IN" = "EB";
    "JP" = "EC";
    "UK" = "EUA";
    "FR" = "EUB";
  ...
  } // Expand this later as required
  </code></pre>
  
  <p>Then, can it read these constants from the config file and build the appropriate enums or static constants? </p>
  
  <p>Is this possible to do?</p>