From d331b9a861326deb6c5503487ff106efb67ee59b Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 12 Mar 2016 12:45:32 +0100 Subject: [PATCH] Cleanup: - compareTo()/Comparable was used back in the TDGP times and is no longer needed - value first, then variable on comparison to avoid accidently assignments - updated jar(s) --- lib/jcontacts-core.jar | Bin 21291 -> 20592 bytes lib/jcore.jar | Bin 13656 -> 13656 bytes lib/jcoreee.jar | Bin 18919 -> 18919 bytes .../model/basket/AddableBasketItem.java | 22 +++---- .../model/basket/items/BaseItem.java | 23 +------ .../model/basket/items/BasketItem.java | 2 +- .../model/category/ProductCategory.java | 23 +------ .../model/customer/ShopCustomer.java | 17 ++---- .../jshopcore/model/order/ShopOrder.java | 7 +-- .../model/order/items/OrderItem.java | 56 +++++++++++++++--- .../model/product/GenericProduct.java | 40 ++++--------- 11 files changed, 75 insertions(+), 115 deletions(-) diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar index e905316a232cc3f743e47c1d041b3c782fa666f1..c06f26338a644f05dc23d0100e3b2efc31d0f98f 100644 GIT binary patch delta 5503 zcmaJ_3w)MU8ULT}+xBhW-odU6Hg@H*u?vI2V4GtM7y|}lH&8BO4p<@}kpm?IKM|75 zF5sIbqr?htXxbPI$WSp2E3BlTQYkR0&?GIbR1*KsdEaf{_ws)1x9^<)Iqx~o^M9Um zd(L_MVfF5VDz0g^H^L7@1E-d+-VvAYJ;|(mw^vH9X6fu=zGP;eD%JV5s#51W)fAnd zR+A*}&hRwGBofSg;8N7aiabDmV_>#5<(Ru;(*jrfk*i{2nD`}$mBjF48tYV?8X(1i zu^6V}rCoxcL_tY{k_Dv*8YC!H&|pDB1f>Z|7c^8*hM-JAS%R_!<-`UEa|I5Q%He`W z2pTCUPf)&~Q9f1RQ-uPHq_W75B2_HKc)uF0N+i+6L?JxJr^fnJX|x*WN3k03S7mB~ zbeJd~%O$Chq>@RUx=LV`B$FhmmSnOdHIht`WU3_7B&n5Tx+HZm6gb1LW~x~}R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r=k!|V6*t-1X3*`V&@mP4_y24m35VFK>lO9M{&J-!;WHo u;9IrX`oNv5SFc~eCu{ka_82&Rn&z+Wr!B6D(@sB|=82$%->lw)a diff --git a/lib/jcore.jar b/lib/jcore.jar index 23ef19d3e26ecc03e092895707158a0296bb95bf..097890ccbac9f229dc08c9aa1dd3e6ca12696ce6 100644 GIT binary patch delta 415 zcmcbSbt8*6z?+$ci-CcIf#G~g&O}}f=5s*GVm>p7cS{~j{m}qXlhqmZz;pzo6`1B^ zQkiVP!an%`BNv!|meCR_ZVILynasd+6_XQ)-n^gbBoCO;&F{_xW?U7##Rz6>5`GL} z%n*If3>ImUyao}8mR5!+Zj|kWFnAUGA&hvXT@W=gD!vd#j%qR+So2^e=Cd0Ff$127 za4@~iAPh|N8%BfaT*G)Uecmt>Osg9Og6V3bd@%jiC<{zS8E1p(6UGpA3MLSBB_m{20QR zA^MydEYc)-4I&aPtqf7zDBB5P@GAI281YKGAZlb(d?Ab+)nqoX_DkAR8JU3|nw+I; z0TP(JRM#F%KiAa<(~^1+@en;bFn_9^7npve=L)8^^gY3JnLdQSPu~s9XEz7}(=i6& zV0xQD7?|caj0V%WhVfwfykRJqRyPU+)73`#VEV057MPAQ&IZ#bj3Me2Od#q?Od#?P GP09iJ1B1^1 diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index f2ad1c85d97e64c5a60b7580b4a440554a198134..3f35cb503dc349a077aa978ba857bb1175b5c861 100644 GIT binary patch delta 407 zcmaDpneq8#M&1B#W)?061`Y;>ODQ=Mc{P|X0x666%pl$^c`)@y14K<$XEXrQQH+*g zdK#k@n7+(t52jZ#8BD(GF2aLs;N+h`!2}QX$#a;vpo)CK^iL*7Fm2214x%@=GoNPz zGa|XnI0S(r9y5b(u}bqWFo3Y#!1)DLX`D^kSCx}z|ob^EpCObG=faz*y2QaQMPTR51`c8dqoXWf#)w6S|8n4a(60H&2ZGQf1N PM;VxA^UMO%#hxVqi5-{X delta 407 zcmaDpneq8#M&1B#W)?061`Y-W#on}uyc*03K+0l1n7Snorv88hC#y3WfVh*R7%jo{ zG)5~heVNf7Os`}zn0(h=ga>XQNbyggV1ftxPJFE zJWcPigGDrLQ(2jT-kLno$pR!W`HU09seI1*V7`MhM7-MB0nFd$>?+Sol4OwV_30Mkky8DP5C PqYO;5d1is>V$Tu)*g=4B diff --git a/src/org/mxchange/jshopcore/model/basket/AddableBasketItem.java b/src/org/mxchange/jshopcore/model/basket/AddableBasketItem.java index 366783e..512ca7b 100644 --- a/src/org/mxchange/jshopcore/model/basket/AddableBasketItem.java +++ b/src/org/mxchange/jshopcore/model/basket/AddableBasketItem.java @@ -26,14 +26,6 @@ import org.mxchange.jshopcore.model.product.Product; */ public interface AddableBasketItem extends Serializable { - /** - * Check equality on item instance - *

- * @param object Other object to check - */ - @Override - boolean equals (final Object object); - /** * Getter for item amount *

@@ -84,22 +76,22 @@ public interface AddableBasketItem extends Serializable { Product getItemProduct (); /** - * Setter fo product instance + * Setter for product instance *

* @param product the product to set */ void setItemProduct (final Product product); - /** - * Hash-code calculation - */ - @Override - int hashCode (); - /** * Determines whether the item has a Product instance set *

* @return Whether a Product instance is set */ boolean isProductType (); + + @Override + boolean equals (final Object object); + + @Override + int hashCode (); } diff --git a/src/org/mxchange/jshopcore/model/basket/items/BaseItem.java b/src/org/mxchange/jshopcore/model/basket/items/BaseItem.java index d5f015c..198afad 100644 --- a/src/org/mxchange/jshopcore/model/basket/items/BaseItem.java +++ b/src/org/mxchange/jshopcore/model/basket/items/BaseItem.java @@ -26,33 +26,13 @@ import org.mxchange.jshopcore.model.product.Product; *

* @author Roland Haeder */ -public abstract class BaseItem implements AddableBasketItem, Comparable { +public abstract class BaseItem implements AddableBasketItem { /** * Serial number */ private static final long serialVersionUID = 24_348_671_457_829_156L; - @Override - public int compareTo (final AddableBasketItem item) { - // item should not be null - if (null == item) { - throw new NullPointerException("item is null"); //NOI18N - } - - // Is the id the same? - if (Objects.equals(this.getItemProduct(), item.getItemProduct())) { - // Same id, means same item - return 0; - } else if (this.getItemProduct().getProductId() > item.getItemProduct().getProductId()) { - // This id is larger than compared to - return -1; - } - - // The other id is larger - return 1; - } - @Override public boolean equals (final Object object) { // Is it same type? @@ -85,4 +65,5 @@ public abstract class BaseItem implements AddableBasketItem, Comparable { +public class BasketItem extends BaseItem implements AddableBasketItem { /** * Serial number diff --git a/src/org/mxchange/jshopcore/model/category/ProductCategory.java b/src/org/mxchange/jshopcore/model/category/ProductCategory.java index 0e94427..cc63278 100644 --- a/src/org/mxchange/jshopcore/model/category/ProductCategory.java +++ b/src/org/mxchange/jshopcore/model/category/ProductCategory.java @@ -16,7 +16,6 @@ */ package org.mxchange.jshopcore.model.category; -import java.util.Objects; import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -35,7 +34,7 @@ import javax.persistence.Table; */ @Entity (name = "category") @Table (name = "category") -public class ProductCategory implements Category, Comparable { +public class ProductCategory implements Category { /** * Serial number @@ -84,26 +83,6 @@ public class ProductCategory implements Category, Comparable { public ProductCategory () { } - @Override - public int compareTo (final Category category) { - // category should not be null - if (null == category) { - throw new NullPointerException("category is null"); //NOI18N - } - - // Is the categoryId the same? - if (Objects.equals(this.getCategoryId(), category.getCategoryId())) { - // Same categoryId, means same category - return 0; - } else if (this.getCategoryId() > category.getCategoryId()) { - // This categoryId is larger than compared to - return -1; - } - - // The other categoryId is larger - return 1; - } - @Override public void copyAll (final Category category) { // Copy all data diff --git a/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java b/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java index 4fe55ce..0165309 100644 --- a/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java +++ b/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java @@ -43,7 +43,7 @@ import org.mxchange.jshopcore.model.customer.status.CustomerAccountStatus; */ @Entity (name = "customer") @Table (name = "customer") -public class ShopCustomer implements Customer, Comparable { +public class ShopCustomer implements Customer { /** * Serial number @@ -112,11 +112,6 @@ public class ShopCustomer implements Customer, Comparable { public ShopCustomer () { } - @Override - public int compareTo (final Customer customer) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - @Override public void copyAll (final Customer customer) { // Copy also contact data @@ -132,16 +127,16 @@ public class ShopCustomer implements Customer, Comparable { } @Override - public boolean equals (final Object obj) { - if (this == obj) { + public boolean equals (final Object object) { + if (this == object) { return true; - } else if (obj == null) { + } else if (null == object) { return false; - } else if (this.getClass() != obj.getClass()) { + } else if (this.getClass() != object.getClass()) { return false; } - final Customer other = (Customer) obj; + final Customer other = (Customer) object; if (!Objects.equals(this.getCustomerNumber(), other.getCustomerNumber())) { return false; diff --git a/src/org/mxchange/jshopcore/model/order/ShopOrder.java b/src/org/mxchange/jshopcore/model/order/ShopOrder.java index 51acec5..54a087c 100644 --- a/src/org/mxchange/jshopcore/model/order/ShopOrder.java +++ b/src/org/mxchange/jshopcore/model/order/ShopOrder.java @@ -42,7 +42,7 @@ import org.mxchange.jshopcore.model.customer.ShopCustomer; */ @Entity (name = "orders") @Table (name = "orders") -public class ShopOrder implements Orderable, Comparable { +public class ShopOrder implements Orderable { /** * Serial number @@ -85,11 +85,6 @@ public class ShopOrder implements Orderable, Comparable { @Transient private List orderedItems; - @Override - public int compareTo (final Orderable order) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - @Override public String getAccessKey () { return this.accessKey; diff --git a/src/org/mxchange/jshopcore/model/order/items/OrderItem.java b/src/org/mxchange/jshopcore/model/order/items/OrderItem.java index 23f2ab1..95b2d15 100644 --- a/src/org/mxchange/jshopcore/model/order/items/OrderItem.java +++ b/src/org/mxchange/jshopcore/model/order/items/OrderItem.java @@ -16,6 +16,7 @@ */ package org.mxchange.jshopcore.model.order.items; +import java.util.Objects; import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -23,6 +24,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.OneToOne; import javax.persistence.Table; @@ -37,21 +39,19 @@ import org.mxchange.jshopcore.model.product.Product; * @author Roland Haeder */ @Entity (name = "ordered_item") -@Table (name = "ordered_items") -public class OrderItem extends BaseItem implements AddableBasketItem, Comparable { +@Table ( + name = "ordered_items", + indexes = { + @Index (name = "product", columnList = "order_product_id") + } +) +public class OrderItem extends BaseItem implements AddableBasketItem { /** * Serial number */ private static final long serialVersionUID = 44_189_562_738_723_581L; - /** - * Item amount - */ - @Basic (optional = false) - @Column (name = "order_amount", length = 20, nullable = false) - private Long orderedAmount; - /** * Entry id (from database backend) */ @@ -67,6 +67,13 @@ public class OrderItem extends BaseItem implements AddableBasketItem, Comparable @Column (name = "order_item_type", length = 20) private String itemType; + /** + * Item amount + */ + @Basic (optional = false) + @Column (name = "order_amount", length = 20, nullable = false) + private Long orderedAmount; + /** * Product instance */ @@ -80,6 +87,36 @@ public class OrderItem extends BaseItem implements AddableBasketItem, Comparable public OrderItem () { } + @Override + public boolean equals (final Object object) { + if (this == object) { + return true; + } else if (null == object) { + return false; + } else if (this.getClass() != object.getClass()) { + return false; + } + + final AddableBasketItem item = (AddableBasketItem) object; + + if (!Objects.equals(this.itemType, item.getItemType())) { + return false; + } else if (!Objects.equals(this.orderedAmount, item.getOrderedAmount())) { + return false; + } + + return Objects.equals(this.product, item.getItemProduct()); + } + + @Override + public int hashCode () { + int hash = 3; + hash = 53 * hash + Objects.hashCode(this.getItemType()); + hash = 53 * hash + Objects.hashCode(this.getOrderedAmount()); + hash = 53 * hash + Objects.hashCode(this.getItemProduct()); + return hash; + } + @Override public Long getItemId () { return this.itemId; @@ -119,4 +156,5 @@ public class OrderItem extends BaseItem implements AddableBasketItem, Comparable public void setOrderedAmount (final Long orderedAmount) { this.orderedAmount = orderedAmount; } + } diff --git a/src/org/mxchange/jshopcore/model/product/GenericProduct.java b/src/org/mxchange/jshopcore/model/product/GenericProduct.java index 05fba51..d1e952f 100644 --- a/src/org/mxchange/jshopcore/model/product/GenericProduct.java +++ b/src/org/mxchange/jshopcore/model/product/GenericProduct.java @@ -38,7 +38,7 @@ import org.mxchange.jshopcore.model.category.ProductCategory; */ @Entity (name = "products") @Table (name = "products") -public class GenericProduct implements Product, Comparable { +public class GenericProduct implements Product { /** * Serial number @@ -89,10 +89,10 @@ public class GenericProduct implements Product, Comparable { /** * Constructor will all required data *

- * @param productId Id number of product - * @param productTitle Name of product - * @param productPrice Price - * @param productCategory Category instance + * @param productId Id number of product + * @param productTitle Name of product + * @param productPrice Price + * @param productCategory Category instance * @param productAvailability Availability (selectable by customer) */ public GenericProduct (final Long productId, final String productTitle, final Float productPrice, final Category productCategory, final Boolean productAvailability) { @@ -104,26 +104,6 @@ public class GenericProduct implements Product, Comparable { this.productAvailability = productAvailability; } - @Override - public int compareTo (final Product product) { - // productCategory should not be null - if (null == product) { - throw new NullPointerException("product is null"); //NOI18N - } - - // Is the productId the same? - if (Objects.equals(this.getProductId(), product.getProductId())) { - // Same productId, means same productCategory - return 0; - } else if (this.getProductId() > product.getProductId()) { - // This productId is larger than compared to - return 1; - } - - // The other productId is larger - return -1; - } - @Override public void copyAll (final Product product) { // Copy all @@ -134,16 +114,16 @@ public class GenericProduct implements Product, Comparable { } @Override - public boolean equals (final Object obj) { - if (this == obj) { + public boolean equals (final Object object) { + if (this == object) { return true; - } else if (obj == null) { + } else if (null == object) { return false; - } else if (this.getClass() != obj.getClass()) { + } else if (this.getClass() != object.getClass()) { return false; } - final Product other = (Product) obj; + final Product other = (Product) object; if (!Objects.equals(this.getProductTitle(), other.getProductTitle())) { return false; -- 2.39.5