001/*
002 * Copyright 2006-2007 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.batch.sample.domain.trade;
018
019import java.math.BigDecimal;
020
021/**
022 * Immutable Value Object representing an update to the customer as stored in the database. 
023 * This object has the customer name, credit amount, and the operation to be performed
024 * on them.  In the case of an add, a new customer will be entered with the appropriate 
025 * credit.  In the case of an update, the customer's credit is considered an absolute update.
026 * Deletes are currently not supported, but can still be read in from a file.
027 * 
028 * @author Lucas Ward
029 * @since 2.0
030 */
031public class CustomerUpdate {
032
033        private final CustomerOperation operation;
034        private final String customerName;
035        private final BigDecimal credit;
036        
037        public CustomerUpdate(CustomerOperation operation, String customerName, BigDecimal credit) {
038                this.operation = operation;
039                this.customerName = customerName;
040                this.credit = credit;
041        }
042
043        public CustomerOperation getOperation() {
044                return operation;
045        }
046
047        public String getCustomerName() {
048                return customerName;
049        }
050
051        public BigDecimal getCredit() {
052                return credit;
053        }
054        
055        @Override
056        public String toString() {
057                return "Customer Update, name: [" + customerName + "], operation: [" + operation + "], credit: [" + credit + "]";
058        }
059}