org.qi4j.api.constraint
Class ConstraintViolationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.IllegalArgumentException
org.qi4j.api.constraint.ConstraintViolationException
- All Implemented Interfaces:
- java.io.Serializable
public class ConstraintViolationException
- extends java.lang.IllegalArgumentException
This Exception is thrown when there is one or more Constraint Violations in a method
call.
The Constraint Violations are aggregated per method, and this exception will contain those
violations, together with the Composite instance it happened on as well as the Method that
was invoked. The Exception also has support for localized messages of these violations.
This class is still under evolution. Beware that the methods, formatting, Locale spec may
change. It will be stable before the 1.0 release.
- See Also:
- Serialized Form
Methods inherited from class java.lang.Throwable |
fillInStackTrace, getCause, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ConstraintViolationException
public ConstraintViolationException(Composite instance,
java.lang.reflect.Member method,
java.util.Collection<ConstraintViolation> constraintViolations)
ConstraintViolationException
public ConstraintViolationException(java.lang.String instanceToString,
java.lang.Iterable<java.lang.Class<?>> instanceTypes,
java.lang.reflect.Member method,
java.util.Collection<ConstraintViolation> violations)
ConstraintViolationException
public ConstraintViolationException(java.lang.String instanceToString,
java.lang.Iterable<java.lang.Class<?>> instanceTypes,
java.lang.String mixinTypeName,
java.lang.String methodName,
java.util.Collection<ConstraintViolation> violations)
constraintViolations
public java.util.Collection<ConstraintViolation> constraintViolations()
localizedMessagesFrom
public java.lang.String[] localizedMessagesFrom(java.util.ResourceBundle bundle)
- Creates localized messages of all the constraint violations that has occured.
The key "
Qi4j_ConstraintViolation_CompositeType
" will be used to lookup the text formatting
pattern from the ResourceBundle, where CompositeType
is the
class name of the Composite where the constraint was violated. If such key does not exist, then the
key "Qi4j_ConstraintViolation
" will be used, and if that one also doesn't exist, or
the resourceBundle argument is null, then the default patterns will be used;
Type of Composite | Pattern used |
Composite |
Constraint Violation in {2}.{3} with constraint {4}, in composite \n{0} of type {1} |
EntityComposite |
Constraint Violation in {2}.{3} with constraint {4}, in entity {1}[id={0}] |
ServiceComposite |
Constraint Violation in {2}.{3} with constraint {4}, in service {0} |
Then format each ConstraintViolation according to such pattern, where the following argument are passed;
Arg | Value |
{0} |
Composite instance toString() |
{1} |
CompositeType class name |
{2} |
MixinType class name |
{3} |
MixinType method name |
{4} |
Annotation toString() |
{5} |
toString() of value passed as the argument, or "null" text if argument was null. |
NOTE!!! This class is still under construction and will be modified further.
- Parameters:
bundle
- The ResourceBundle for Localization, or null if default formatting and locale to be used.
- Returns:
- An array of localized messages of the violations incurred.
localizedMessage
public java.lang.String localizedMessage()
getLocalizedMessage
public java.lang.String getLocalizedMessage()
- Overrides:
getLocalizedMessage
in class java.lang.Throwable
getMessage
public java.lang.String getMessage()
- Overrides:
getMessage
in class java.lang.Throwable
methodName
public java.lang.String methodName()
mixinTypeName
public java.lang.String mixinTypeName()