Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
40   163   27   2.86
22   92   0.68   14
14     1.93  
1    
 
  SubstPredVo       Line # 29 40 27 100% 1.0
 
  (29)
 
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.list.Element;
21    import org.qedeq.kernel.se.base.module.SubstPred;
22   
23   
24    /**
25    * Usage of rule for substitute predicate variable.
26    *
27    * @author Michael Meyling
28    */
 
29    public class SubstPredVo implements SubstPred {
30   
31    /** Reference to previously proven formula. */
32    private String reference;
33   
34    /** Function variable that will be substituted. */
35    private Element predicateVariable;
36   
37    /** Replacement formula. */
38    private Element substituteFormula;
39   
40    /**
41    * Constructs an reason.
42    *
43    * @param reference Reference to a valid formula.
44    * @param predicateVariable Predicate variable that will be substituted.
45    * @param substituteFormula Replacement formula.
46    */
47   
 
48  4176 toggle public SubstPredVo(final String reference, final Element predicateVariable,
49    final Element substituteFormula) {
50  4176 this.reference = reference;
51  4176 this.predicateVariable = predicateVariable;
52  4176 this.substituteFormula = substituteFormula;
53    }
54   
55    /**
56    * Default constructor.
57    */
 
58  49 toggle public SubstPredVo() {
59    // nothing to do
60    }
61   
 
62  12232 toggle public SubstPred getSubstPred() {
63  12232 return this;
64    }
65   
 
66  8980 toggle public String getReference() {
67  8980 return reference;
68    }
69   
70    /**
71    * Set formula reference.
72    *
73    * @param reference Reference to formula.
74    */
 
75  16 toggle public void setReference(final String reference) {
76  16 this.reference = reference;
77    }
78   
 
79  2 toggle public String[] getReferences() {
80  2 if (reference == null) {
81  1 return ArrayUtils.EMPTY_STRING_ARRAY;
82    }
83  1 return new String[] {reference };
84    }
85   
 
86  17012 toggle public Element getPredicateVariable() {
87  17012 return predicateVariable;
88    }
89   
90    /**
91    * Set predicate variable that will be substituted.
92    *
93    * @param predicateVariable Function variable that will be replaced.
94    */
 
95  18 toggle public void setPredicateVariable(final Element predicateVariable) {
96  18 this.predicateVariable = predicateVariable;
97    }
98   
 
99  23674 toggle public Element getSubstituteFormula() {
100  23674 return substituteFormula;
101    }
102   
103    /**
104    * Set substitution formula.
105    *
106    * @param substituteFormula New formula.
107    */
 
108  18 toggle public void setSubstituteFormula(final Element substituteFormula) {
109  18 this.substituteFormula = substituteFormula;
110    }
111   
 
112  2589 toggle public String getName() {
113  2589 return "SubstPred";
114    }
115   
 
116  49 toggle public boolean equals(final Object obj) {
117  49 if (!(obj instanceof SubstPred)) {
118  5 return false;
119    }
120  44 final SubstPred other = (SubstPred) obj;
121  44 return EqualsUtility.equals(getReference(), other.getReference())
122    && EqualsUtility.equals(predicateVariable, other.getPredicateVariable())
123    && EqualsUtility.equals(substituteFormula, other.getSubstituteFormula());
124    }
125   
 
126  52 toggle public int hashCode() {
127  52 return (getReference() != null ? getReference().hashCode() : 0)
128  52 ^ (getPredicateVariable() != null ? 2 ^ getPredicateVariable().hashCode() : 0)
129  52 ^ (getSubstituteFormula() != null ? 3 ^ getSubstituteFormula().hashCode() : 0);
130    }
131   
 
132  1178 toggle public String toString() {
133  1178 StringBuffer result = new StringBuffer();
134  1178 result.append(getName());
135  1178 if (getReference() != null || getPredicateVariable() != null
136    || getSubstituteFormula() != null) {
137  1154 result.append(" (");
138  1154 boolean w = false;
139  1154 if (getReference() != null) {
140  1132 result.append(getReference());
141  1132 w = true;
142    }
143  1154 if (getPredicateVariable() != null) {
144  1122 if (w) {
145  1105 result.append(", ");
146    }
147  1122 result.append(getPredicateVariable());
148  1122 w = true;
149    }
150  1154 if (getSubstituteFormula() != null) {
151  1120 if (w) {
152  1115 result.append(", ");
153    }
154  1120 result.append("by ");
155  1120 result.append(getSubstituteFormula());
156  1120 w = true;
157    }
158  1154 result.append(")");
159    }
160  1178 return result.toString();
161    }
162   
163    }