diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Identifier.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Identifier.java index bcc2a37..8c555d7 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Identifier.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/Identifier.java @@ -7,6 +7,10 @@ public final class Identifier { + private static final int MAX_ID_LENGTH = 19; + + private static final String ZERO_ID = "0"; + private final Long id; private final Anchor anchor; @@ -48,12 +52,12 @@ public Optional getAnchor() { public static boolean isId(String str) { - if (str.equals("0")) { + if (ZERO_ID.equals(str)) { throw new IllegalArgumentException("id should be greater than 0"); } int length = str.length(); - if (length > 19) { + if (length > MAX_ID_LENGTH) { return false; } diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReference.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReference.java index fb2c746..fef465b 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReference.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReference.java @@ -71,17 +71,13 @@ protected Builder(MediaReference media) { } public Builder mediaId(String mediaId) { - if (mediaId == null) { - throw new NullPointerException("mediaId is null"); - } + Objects.requireNonNull(mediaId, "mediaId is null"); this.mediaId = mediaId; return this; } public Builder usedBy(String usedBy) { - if (usedBy == null) { - throw new NullPointerException("usedBy is null"); - } + Objects.requireNonNull(usedBy, "usedBy is null"); this.usedBy = usedBy; return this; } diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQuery.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQuery.java index c2c0003..41978aa 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQuery.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQuery.java @@ -51,7 +51,9 @@ public final boolean equals(Object o) { } /** - * @see How to Write an Equality Method in Java + * @see + * How to Write an Equality Method in Java + * */ @Override public boolean canEqual(Object other) { diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/Query.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/Query.java index 9c181a4..07e1677 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/Query.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/Query.java @@ -60,7 +60,9 @@ public boolean equals(Object o) { } /** - * @see How to Write an Equality Method in Java + * @see + * How to Write an Equality Method in Java + * */ public boolean canEqual(Object other) { return (other instanceof Query); diff --git a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/SubTreeQuery.java b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/SubTreeQuery.java index be6410f..f1b2c9d 100644 --- a/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/SubTreeQuery.java +++ b/src/main/java/com/sitepark/ies/contentrepository/core/domain/entity/query/SubTreeQuery.java @@ -46,7 +46,9 @@ public final boolean equals(Object o) { } /** - * @see How to Write an Equality Method in Java + * @see + * How to Write an Equality Method in Java + * */ @Override public boolean canEqual(Object other) { diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecutionTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecutionTest.java index a0f669a..c049f07 100644 --- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecutionTest.java +++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityBulkExecutionTest.java @@ -16,6 +16,7 @@ import nl.jqno.equalsverifier.EqualsVerifier; +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class EntityBulkExecutionTest { @Test diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityLockTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityLockTest.java index e4d33ee..e2bb9a6 100644 --- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityLockTest.java +++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/EntityLockTest.java @@ -13,6 +13,7 @@ import nl.jqno.equalsverifier.EqualsVerifier; +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class EntityLockTest { @Test diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntryTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntryTest.java index 02886da..e58e717 100644 --- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntryTest.java +++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/HistoryEntryTest.java @@ -11,6 +11,7 @@ import nl.jqno.equalsverifier.EqualsVerifier; +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class HistoryEntryTest { @Test diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/IdentifierTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/IdentifierTest.java index fccca5c..967ea24 100644 --- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/IdentifierTest.java +++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/IdentifierTest.java @@ -9,6 +9,7 @@ import nl.jqno.equalsverifier.EqualsVerifier; +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class IdentifierTest { @Test diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReferenceTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReferenceTest.java index a0d644a..e943d09 100644 --- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReferenceTest.java +++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/MediaReferenceTest.java @@ -7,6 +7,7 @@ import nl.jqno.equalsverifier.EqualsVerifier; +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class MediaReferenceTest { @Test diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItemTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItemTest.java index b6a3c2d..f2378f3 100644 --- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItemTest.java +++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/RecycleBinItemTest.java @@ -14,6 +14,7 @@ import nl.jqno.equalsverifier.EqualsVerifier; +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class RecycleBinItemTest { @Test diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/FilterTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/FilterTest.java index a3baa59..bc15a7e 100644 --- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/FilterTest.java +++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/filter/FilterTest.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.sitepark.ies.contentrepository.core.domain.databind.DatabindModule; +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class FilterTest { @Test diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQueryTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQueryTest.java index ca1f07b..ea3aa7e 100644 --- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQueryTest.java +++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/entity/query/CursorBasedQueryTest.java @@ -6,6 +6,7 @@ import nl.jqno.equalsverifier.EqualsVerifier; +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class CursorBasedQueryTest { @Test diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFoundExceptionTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFoundExceptionTest.java index 529418a..ec34776 100644 --- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFoundExceptionTest.java +++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/exception/EntityNotFoundExceptionTest.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test; +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class EntityNotFoundExceptionTest { @Test diff --git a/src/test/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmptyExceptionTest.java b/src/test/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmptyExceptionTest.java index b506747..e39bda3 100644 --- a/src/test/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmptyExceptionTest.java +++ b/src/test/java/com/sitepark/ies/contentrepository/core/domain/exception/GroupNotEmptyExceptionTest.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test; +@SuppressWarnings("PMD.AvoidDuplicateLiterals") class GroupNotEmptyExceptionTest { @Test