2009/04/15 - Apache HiveMind has been retired.

For more information, please explore the Attic.

Clover coverage report - Code Coverage for hivemind release 1.2.1
Coverage timestamp: Fri Feb 10 2006 16:33:43 PST
file stats: LOC: 105   Methods: 8
NCLOC: 52   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Occurances.java - 100% 100% 100%
coverage
 1    // Copyright 2004, 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.hivemind;
 16   
 17    /**
 18    * Identifies the number of contributions allowed to a configuration extension point.
 19    *
 20    * @author Howard Lewis Ship
 21    */
 22    public abstract class Occurances
 23    {
 24    /**
 25    * An unbounded number, zero or more.
 26    */
 27    public static final Occurances UNBOUNDED = new Occurances("UNBOUNDED")
 28    {
 29  1030 public boolean inRange(int count)
 30    {
 31  1030 return true;
 32    }
 33    };
 34   
 35    /**
 36    * Optional, may be zero or one, but not more.
 37    */
 38   
 39    public static final Occurances OPTIONAL = new Occurances("OPTIONAL")
 40    {
 41  4 public boolean inRange(int count)
 42    {
 43  4 return count < 2;
 44    }
 45    };
 46   
 47    /**
 48    * Exactly one is required.
 49    */
 50   
 51    public static final Occurances REQUIRED = new Occurances("REQUIRED")
 52    {
 53  486 public boolean inRange(int count)
 54    {
 55  486 return count == 1;
 56    }
 57    };
 58   
 59    /**
 60    * At least one is required.
 61    */
 62   
 63    public static final Occurances ONE_PLUS = new Occurances("ONE_PLUS")
 64    {
 65  13 public boolean inRange(int count)
 66    {
 67  13 return count > 0;
 68    }
 69    };
 70   
 71    public static final Occurances NONE = new Occurances("NONE")
 72    {
 73  8 public boolean inRange(int count)
 74    {
 75  8 return count == 0;
 76    }
 77    };
 78   
 79    private String _name;
 80   
 81  5 private Occurances(String name)
 82    {
 83  5 _name = name;
 84    }
 85   
 86  4 public String getName()
 87    {
 88  4 return _name;
 89    }
 90   
 91  2 public String toString()
 92    {
 93  2 return "Occurances[" + _name + "]";
 94    }
 95   
 96    /**
 97    * Validates that an actual count is in range for the particular Occurances count.
 98    *
 99    * @param count
 100    * the number of items to check. Should be zero or greater.
 101    * @return true if count is a valid number in accordance to the range, false otherwise
 102    */
 103    public abstract boolean inRange(int count);
 104   
 105    }