title: How to define Whitelist approach on Java to be able to return specific 'Type' of whitelist?
body: <p>I am facing a hard to decide situation(in my head)right now when I design my algorithm to filter and check whenever a things, let say CallCenter, has a allowlist for some phone number or some area and return specific type of allowlist-ing that the CallCenter applied on them. Is it allowlist for phonenumber, or for some area, or even the combination of area and phone(specific target).</p>
  <p>Btw, in my design a CallCenter will only has one type of Allowlist (&quot;byPhone&quot;, &quot;byArea&quot;, or &quot;byAreaAndPhone&quot; )I have my approach like this:</p>
  <pre><code>//// I use call center one to many relationship to allowlist directly to get the allowlists
  private void validateWhitelistOfCallCenter(CallCenter callCenter, String phoneNumber, String areaName) {
      if (callCenter.getAllowlists().isEmpty()) return;
      String typeAllowlist
      for (CallCenterAllowlist allowlist : callCenter.getAllowlists()) {
          typeAllowlist = allowlist.getType();
          if (ALLOWLIST_BY_PHONE_NUMBER.equals(allowlist.getType())
                  &amp;&amp; allowlist.getCustomerPhoneNumber().equals(phoneNumber)) return;
  
          if (ALLOWLIST_BY_AREA.equals(allowlist.getType())
                  &amp;&amp; allowlist.getAreaName().equals(areaName)) return;
  
          if (ALLOWLIST_BY_PHONE_NUMBER_AND_AREA.equals(allowlist.getType())
                  &amp;&amp; allowlist.getAreaName().equals(areaName)
                  &amp;&amp; allowlist.getCustomerPhoneNumber().equals(phoneNumber)) return;
      }
      if (ALLOWLIST_BY_PHONE_NUMBER.equals(errorType))
          throw CallCenterErrors.customerPhoneIsNotInAllowlist(phoneNumber);
      if (ALLOWLIST_BY_AREA.equals(errorType),
          throw CallCenterErrors.customerAreaIsNotInAllowlist(areaName);
      if (ALLOWLIST_BY_PHONE_NUMBER_AND_AREA.equals(errorType),
          throw CallCenterErrors.customerAreaAndPhoneIsNotInAllowlist(phoneNumber, areaName);
  }
  /// note: each return means the customer is in allowlist or the callcenter doesn't use any allowlist kind of things
  </code></pre>
  <p>Then, in my head I already feels it will be weird when the development becomes bigger let say callcenter allowlist will has more type of allowlist, then the if on the last method execution will be scaling too, and if statement inside the loop will be scaling too. Can anyone help me to decide is it good enough to do it as I make it or should I separate the validation to become one on one validation on each type of allowlist?. At first I decide not to separate the function because CallCenter Will only contain one type of allowlist, but the error return will always check the type whatever the condition of type in allowlists.</p>
  <p>**<em>Notes: Btw I already design a Blocklist for this kind of situation, blocklist has the opposite approach that makes it easier to apply error specification because whenever things found on loop throw error, which means the error type is same as the exact element that I found same with the specification(like byPhone or byArea).</em></p>