Package: BooleanServices

BooleanServices

nameinstructionbranchcomplexitylinemethod
BooleanServices()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
and(Boolean, Boolean)
M: 11 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
implies(Boolean, Boolean)
M: 10 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
not(Boolean)
M: 8 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
or(Boolean, Boolean)
M: 11 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
xor(Boolean, Boolean)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2015 Obeo.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * Obeo - initial API and implementation
10: *******************************************************************************/
11: package org.eclipse.acceleo.query.services;
12:
13: import org.eclipse.acceleo.annotations.api.documentation.Documentation;
14: import org.eclipse.acceleo.annotations.api.documentation.Example;
15: import org.eclipse.acceleo.annotations.api.documentation.Param;
16: import org.eclipse.acceleo.annotations.api.documentation.ServiceProvider;
17:
18: //@formatter:off
19: @ServiceProvider(
20:         value = "Services available for Booleans"
21: )
22: //@formatter:on
23: @SuppressWarnings({"checkstyle:javadocmethod", "checkstyle:javadoctype" })
24: public class BooleanServices {
25:
26:         // @formatter:off
27:         @Documentation(
28:                 value = "Logical or.",
29:                 params = {
30:                         @Param(name = "op1", value = "The first operand"),
31:                         @Param(name = "op2", value = "The second operand")
32:                 },
33:                 result = "The logical or of the two operands",
34:                 examples = {
35:                         @Example(expression = "true or false", result = "true"),
36:                         @Example(expression = "false or true", result = "true"),
37:                         @Example(expression = "true or true", result = "true"),
38:                         @Example(expression = "false or false", result = "false")
39:                 }
40:         )
41:         // @formatter:on
42:         public Boolean or(Boolean op1, Boolean op2) {
43:•                return Boolean.valueOf(op1.booleanValue() || op2.booleanValue());
44:         }
45:
46:         // @formatter:off
47:         @Documentation(
48:                 value = "Logical and.",
49:                 params = {
50:                         @Param(name = "op1", value = "The first operand"),
51:                         @Param(name = "op2", value = "The second operand")
52:                 },
53:                 result = "The logical and of the two operands",
54:                 examples = {
55:                         @Example(expression = "true and false", result = "false"),
56:                         @Example(expression = "false and true", result = "false"),
57:                         @Example(expression = "true and true", result = "true"),
58:                         @Example(expression = "false and false", result = "false")
59:                 }
60:         )
61:         // @formatter:on
62:         public Boolean and(Boolean op1, Boolean op2) {
63:•                return Boolean.valueOf(op1.booleanValue() && op2.booleanValue());
64:         }
65:
66:         // @formatter:off
67:         @Documentation(
68:                 value = "Logical negation.",
69:                 params = {
70:                         @Param(name = "op1", value = "The operand")
71:                 },
72:                 result = "The logical negation of the operand",
73:                 examples = {
74:                         @Example(expression = "not true", result = "false"),
75:                         @Example(expression = "not false", result = "true")
76:                 }
77:         )
78:         // @formatter:on
79:         public Boolean not(Boolean op1) {
80:•                return Boolean.valueOf(!op1.booleanValue());
81:         }
82:
83:         /**
84:          * Logical implies.
85:          *
86:          * @param op1
87:          * the first operand
88:          * @param op2
89:          * the second operand
90:          * @return the logical implies of the two operands
91:          */
92:         // @formatter:off
93:         @Documentation(
94:                 value = "Logical implies.",
95:                 params = {
96:                         @Param(name = "op1", value = "The first operand"),
97:                         @Param(name = "op2", value = "The second operand"),
98:                 },
99:                 result = "The logical implies of the operands",
100:                 examples = {
101:                         @Example(expression = "true implies true", result = "true"),
102:                         @Example(expression = "true implies false", result = "false"),
103:                         @Example(expression = "false implies true", result = "true"),
104:                         @Example(expression = "false implies false", result = "true"),
105:                 }
106:         )
107:         // @formatter:on
108:         public Boolean implies(Boolean op1, Boolean op2) {
109:                 final Boolean result;
110:
111:•                if (!op1.booleanValue()) {
112:                         result = Boolean.TRUE;
113:                 } else {
114:                         result = op2;
115:                 }
116:
117:                 return result;
118:         }
119:
120:         // @formatter:off
121:         @Documentation(
122:                 value = "Logical xor.",
123:                 params = {
124:                         @Param(name = "op1", value = "The first operand"),
125:                         @Param(name = "op2", value = "The second operand"),
126:                 },
127:                 result = "The logical xor of the operands",
128:                 examples = {
129:                         @Example(expression = "true xor true", result = "false"),
130:                         @Example(expression = "true xor false", result = "true"),
131:                         @Example(expression = "false xor true", result = "true"),
132:                         @Example(expression = "false xor false", result = "false"),
133:                 }
134:         )
135:         // @formatter:on
136:         public Boolean xor(Boolean op1, Boolean op2) {
137:                 return Boolean.valueOf(op1.booleanValue() ^ op2.booleanValue());
138:         }
139:
140: }