From fd145afe54b70f88f4317558283806bed919a7b5 Mon Sep 17 00:00:00 2001 From: Frank Hossfeld Date: Sat, 10 Jun 2023 12:50:57 +0200 Subject: [PATCH] #48 - add packageName, simpleName and fieldName to MalioValidationException - done (#49) --- .../ArrayItemMaxLengthConstraint.java | 7 +++-- .../ArrayItemMinLengthConstraint.java | 7 +++-- .../ArrayItemNotBlankConstraint.java | 5 +++- .../ArrayItemNotNullConstraint.java | 5 +++- .../constraint/ArraySizeConstraint.java | 6 ++-- .../constraint/BlacklistConstraint.java | 7 +++-- .../CollectionItemMaxLengthConstraint.java | 7 +++-- .../CollectionItemMinLengthConstraint.java | 7 +++-- .../CollectionItemNotBlankConstraint.java | 5 +++- .../CollectionItemNotNullConstraint.java | 5 +++- .../internal/constraint/EmailConstraint.java | 5 +++- .../internal/constraint/MaxConstraint.java | 7 +++-- .../constraint/MaxDecimalConstraint.java | 7 +++-- .../constraint/MaxLengthConstraint.java | 7 +++-- .../internal/constraint/MinConstraint.java | 7 +++-- .../constraint/MinDecimalConstraint.java | 7 +++-- .../constraint/MinLengthConstraint.java | 7 +++-- .../constraint/NotBlankConstraint.java | 5 +++- .../constraint/NotEmptyConstraint.java | 5 +++- .../constraint/NotNullConstraint.java | 5 +++- .../constraint/NotZeroConstraint.java | 12 ++++++-- .../internal/constraint/RegexpConstraint.java | 7 +++-- .../internal/constraint/SizeConstraint.java | 5 +++- .../internal/constraint/UuidConstraint.java | 5 +++- .../constraint/WhitelistConstraint.java | 7 +++-- .../shared/util/MalioValidationException.java | 30 +++++++++++++++++-- 26 files changed, 146 insertions(+), 43 deletions(-) diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemMaxLengthConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemMaxLengthConstraint.java index a65cff2..f693fcf 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemMaxLengthConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemMaxLengthConstraint.java @@ -23,7 +23,7 @@ public class ArrayItemMaxLengthConstraint extends AbstractConstraint { - private int maxLength; + private final int maxLength; public ArrayItemMaxLengthConstraint(String packageName, String simpleName, @@ -40,7 +40,10 @@ public ArrayItemMaxLengthConstraint(String packageName, public void check(String value) throws MalioValidationException { if (value != null && value.length() > maxLength) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemMinLengthConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemMinLengthConstraint.java index 82a2d5d..189457d 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemMinLengthConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemMinLengthConstraint.java @@ -23,7 +23,7 @@ public class ArrayItemMinLengthConstraint extends AbstractConstraint { - private int minLength; + private final int minLength; public ArrayItemMinLengthConstraint(String packageName, String simpleName, @@ -40,7 +40,10 @@ public ArrayItemMinLengthConstraint(String packageName, public void check(String value) throws MalioValidationException { if (value != null && value.length() < minLength) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemNotBlankConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemNotBlankConstraint.java index 11cc494..706bdc8 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemNotBlankConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemNotBlankConstraint.java @@ -43,7 +43,10 @@ protected String getSpecializedMessage(String value) { public void check(String value) throws MalioValidationException { if (Objects.nonNull(value) && value.isEmpty()) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemNotNullConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemNotNullConstraint.java index 6588e39..5b618c5 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemNotNullConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArrayItemNotNullConstraint.java @@ -43,7 +43,10 @@ protected String getSpecializedMessage(T value) { public void check(T value) throws MalioValidationException { if (Objects.isNull(value)) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArraySizeConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArraySizeConstraint.java index 8199015..0ff1e80 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArraySizeConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/ArraySizeConstraint.java @@ -99,9 +99,11 @@ public void check(Object[] value) private void internCheck(int size) { if (size < this.min || size > this.max) { - throw new MalioValidationException(getMessage(null)); + throw new MalioValidationException(getMessage(null), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } - } public void isValid(Object[] value, diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/BlacklistConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/BlacklistConstraint.java index ed8e6f8..53cf0fd 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/BlacklistConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/BlacklistConstraint.java @@ -26,7 +26,7 @@ public class BlacklistConstraint extends AbstractConstraint { - private List blacklist; + private final List blacklist; public BlacklistConstraint(String packageName, String simpleName, @@ -44,7 +44,10 @@ public void check(String value) throws MalioValidationException { if (value != null && blacklist.contains(value)) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemMaxLengthConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemMaxLengthConstraint.java index e9cb6f9..ca6244e 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemMaxLengthConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemMaxLengthConstraint.java @@ -23,7 +23,7 @@ public class CollectionItemMaxLengthConstraint extends AbstractConstraint { - private int maxLength; + private final int maxLength; public CollectionItemMaxLengthConstraint(String packageName, String simpleName, @@ -40,7 +40,10 @@ public CollectionItemMaxLengthConstraint(String packageName, public void check(String value) throws MalioValidationException { if (value != null && value.length() > maxLength) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemMinLengthConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemMinLengthConstraint.java index 0432678..c37d4c8 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemMinLengthConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemMinLengthConstraint.java @@ -23,7 +23,7 @@ public class CollectionItemMinLengthConstraint extends AbstractConstraint { - private int minLength; + private final int minLength; public CollectionItemMinLengthConstraint(String packageName, String simpleName, @@ -40,7 +40,10 @@ public CollectionItemMinLengthConstraint(String packageName, public void check(String value) throws MalioValidationException { if (value != null && value.length() < minLength) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemNotBlankConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemNotBlankConstraint.java index a944084..1b70337 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemNotBlankConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemNotBlankConstraint.java @@ -43,7 +43,10 @@ protected String getSpecializedMessage(String value) { public void check(String value) throws MalioValidationException { if (Objects.nonNull(value) && value.isEmpty()) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemNotNullConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemNotNullConstraint.java index 18373da..2ed9b99 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemNotNullConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/CollectionItemNotNullConstraint.java @@ -43,7 +43,10 @@ protected String getSpecializedMessage(T value) { public void check(T value) throws MalioValidationException { if (Objects.isNull(value)) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/EmailConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/EmailConstraint.java index 1ecd926..06c3ecb 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/EmailConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/EmailConstraint.java @@ -46,7 +46,10 @@ protected String getSpecializedMessage(String value) { public void check(String value) throws MalioValidationException { if (Objects.nonNull(value) && !EmailConstraint.regExp.test(value)) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxConstraint.java index d876e60..fbb6e88 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxConstraint.java @@ -23,7 +23,7 @@ public class MaxConstraint extends AbstractConstraint { - private Long maxValue; + private final Long maxValue; public MaxConstraint(String packageName, String simpleName, @@ -40,7 +40,10 @@ public MaxConstraint(String packageName, public void check(Number value) throws MalioValidationException { if (value != null && value.longValue() > this.maxValue) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxDecimalConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxDecimalConstraint.java index baa770c..3a38a1a 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxDecimalConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxDecimalConstraint.java @@ -25,7 +25,7 @@ public class MaxDecimalConstraint extends AbstractConstraint { - private BigDecimal maxValue; + private final BigDecimal maxValue; public MaxDecimalConstraint(String packageName, String simpleName, @@ -42,7 +42,10 @@ public MaxDecimalConstraint(String packageName, public void check(BigDecimal value) throws MalioValidationException { if (value != null && value.compareTo(this.maxValue) > 0) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxLengthConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxLengthConstraint.java index 50d1d7e..00314a1 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxLengthConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MaxLengthConstraint.java @@ -23,7 +23,7 @@ public class MaxLengthConstraint extends AbstractConstraint { - private int maxLength; + private final int maxLength; public MaxLengthConstraint(String packageName, String simpleName, @@ -40,7 +40,10 @@ public MaxLengthConstraint(String packageName, public void check(String value) throws MalioValidationException { if (value != null && value.length() > maxLength) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinConstraint.java index 8af969c..13d5dcc 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinConstraint.java @@ -23,7 +23,7 @@ public class MinConstraint extends AbstractConstraint { - private Long minValue; + private final Long minValue; public MinConstraint(String packageName, String simpleName, @@ -40,7 +40,10 @@ public MinConstraint(String packageName, public void check(Number value) throws MalioValidationException { if (value != null && value.longValue() < this.minValue) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinDecimalConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinDecimalConstraint.java index 45bc95c..a12b014 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinDecimalConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinDecimalConstraint.java @@ -25,7 +25,7 @@ public class MinDecimalConstraint extends AbstractConstraint { - private BigDecimal minValue; + private final BigDecimal minValue; public MinDecimalConstraint(String packageName, String simpleName, @@ -42,7 +42,10 @@ public MinDecimalConstraint(String packageName, public void check(BigDecimal value) throws MalioValidationException { if (value != null && value.compareTo(this.minValue) < 0) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinLengthConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinLengthConstraint.java index 2f0171b..0fe8a5d 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinLengthConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/MinLengthConstraint.java @@ -23,7 +23,7 @@ public class MinLengthConstraint extends AbstractConstraint { - private int minLength; + private final int minLength; public MinLengthConstraint(String packageName, String simpleName, @@ -40,7 +40,10 @@ public MinLengthConstraint(String packageName, public void check(String value) throws MalioValidationException { if (value != null && value.length() < minLength) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotBlankConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotBlankConstraint.java index c60d851..15a27da 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotBlankConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotBlankConstraint.java @@ -43,7 +43,10 @@ protected String getSpecializedMessage(String value) { public void check(String value) throws MalioValidationException { if (Objects.nonNull(value) && value.isEmpty()) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotEmptyConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotEmptyConstraint.java index c469b79..e069701 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotEmptyConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotEmptyConstraint.java @@ -44,7 +44,10 @@ protected String getSpecializedMessage(T value) { public void check(T value) throws MalioValidationException { if (Objects.nonNull(value) && value.isEmpty()) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotNullConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotNullConstraint.java index fd0aea3..ea1fb45 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotNullConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotNullConstraint.java @@ -43,7 +43,10 @@ protected String getSpecializedMessage(T value) { public void check(T value) throws MalioValidationException { if (Objects.isNull(value)) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotZeroConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotZeroConstraint.java index cfa815d..d506ca9 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotZeroConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/NotZeroConstraint.java @@ -25,7 +25,7 @@ public class NotZeroConstraint extends AbstractConstraint { - private boolean allowNegativeValues; + private final boolean allowNegativeValues; public NotZeroConstraint(String packageName, String simpleName, @@ -47,12 +47,18 @@ public void check(Number value) if (!this.allowNegativeValues) { if (value.longValue() < 0) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } if (value.longValue() == 0) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/RegexpConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/RegexpConstraint.java index abbbf2f..701d7c8 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/RegexpConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/RegexpConstraint.java @@ -24,7 +24,7 @@ public class RegexpConstraint extends AbstractConstraint { - private RegExp regExp; + private final RegExp regExp; public RegexpConstraint(String packageName, String simpleName, @@ -42,7 +42,10 @@ public void check(String value) throws MalioValidationException { if (value != null) { if (!this.regExp.test(value)) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/SizeConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/SizeConstraint.java index 28fcbb3..b6df302 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/SizeConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/SizeConstraint.java @@ -49,7 +49,10 @@ public void check(T value) int size = value.size(); if (size < this.min || size > this.max) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/UuidConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/UuidConstraint.java index 5b0c256..300cc0b 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/UuidConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/UuidConstraint.java @@ -41,7 +41,10 @@ public UuidConstraint(String packageName, public void check(String value) throws MalioValidationException { if (Objects.nonNull(value) && !UuidConstraint.regExp.test(value)) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/WhitelistConstraint.java b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/WhitelistConstraint.java index d38b5f1..bf07ff6 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/WhitelistConstraint.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/internal/constraint/WhitelistConstraint.java @@ -26,7 +26,7 @@ public class WhitelistConstraint extends AbstractConstraint { - private List whitelist; + private final List whitelist; public WhitelistConstraint(String packageName, String simpleName, @@ -43,7 +43,10 @@ public WhitelistConstraint(String packageName, public void check(String value) throws MalioValidationException { if (value != null && !whitelist.contains(value)) { - throw new MalioValidationException(getMessage(value)); + throw new MalioValidationException(getMessage(value), + super.getClassName(), + super.getSimpleName(), + super.getFieldName()); } } diff --git a/malio/src/main/java/com/github/nalukit/malio/shared/util/MalioValidationException.java b/malio/src/main/java/com/github/nalukit/malio/shared/util/MalioValidationException.java index 6ca0c91..100e068 100644 --- a/malio/src/main/java/com/github/nalukit/malio/shared/util/MalioValidationException.java +++ b/malio/src/main/java/com/github/nalukit/malio/shared/util/MalioValidationException.java @@ -15,14 +15,40 @@ */ package com.github.nalukit.malio.shared.util; -@SuppressWarnings("serial") public class MalioValidationException extends RuntimeException { + private String packageName; + private String simpleName; + private String fieldName; + public MalioValidationException() { } - public MalioValidationException(String message) { + public MalioValidationException(String message, + String packageName, + String simpleName, + String fieldName) { super(message); + this.packageName = packageName; + this.simpleName = simpleName; + this.fieldName = fieldName; + } + + public String getPackageName() { + return this.packageName; + } + + public String getSimpleName() { + return this.simpleName; } + + public String getFieldName() { + return this.fieldName; + } + + public String getClassName() { + return this.packageName + "." + this.simpleName; + } + }