001/* 002 * Copyright 2006-2014 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.order; 018 019import java.math.BigDecimal; 020 021public class LineItem { 022 public static final String LINE_ID_ITEM = "LIT"; 023 024 private long itemId; 025 private BigDecimal price; 026 private BigDecimal discountPerc; 027 private BigDecimal discountAmount; 028 private BigDecimal shippingPrice; 029 private BigDecimal handlingPrice; 030 private int quantity; 031 private BigDecimal totalPrice; 032 033 public BigDecimal getDiscountAmount() { 034 return discountAmount; 035 } 036 037 public void setDiscountAmount(BigDecimal discountAmount) { 038 this.discountAmount = discountAmount; 039 } 040 041 public BigDecimal getDiscountPerc() { 042 return discountPerc; 043 } 044 045 public void setDiscountPerc(BigDecimal discountPerc) { 046 this.discountPerc = discountPerc; 047 } 048 049 public BigDecimal getHandlingPrice() { 050 return handlingPrice; 051 } 052 053 public void setHandlingPrice(BigDecimal handlingPrice) { 054 this.handlingPrice = handlingPrice; 055 } 056 057 public long getItemId() { 058 return itemId; 059 } 060 061 public void setItemId(long itemId) { 062 this.itemId = itemId; 063 } 064 065 public BigDecimal getPrice() { 066 return price; 067 } 068 069 public void setPrice(BigDecimal price) { 070 this.price = price; 071 } 072 073 public int getQuantity() { 074 return quantity; 075 } 076 077 public void setQuantity(int quantity) { 078 this.quantity = quantity; 079 } 080 081 public BigDecimal getShippingPrice() { 082 return shippingPrice; 083 } 084 085 public void setShippingPrice(BigDecimal shippingPrice) { 086 this.shippingPrice = shippingPrice; 087 } 088 089 public BigDecimal getTotalPrice() { 090 return totalPrice; 091 } 092 093 public void setTotalPrice(BigDecimal totalPrice) { 094 this.totalPrice = totalPrice; 095 } 096 097 @Override 098 public String toString() { 099 return "LineItem [price=" + price + ", quantity=" + quantity + ", totalPrice=" + totalPrice + "]"; 100 } 101 102 @Override 103 public int hashCode() { 104 final int prime = 31; 105 int result = 1; 106 result = prime * result + (int) (itemId ^ (itemId >>> 32)); 107 result = prime * result + quantity; 108 return result; 109 } 110 111 @Override 112 public boolean equals(Object obj) { 113 if (this == obj) { 114 return true; 115 } 116 117 if (obj == null) { 118 return false; 119 } 120 121 if (getClass() != obj.getClass()) { 122 return false; 123 } 124 125 LineItem other = (LineItem) obj; 126 127 if (itemId != other.itemId) { 128 return false; 129 } 130 131 if (quantity != other.quantity) { 132 return false; 133 } 134 135 return true; 136 } 137}