Coverage Report - com.lexicalscope.jewel.cli.validation.ReportWrongFormatValues
 
Classes in this File Line Coverage Branch Coverage Complexity
ReportWrongFormatValues
100%
11/11
100%
4/4
2
 
 1  
 //
 2  
 //Author       : t.wood
 3  
 //Copyright    : (c) Resilient Networks plc 2012 - All Rights Reserved
 4  
 //
 5  
 package com.lexicalscope.jewel.cli.validation;
 6  
 
 7  
 import com.lexicalscope.fluent.map.PutVeto;
 8  
 import com.lexicalscope.jewel.cli.ValidationErrorBuilder;
 9  
 import com.lexicalscope.jewel.cli.specification.ParsedOptionSpecification;
 10  
 
 11  
 import java.util.List;
 12  
 
 13  198
 public class ReportWrongFormatValues implements PutVeto<ParsedOptionSpecification, List<String>>
 14  
 {
 15  
    private final ValidationErrorBuilder validationErrorBuilder;
 16  
 
 17  
    public ReportWrongFormatValues(final ValidationErrorBuilder validationErrorBuilder)
 18  226
    {
 19  226
       this.validationErrorBuilder = validationErrorBuilder;
 20  226
    }
 21  
 
 22  
    @Override
 23  
    public boolean allow(final ParsedOptionSpecification key, final List<String> values)
 24  
    {
 25  198
       boolean result = true;
 26  198
       for (final String value : values)
 27  
       {
 28  182
           if (!key.allowedValue(value))
 29  
           {
 30  6
               validationErrorBuilder.patternMismatch(key, value);
 31  6
               result = false;
 32  
           }
 33  182
       }
 34  198
       return result;
 35  
    }
 36  
 }