public void addCriterion(Criterion criterion) throws SubscriptionRepositoryException { // Validate criterion object if (criterion == null) { throw new SubscriptionRepositoryException( "Attempted to add null criterion to subscription criteria list"); } // Validate key if ((criterion.getKey() == null) || "".equals(criterion.getKey().trim())) { throw new SubscriptionRepositoryException( "Attempted to add criterion with an invalid key to subscription criteria list - key: " + criterion.getKey()); } else { // Trim key prior to storage criterion.setKey(criterion.getKey().trim()); } // Valiedate value if ((criterion.getValue() == null) || "".equals(criterion.getValue().trim())) { throw new SubscriptionRepositoryException( "Attempted to add criterion to the subscription criteria list with an invalid value for key: " + criterion.getKey()); } getCriteria().add(criterion); }