Coverage Report - com.lexicalscope.jewel.cli.validation.ReportWrongNumberOfValues
 
Classes in this File Line Coverage Branch Coverage Complexity
ReportWrongNumberOfValues
100%
8/8
100%
2/2
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  228
 public class ReportWrongNumberOfValues implements PutVeto<ParsedOptionSpecification, List<String>>
 14  
 {
 15  
    private final ValidationErrorBuilder validationErrorBuilder;
 16  
 
 17  
    public ReportWrongNumberOfValues(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  228
       if (!key.allowedThisManyValues(values.size()))
 26  
       {
 27  30
           validationErrorBuilder.wrongNumberOfValues(key, values);
 28  30
           return false;
 29  
       }
 30  198
       return true;
 31  
    }
 32  
 }