From: Roland Häder Date: Sun, 29 Oct 2017 22:48:37 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5871d3f588e8adc958c4d0f488793547bbcfaa57;p=jproduct-core.git Continued: - renamed categoryTitle (not localizable) to categoryI18nKey which can be localized Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jproduct/events/category/CategoryAddedEvent.java b/src/org/mxchange/jproduct/events/category/CategoryAddedEvent.java index b5d2673..580ec09 100644 --- a/src/org/mxchange/jproduct/events/category/CategoryAddedEvent.java +++ b/src/org/mxchange/jproduct/events/category/CategoryAddedEvent.java @@ -46,7 +46,7 @@ public class CategoryAddedEvent implements AddedCategoryEvent { if (null == addedCategory) { // Is NULL, throw NPE throw new NullPointerException("addedCategory is null"); //NOI18N - } else if (addedCategory.getCategoryTitle().isEmpty()) { + } else if (addedCategory.getCategoryI18nKey().isEmpty()) { // Empty title throw new IllegalArgumentException("addedCategory.categoryTitle is empty"); //NOI18N } else if (addedCategory.getCategoryId() == null) { diff --git a/src/org/mxchange/jproduct/exceptions/category/CategoryAlreadyAddedException.java b/src/org/mxchange/jproduct/exceptions/category/CategoryAlreadyAddedException.java index b724fb2..6e6b342 100644 --- a/src/org/mxchange/jproduct/exceptions/category/CategoryAlreadyAddedException.java +++ b/src/org/mxchange/jproduct/exceptions/category/CategoryAlreadyAddedException.java @@ -48,6 +48,6 @@ public class CategoryAlreadyAddedException extends Exception { */ public CategoryAlreadyAddedException (final Category category) { // Call super constructor - super(MessageFormat.format("Category with title '{0}' already added.", category.getCategoryTitle())); //NOI18N + super(MessageFormat.format("Category with i18n key '{0}' already added.", category.getCategoryI18nKey())); //NOI18N } } diff --git a/src/org/mxchange/jproduct/exceptions/category/CategoryNotFoundException.java b/src/org/mxchange/jproduct/exceptions/category/CategoryNotFoundException.java index b02c11e..d3fc25f 100644 --- a/src/org/mxchange/jproduct/exceptions/category/CategoryNotFoundException.java +++ b/src/org/mxchange/jproduct/exceptions/category/CategoryNotFoundException.java @@ -48,7 +48,7 @@ public class CategoryNotFoundException extends Exception { */ public CategoryNotFoundException (final Category category) { // Call super constructor - super(MessageFormat.format("Category with title '{0}' already added.", category.getCategoryTitle())); //NOI18N + super(MessageFormat.format("Category with i18n key '{0}' already added.", category.getCategoryI18nKey())); //NOI18N } /** diff --git a/src/org/mxchange/jproduct/model/category/Category.java b/src/org/mxchange/jproduct/model/category/Category.java index f77dc97..1ec3089 100644 --- a/src/org/mxchange/jproduct/model/category/Category.java +++ b/src/org/mxchange/jproduct/model/category/Category.java @@ -88,14 +88,14 @@ public interface Category extends Serializable { *

* @return the title */ - String getCategoryTitle (); + String getCategoryI18nKey (); /** * Title of category *

* @param title the title to set */ - void setCategoryTitle (final String title); + void setCategoryI18nKey (final String title); @Override boolean equals (final Object object); diff --git a/src/org/mxchange/jproduct/model/category/ProductCategory.java b/src/org/mxchange/jproduct/model/category/ProductCategory.java index 029d6f8..5c0abff 100644 --- a/src/org/mxchange/jproduct/model/category/ProductCategory.java +++ b/src/org/mxchange/jproduct/model/category/ProductCategory.java @@ -63,6 +63,13 @@ public class ProductCategory implements Category { @Temporal (TemporalType.TIMESTAMP) private Date categoryCreated; + /** + * I18n key of category + */ + @Basic (optional = false) + @Column (name = "category_i18n_key", nullable = false, unique = true) + private String categoryI18nKey; + /** * Id number of category */ @@ -78,13 +85,6 @@ public class ProductCategory implements Category { @Column (name = "category_in_statistics", nullable = false) private Boolean categoryShownInStatistics; - /** - * Title of category - */ - @Basic (optional = false) - @Column (name = "category_title", length = 100, nullable = false, unique = true) - private String categoryTitle; - /** * Parent category */ @@ -93,19 +93,19 @@ public class ProductCategory implements Category { private Category parentCategory; /** - * Constructor which accepts all database fields + * Constructor with all required fields *

- * @param categoryTitle Category categoryTitle + * @param categoryI18nKey Category i18n key * @param parentCategory Parent category * @param categoryShownInStatistics Whether this category is shown in any * statistics */ - public ProductCategory (final String categoryTitle, final Category parentCategory, final Boolean categoryShownInStatistics) { + public ProductCategory (final String categoryI18nKey, final Category parentCategory, final Boolean categoryShownInStatistics) { // Call other constructor this(); // Set all here - this.categoryTitle = categoryTitle; + this.categoryI18nKey = categoryI18nKey; this.parentCategory = parentCategory; this.categoryShownInStatistics = categoryShownInStatistics; } @@ -128,7 +128,7 @@ public class ProductCategory implements Category { final Category category = (Category) object; - if (!Objects.equals(this.getCategoryTitle(), category.getCategoryTitle())) { + if (!Objects.equals(this.getCategoryI18nKey(), category.getCategoryI18nKey())) { return false; } else if (!Objects.equals(this.getCategoryId(), category.getCategoryId())) { return false; @@ -149,6 +149,16 @@ public class ProductCategory implements Category { this.categoryCreated = categoryCreated; } + @Override + public String getCategoryI18nKey () { + return this.categoryI18nKey; + } + + @Override + public void setCategoryI18nKey (final String categoryI18nKey) { + this.categoryI18nKey = categoryI18nKey; + } + @Override public Long getCategoryId () { return this.categoryId; @@ -169,16 +179,6 @@ public class ProductCategory implements Category { this.categoryShownInStatistics = categoryShownInStatistics; } - @Override - public String getCategoryTitle () { - return this.categoryTitle; - } - - @Override - public void setCategoryTitle (final String categoryTitle) { - this.categoryTitle = categoryTitle; - } - @Override public Category getParentCategory () { return this.parentCategory; @@ -194,7 +194,7 @@ public class ProductCategory implements Category { int hash = 7; hash = 13 * hash + Objects.hashCode(this.getCategoryId()); - hash = 13 * hash + Objects.hashCode(this.getCategoryTitle()); + hash = 13 * hash + Objects.hashCode(this.getCategoryI18nKey()); return hash; }