public class InvalidElementImpl extends java.lang.Object implements InvalidElement
Constructor and Description |
---|
InvalidElementImpl(Element element,
java.lang.Object invalidValue) |
InvalidElementImpl(Element element,
java.lang.Object invalidValue,
java.util.Collection<java.lang.annotation.Annotation> violatedConstraints) |
Modifier and Type | Method and Description |
---|---|
void |
addViolatedConstraint(java.lang.Class<? extends java.lang.annotation.Annotation> constraint,
java.lang.annotation.Annotation annotation) |
java.lang.Class |
declaringClass() |
<T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class<T> annotationClass) |
java.lang.annotation.Annotation[] |
getAnnotations() |
java.lang.annotation.Annotation[] |
getDeclaredAnnotations() |
ValueHandler |
in(java.lang.Object target)
Handles this element on the given target (if applies).
|
java.lang.Object |
invalidValue()
Returns the invalid value.
|
boolean |
isConstraintViolated(java.lang.Class<? extends java.lang.annotation.Annotation> constraint) |
boolean |
isReadable() |
boolean |
isSpecific()
Checks if this element is specific for a target.
|
boolean |
isWritable() |
java.lang.String |
name() |
void |
set(java.lang.Object value)
Sets the value if this element is
specific . |
<E> E |
target()
Returns the target for this element in case of a
specific one. |
java.lang.Class |
type() |
<E> E |
value()
Returns the value if this element is
specific . |
java.lang.annotation.Annotation |
violatedConstraint(java.lang.Class<? extends java.lang.annotation.Annotation> constraint) |
java.util.Collection<java.lang.annotation.Annotation> |
violatedConstraints()
Returns a list of the annotation that defines constraints violated by this
element.
|
public InvalidElementImpl(Element element, java.lang.Object invalidValue)
public InvalidElementImpl(Element element, java.lang.Object invalidValue, java.util.Collection<java.lang.annotation.Annotation> violatedConstraints)
public java.lang.annotation.Annotation violatedConstraint(java.lang.Class<? extends java.lang.annotation.Annotation> constraint)
violatedConstraint
in interface InvalidElement
constraint
- the constraint annotation typenull
if the constraint
is not present in the element or it was not violated.public boolean isConstraintViolated(java.lang.Class<? extends java.lang.annotation.Annotation> constraint)
isConstraintViolated
in interface InvalidElement
constraint
- the constraint annotation typetrue
if the given constraint is violated in this
element or false
if is not defined or violated.public void addViolatedConstraint(java.lang.Class<? extends java.lang.annotation.Annotation> constraint, java.lang.annotation.Annotation annotation)
public java.lang.Object invalidValue()
InvalidElement
Note that this method may not return the same value as Element.value()
because the element value may change after the validation.
invalidValue
in interface InvalidElement
public java.util.Collection<java.lang.annotation.Annotation> violatedConstraints()
InvalidElement
The annotations can be used to create validation messages.
violatedConstraints
in interface InvalidElement
public java.lang.Class declaringClass()
declaringClass
in interface Element
public java.lang.String name()
public java.lang.Class type()
public boolean isReadable()
isReadable
in interface Element
true
if the value of this element can be read.public boolean isWritable()
isWritable
in interface Element
true
if the value of this element can be change.public ValueHandler in(java.lang.Object target)
Element
This method may throw exceptions in case of the element cannot be handled or an error occurring while handling the element.
in
in interface Element
in
in interface Result<ValueHandler,java.lang.Object>
target
- the target that contains this element.public boolean isSpecific()
Element
true
, then the methods Element.value()
and
Element.set(Object)
can be used.isSpecific
in interface Element
true
if this element is specific for a target.public <E> E target()
Element
specific
one.public <E> E value() throws HandlingException
Element
specific
.value
in interface Element
value
in interface ValueHandler
HandlingException
- if anything go wrong.public void set(java.lang.Object value) throws HandlingException
Element
specific
.set
in interface Element
set
in interface ValueHandler
value
- the value to set.HandlingException
- if anything go wrongpublic <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> annotationClass)
getAnnotation
in interface java.lang.reflect.AnnotatedElement
public java.lang.annotation.Annotation[] getAnnotations()
getAnnotations
in interface java.lang.reflect.AnnotatedElement
public java.lang.annotation.Annotation[] getDeclaredAnnotations()
getDeclaredAnnotations
in interface java.lang.reflect.AnnotatedElement