Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 
 /*
  * Carrot2 project.
  *
  * Copyright (C) 2002-2012, Dawid Weiss, Stanisław Osiński.
  * All rights reserved.
  *
  * Refer to the full license file "carrot2.LICENSE"
  * in the root folder of the repository checkout or at:
 * http://www.carrot2.org/carrot2.LICENSE
 */
package org.carrot2.util.attribute.constraint;
An exception thrown when an attempt is made to bind attribute values that do not meet the constraints.
{
    
Value that does not meet the constraints.
    public final Object offendingValue;

    
Constraints that were not met by the offendingValue.
    public final Annotation [] annotations;

    
    public final String key;

    
    public ConstraintViolationException(String keyObject offendngValue,
        Annotation... annotations)
    {
        this. = offendngValue;
        this. = annotations;
        this. = key;
    }
    @Override
    public String getMessage()
    {
        final StringBuilder constraintsString = new StringBuilder();
        final List<Constraintconstraints = 
            Lists.newArrayList(ConstraintFactory.createConstraints());
        for (int i = 0; i < constraints.size(); i++)
        {
            constraintsString.append("@");
            constraintsString.append([i].annotationType().getSimpleName());
            constraintsString.append(": ");
            constraintsString.append(constraints.get(i).toString());
            if (i != . - 1)
            {
                constraintsString.append(", ");
            }
        }
        return "Value: '" +  + "' of attribute: '" + 
            + "' violates constraints: " + constraintsString;
    }
New to GrepCode? Check out our FAQ X