Clover coverage report - brownies library - 1.0-beta-1
Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00
file stats: LOC: 70   Methods: 7
NCLOC: 43   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ValuedEnumSet.java 83.3% 87.5% 85.7% 86.2%
coverage coverage
 1   
 /*
 2   
  * Joey and its relative products are published under the terms
 3   
  * of the Apache Software License.
 4   
  */
 5   
 /*
 6   
  * Created on 2004/03/01
 7   
  */
 8   
 package org.asyrinx.brownie.core.lang.enum;
 9   
 
 10   
 import java.util.HashSet;
 11   
 import java.util.Iterator;
 12   
 import java.util.Set;
 13   
 
 14   
 import org.apache.commons.collections.Predicate;
 15   
 import org.apache.commons.lang.enum.Enum;
 16   
 import org.asyrinx.brownie.core.lang.UnsupportedClassRuntimeException;
 17   
 
 18   
 /**
 19   
  * @author akima
 20   
  */
 21   
 public class ValuedEnumSet extends EnumSet {
 22   
 
 23   
     /**
 24   
      *  
 25   
      */
 26  1
     public ValuedEnumSet(Class valuedEnumClass) {
 27  1
         super(valuedEnumClass);
 28   
     }
 29   
 
 30   
     /**
 31   
      * @see org.asyrinx.brownie.core.collection.EnumSet#toEntry(org.apache.commons.lang.enum.Enum)
 32   
      */
 33  4
     protected EnumSetEntry toEntry(Enum enum) {
 34  4
         if (enum instanceof ValuedEnum)
 35  4
             return new ValuedEnumSetEntry((ValuedEnum) enum);
 36   
         else
 37  0
             throw new UnsupportedClassRuntimeException(enum.getClass()
 38   
                     .getName());
 39   
     }
 40   
 
 41  3
     public Set getSelectedEnumValues() {
 42  3
         return toValueSet(new SelectedPredicate(true));
 43   
     }
 44   
 
 45  0
     public Set getUnselectedEnumValues() {
 46  0
         return toValueSet(new SelectedPredicate(false));
 47   
     }
 48   
 
 49  3
     protected final Set toValueSet(Predicate predicate) {
 50  3
         final Set result = new HashSet();
 51  3
         final Iterator iterator = this.iterator();
 52  3
         while (iterator.hasNext()) {
 53  12
             final ValuedEnumSetEntry entry = (ValuedEnumSetEntry) iterator
 54   
                     .next();
 55  12
             if (predicate.evaluate(entry))
 56  3
                 result.add(entry.getValue());
 57   
         }
 58  3
         return result;
 59   
     }
 60   
 
 61  4
     public EnumSetEntry getEntryByValue(final Object value) {
 62  4
         return findEntry(new Predicate() {
 63  10
             public boolean evaluate(Object input) {
 64  10
                 final ValuedEnumSetEntry entry = (ValuedEnumSetEntry) input;
 65  10
                 return value.equals(entry.getValue());
 66   
             }
 67   
         });
 68   
     }
 69   
 
 70   
 }