Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
32   134   23   2.67
20   74   0.72   12
12     1.92  
1    
 
  ModusPonensVo       Line # 28 32 23 100% 1.0
 
  (36)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.se.dto.module;
17   
18    import org.apache.commons.lang.ArrayUtils;
19    import org.qedeq.base.utility.EqualsUtility;
20    import org.qedeq.kernel.se.base.module.ModusPonens;
21   
22   
23    /**
24    * Modes Ponens usage.
25    *
26    * @author Michael Meyling
27    */
 
28    public class ModusPonensVo implements ModusPonens {
29   
30    /** Usually reference to a formula like A -> B. */
31    private String reference1;
32   
33    /** Usually reference to a formula like A. */
34    private String reference2;
35   
36    /**
37    * Constructs a Modus Ponens argument.
38    *
39    * @param reference1 Usually reference to a formula like A -> B. Might be <code>null</code>.
40    * @param reference2 Usually reference to a formula like A. Might be <code>null</code>.
41    */
 
42  2960 toggle public ModusPonensVo(final String reference1, final String reference2) {
43  2960 this.reference1 = reference1;
44  2960 this.reference2 = reference2;
45    }
46   
47    /**
48    * Default constructor.
49    */
 
50  124 toggle public ModusPonensVo() {
51    // nothing to do
52    }
53   
 
54  4220 toggle public ModusPonens getModusPonens() {
55  4220 return this;
56    }
57   
 
58  9760 toggle public String getReference1() {
59  9760 return reference1;
60    }
61   
62    /**
63    * Set first formula reference.
64    *
65    * @param reference1 Reference to formula. Might be <code>null</code>.
66    */
 
67  98 toggle public void setReference1(final String reference1) {
68  98 this.reference1 = reference1;
69    }
70   
 
71  5939 toggle public String getReference2() {
72  5939 return reference2;
73    }
74   
75    /**
76    * Set second formula reference.
77    *
78    * @param reference2 Reference to formula. Might be <code>null</code>.
79    */
 
80  98 toggle public void setReference2(final String reference2) {
81  98 this.reference2 = reference2;
82    }
83   
 
84  4 toggle public String[] getReferences() {
85  4 if (reference1 == null) {
86  2 if (reference2 == null) {
87  1 return ArrayUtils.EMPTY_STRING_ARRAY;
88    }
89  1 return new String[] {reference2 };
90    }
91  2 if (reference2 == null) {
92  1 return new String[] {reference1 };
93    }
94  1 return new String[] {reference1, reference2 };
95    }
96   
 
97  151 toggle public boolean equals(final Object obj) {
98  151 if (!(obj instanceof ModusPonens)) {
99  6 return false;
100    }
101  145 final ModusPonens other = (ModusPonens) obj;
102  145 return EqualsUtility.equals(getReference1(), other.getReference1())
103    && EqualsUtility.equals(getReference2(), other.getReference2());
104    }
105   
 
106  235 toggle public int hashCode() {
107  235 return (getReference1() != null ? getReference1().hashCode() : 0)
108  235 + (getReference2() != null ? 1 ^ getReference2().hashCode() : 0);
109    }
110   
 
111  1067 toggle public String toString() {
112  1067 StringBuffer result = new StringBuffer();
113  1067 result.append(getName());
114  1067 if (getReference1() != null || getReference2() != null) {
115  1046 result.append(" (");
116  1046 if (getReference1() != null) {
117  1037 result.append(getReference1());
118    }
119  1046 if (getReference2() != null) {
120  1039 if (getReference1() != null) {
121  1030 result.append(", ");
122    }
123  1039 result.append(getReference2());
124    }
125  1046 result.append(")");
126    }
127  1067 return result.toString();
128    }
129   
 
130  2125 toggle public String getName() {
131  2125 return "MP";
132    }
133   
134    }