diff --git a/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintAttributes.java b/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintAttributes.java index c315f08..d9dde84 100644 --- a/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintAttributes.java +++ b/valdr-bean-validation/src/main/java/com/github/valdr/ConstraintAttributes.java @@ -40,6 +40,14 @@ public int size() { public Object put(String key, Object value) { return map.put(key, value); } + + public Object remove(String key) { + return map.remove(key); + } + + public Object get(String key) { + return map.get(key); + } private void removeUnusedAttributes(Map annotationAttributes) { Iterator it = annotationAttributes.keySet().iterator(); diff --git a/valdr-bean-validation/src/main/java/com/github/valdr/decorator/PatternDecorator.java b/valdr-bean-validation/src/main/java/com/github/valdr/decorator/PatternDecorator.java index 738f904..12d0c53 100644 --- a/valdr-bean-validation/src/main/java/com/github/valdr/decorator/PatternDecorator.java +++ b/valdr-bean-validation/src/main/java/com/github/valdr/decorator/PatternDecorator.java @@ -1,10 +1,11 @@ package com.github.valdr.decorator; -import com.github.valdr.ConstraintAttributes; - +import java.util.HashMap; import java.util.Map; import java.util.Set; +import com.github.valdr.ConstraintAttributes; + /** * Decorates the map of attributes of the {@link javax.validation.constraints.Pattern} constraint. */ @@ -31,12 +32,15 @@ public PatternDecorator(ConstraintAttributes decoratee) { @Override public Set> entrySet() { Set> entrySet = getDecoratee().entrySet(); + Map result = new HashMap<>(); for (Map.Entry entry : entrySet) { if ("regexp".equals(entry.getKey())) { - entry.setValue(javaToJavaScriptRegexpPattern(entry)); + result.put("value", javaToJavaScriptRegexpPattern(entry)); + } else { + result.put(entry.getKey(), entry.getValue()); } } - return entrySet; + return result.entrySet(); } private String javaToJavaScriptRegexpPattern(Map.Entry entry) {