private CommerceEvent matchProductAttributes(CommerceEvent event) {
   int hash = Integer.parseInt(commerceMatchPropertyName);
   List<Product> productList = event.getProducts();
   if (productList == null || productList.size() == 0) {
     return null;
   }
   List<Product> matchedProducts = new LinkedList<Product>();
   for (Product product : productList) {
     Map<String, String> attributes = product.getCustomAttributes();
     if (attributes != null) {
       for (Map.Entry<String, String> entry : attributes.entrySet()) {
         int attributeHash =
             KitUtils.hashForFiltering(CommerceEventUtils.getEventType(event) + entry.getKey());
         if (attributeHash == hash) {
           if (commerceMatchPropertyValues.contains(entry.getValue().toLowerCase(Locale.US))) {
             matchedProducts.add(product);
           }
         }
       }
     }
   }
   if (matchedProducts.size() == 0) {
     return null;
   } else if (matchedProducts.size() != productList.size()) {
     return new CommerceEvent.Builder(event).products(matchedProducts).build();
   } else {
     return event;
   }
 }
 private CommerceEvent matchPromotionFields(CommerceEvent event) {
   int hash = Integer.parseInt(commerceMatchPropertyName);
   List<Promotion> promotionList = event.getPromotions();
   if (promotionList == null || promotionList.size() == 0) {
     return null;
   }
   List<Promotion> matchedPromotions = new LinkedList<Promotion>();
   Map<String, String> promotionFields = new HashMap<String, String>();
   for (Promotion promotion : promotionList) {
     promotionFields.clear();
     CommerceEventUtils.extractPromotionAttributes(promotion, promotionFields);
     if (promotionFields != null) {
       for (Map.Entry<String, String> entry : promotionFields.entrySet()) {
         int attributeHash =
             KitUtils.hashForFiltering(CommerceEventUtils.getEventType(event) + entry.getKey());
         if (attributeHash == hash) {
           if (commerceMatchPropertyValues.contains(entry.getValue().toLowerCase(Locale.US))) {
             matchedPromotions.add(promotion);
           }
         }
       }
     }
   }
   if (matchedPromotions.size() == 0) {
     return null;
   } else if (matchedPromotions.size() != promotionList.size()) {
     return new CommerceEvent.Builder(event).promotions(matchedPromotions).build();
   } else {
     return event;
   }
 }
 private boolean matchCommerceAttributes(CommerceEvent event) {
   Map<String, String> attributes = event.getCustomAttributes();
   if (attributes == null || attributes.size() < 1) {
     return false;
   }
   int hash = Integer.parseInt(commerceMatchPropertyName);
   for (Map.Entry<String, String> entry : attributes.entrySet()) {
     int attributeHash =
         KitUtils.hashForFiltering(CommerceEventUtils.getEventType(event) + entry.getKey());
     if (attributeHash == hash) {
       return commerceMatchPropertyValues.contains(entry.getValue().toLowerCase(Locale.US));
     }
   }
   return false;
 }