public void deletePayment(int paymentId) throws CustomerException { if (getId() == 0) { throw new CustomerException("deletePayment", "Invalid Customer Object. ID must be set."); } List<CustPmtMap> custPmtMapList = getCustpmttypes(0); boolean isValidTransaction = false; for (CustPmtMap cpm : custPmtMapList) { if (cpm.getPaymentid() == paymentId) { isValidTransaction = true; if (cpm.getPaymenttype().equals(PaymentType.CreditCard.toString())) { CreditCard creditcard = new CreditCard(); creditcard.setPaymentid(paymentId); creditcard.deletePaymentOption(); } break; } } if (!isValidTransaction) { throw new CustomerException( "deletePayment", "Invalid Request. Payment ID " + paymentId + " does not belong to cust id " + getId()); } }