3 Replies Latest reply on Oct 16, 2012 6:12 AM by Kayaman

    Cool technique using switch & enumset for criteria.

      Java EnumSet jump table for high performance!

      Sometimes you have code that you only want to run part of - maybe it's JAXB that you only want some XML filled out for. Maybe it's a return set you only want part of the result set for. Using EnumSets you can ask for criteria that have only what you want. If you have a fine grained web service, great, pass the tags, if you don't, fine just de-reference the tags you want. The great thing here is you can reuse this same code in multiple data layers in your application, saving time and processing at each layer!

      for (IDiscount responseTO : discountsResponseTo.getAllOffers()) {
      Discount discount = obj.createDiscount();
      for(Tag x:tags) {//COOL!
      switch(x) {//COOL!
      case aaaDollars: discount.setAaaDollars(responseTO.getAAADollars()); break;
      case bestAvailRate: discount.setBestAvailRate(responseTO.getBestRate()); break;
      case caaDollars: discount.setCaaDollars(responseTO.getCAADollars()); break;
      case bogoFree: discount.setBogoFree(responseTO.getBOGOFree()); break;
      case couponBook: discount.setCouponBook(responseTO.getCouponBook()); beak;
      default: LOG.warn("Unhandled Tag: " + x); break;