]> git.mxchange.org Git - jproduct-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sun, 29 Oct 2017 22:48:37 +0000 (23:48 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 29 Oct 2017 22:48:37 +0000 (23:48 +0100)
- renamed categoryTitle (not localizable) to categoryI18nKey which can be
  localized

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jproduct/events/category/CategoryAddedEvent.java
src/org/mxchange/jproduct/exceptions/category/CategoryAlreadyAddedException.java
src/org/mxchange/jproduct/exceptions/category/CategoryNotFoundException.java
src/org/mxchange/jproduct/model/category/Category.java
src/org/mxchange/jproduct/model/category/ProductCategory.java

index b5d2673bc4f08c5980992ff2da6e296f60019fa1..580ec0914da3b8316b7bc0f0d097f245461f3ad0 100644 (file)
@@ -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) {
index b724fb2c1128f27c4a4a0f924868e88451d6d08f..6e6b342cf82e8c846d7b5fa5eb91d399f52002ba 100644 (file)
@@ -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
        }
 }
index b02c11e3f6648d0e04e859af6a73a0fcf271e1b6..d3fc25f9b30d687807168ddee428ff56bc994ed2 100644 (file)
@@ -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
        }
 
        /**
index f77dc971d2d3ce09d4c157e2e1a8e9304345d586..1ec30899ff8ae02c79cc393ad1e02d7b24feaac8 100644 (file)
@@ -88,14 +88,14 @@ public interface Category extends Serializable {
         * <p>
         * @return the title
         */
-       String getCategoryTitle ();
+       String getCategoryI18nKey ();
 
        /**
         * Title of category
         * <p>
         * @param title the title to set
         */
-       void setCategoryTitle (final String title);
+       void setCategoryI18nKey (final String title);
 
        @Override
        boolean equals (final Object object);
index 029d6f880f5e066b408bfe5c4d71a6ab1a4be084..5c0abff876b5eb5b5a9669b88a91dc574c1f6cb0 100644 (file)
@@ -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
         * <p>
-        * @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;
        }