Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HV-807 Allowing to ignore constraint annotations for methods/construc…
…tors via API
- Loading branch information
1 parent
a236fca
commit 03faf18
Showing
18 changed files
with
473 additions
and
27 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
engine/src/main/java/org/hibernate/validator/cfg/context/AnnotationIgnoreOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.cfg.context; | ||
|
||
/** | ||
* Facet of a constraint mapping creational context which allows to configure how existing annotation should be treated. | ||
* | ||
* @author Gunnar Morling | ||
*/ | ||
public interface AnnotationIgnoreOptions<C extends AnnotationIgnoreOptions<C>> { | ||
|
||
/** | ||
* Specifies whether annotations at the given element should be ignored or not, overriding any setting given for | ||
* parent elements. E.g. the setting given for a method parameter overrides the setting given for the method | ||
* declaring that parameter. | ||
* | ||
* @param ignoreAnnotations Whether to ignore annotation-based constraints or not. | ||
* @return This context for method chaining. | ||
*/ | ||
C ignoreAnnotations(boolean ignoreAnnotations); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...org/hibernate/validator/internal/cfg/context/ConstructorConstraintMappingContextImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.internal.cfg.context; | ||
|
||
import java.lang.reflect.Constructor; | ||
|
||
import org.hibernate.validator.cfg.context.ConstructorConstraintMappingContext; | ||
|
||
/** | ||
* Constraint mapping creational context representing a constructor. | ||
* | ||
* @author Gunnar Morling | ||
*/ | ||
class ConstructorConstraintMappingContextImpl extends ExecutableConstraintMappingContextImpl implements ConstructorConstraintMappingContext { | ||
|
||
<T> ConstructorConstraintMappingContextImpl(TypeConstraintMappingContextImpl<T> typeContext, Constructor<T> constructor) { | ||
super( typeContext, constructor ); | ||
} | ||
|
||
@Override | ||
public ConstructorConstraintMappingContext ignoreAnnotations(boolean ignoreAnnotations) { | ||
typeContext.mapping | ||
.getAnnotationProcessingOptions() | ||
.ignoreConstraintAnnotationsOnMember( executable.getMember(), ignoreAnnotations ); | ||
|
||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...java/org/hibernate/validator/internal/cfg/context/MethodConstraintMappingContextImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.internal.cfg.context; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import org.hibernate.validator.cfg.context.MethodConstraintMappingContext; | ||
|
||
/** | ||
* Constraint mapping creational context representing a method. | ||
* | ||
* @author Gunnar Morling | ||
*/ | ||
class MethodConstraintMappingContextImpl extends ExecutableConstraintMappingContextImpl implements MethodConstraintMappingContext { | ||
|
||
MethodConstraintMappingContextImpl(TypeConstraintMappingContextImpl<?> typeContext, Method method) { | ||
super( typeContext, method ); | ||
} | ||
|
||
@Override | ||
public MethodConstraintMappingContext ignoreAnnotations(boolean ignoreAnnotations) { | ||
typeContext.mapping | ||
.getAnnotationProcessingOptions() | ||
.ignoreConstraintAnnotationsOnMember( executable.getMember(), ignoreAnnotations ); | ||
|
||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.