Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
../../../../img/srcFileCovDistChart5.png 38% of files have more coverage
21   122   13   3,5
14   46   0,62   6
6     2,17  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  State       Line # 41 21 0% 13 22 46,3% 0.46341464
 
  (342)
 
1    /*
2    * Copyright (c) 2003-2006, Simon Brown
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are met:
7    *
8    * - Redistributions of source code must retain the above copyright
9    * notice, this list of conditions and the following disclaimer.
10    *
11    * - Redistributions in binary form must reproduce the above copyright
12    * notice, this list of conditions and the following disclaimer in
13    * the documentation and/or other materials provided with the
14    * distribution.
15    *
16    * - Neither the name of Pebble nor the names of its contributors may
17    * be used to endorse or promote products derived from this software
18    * without specific prior written permission.
19    *
20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23    * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30    * POSSIBILITY OF SUCH DAMAGE.
31    */
32    package net.sourceforge.pebble.domain;
33   
34    import java.io.Serializable;
35   
36    /**
37    * Represents a state.
38    *
39    * @author Simon Brown
40    */
 
41    public class State implements Serializable {
42   
43    public static final State APPROVED = new State("approved");
44    public static final State REJECTED = new State("rejected");
45    public static final State PENDING = new State("pending");
46   
47    public static final State UNPUBLISHED = new State("unpublished");
48    public static final State PUBLISHED = new State("published");
49   
 
50  14 toggle public static State getState(String name) {
51  14 if (name == null) {
52  0 return null;
53  14 } else if (name.equals("approved")) {
54  0 return APPROVED;
55  14 } else if (name.equals("rejected")) {
56  0 return REJECTED;
57  14 } else if (name.equals("pending")) {
58  14 return PENDING;
59  0 } else if (name.equals("unpublished")) {
60  0 return UNPUBLISHED;
61  0 } else if (name.equals("published")) {
62  0 return PUBLISHED;
63    } else {
64  0 return null;
65    }
66    }
67   
68    /** the name of the state */
69    private String name;
70   
71    /**
72    * Creates a new instance.
73    *
74    * @param name the name of the state
75    */
 
76  10 toggle private State(String name) {
77  10 this.name = name;
78    }
79   
80    /**
81    * Gets the name of this state.
82    *
83    * @return the name as a String
84    */
 
85  3412 toggle public String getName() {
86  3412 return name;
87    }
88   
89    /**
90    * Gets the hashcode of this object.
91    *
92    * @return the hashcode as an int
93    */
 
94  0 toggle public int hashCode() {
95  0 return name.hashCode();
96    }
97   
98    /**
99    * Determines whether the specified object is equal to this one.
100    *
101    * @param o the object to compare against
102    * @return true if Object o represents the same category, false otherwise
103    */
 
104  3288 toggle public boolean equals(Object o) {
105  3288 if (!(o instanceof State)) {
106  0 return false;
107    }
108   
109  3288 State state = (State)o;
110  3288 return state.getName().equals(name);
111    }
112   
113    /**
114    * Returns a String representation of this object.
115    *
116    * @return a String
117    */
 
118  0 toggle public String toString() {
119  0 return this.name;
120    }
121   
122    }