blob: c8c8b00057135f905fbbff1b267cc970f3e46447 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
package hu.bme.mit.inf.dslreasoner.faulttree.transformation.solver;
import org.eclipse.xtend.lib.annotations.Data;
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor;
import org.eclipse.xtext.xbase.lib.Pure;
import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;
@SuppressWarnings("all")
public abstract class ReliabilityResult {
@Data
public static final class Solution extends ReliabilityResult {
private final double lowerBound;
private final double upperBound;
public Solution(final double value) {
this(value, value);
}
public Solution(final double lowerBound, final double upperBound) {
if ((lowerBound > upperBound)) {
throw new IllegalArgumentException("lowerBound must not be larger than upperBound");
}
this.lowerBound = lowerBound;
this.upperBound = upperBound;
}
@Override
public ReliabilityResult.Solution getOrThrow() {
return this;
}
@Override
@Pure
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (int) (Double.doubleToLongBits(this.lowerBound) ^ (Double.doubleToLongBits(this.lowerBound) >>> 32));
return prime * result + (int) (Double.doubleToLongBits(this.upperBound) ^ (Double.doubleToLongBits(this.upperBound) >>> 32));
}
@Override
@Pure
public boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ReliabilityResult.Solution other = (ReliabilityResult.Solution) obj;
if (Double.doubleToLongBits(other.lowerBound) != Double.doubleToLongBits(this.lowerBound))
return false;
if (Double.doubleToLongBits(other.upperBound) != Double.doubleToLongBits(this.upperBound))
return false;
return true;
}
@Override
@Pure
public String toString() {
return new ToStringBuilder(this)
.addAllFields()
.toString();
}
@Pure
public double getLowerBound() {
return this.lowerBound;
}
@Pure
public double getUpperBound() {
return this.upperBound;
}
}
@Data
public static final class Unknown extends ReliabilityResult {
private final String message;
private final Throwable cause;
@FinalFieldsConstructor
public Unknown(final String message, final Throwable cause) {
super();
this.message = message;
this.cause = cause;
}
public Unknown(final String message) {
this(message, null);
}
@Override
public ReliabilityResult.Solution getOrThrow() {
throw new RuntimeException(this.message, this.cause);
}
@Override
@Pure
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((this.message== null) ? 0 : this.message.hashCode());
return prime * result + ((this.cause== null) ? 0 : this.cause.hashCode());
}
@Override
@Pure
public boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ReliabilityResult.Unknown other = (ReliabilityResult.Unknown) obj;
if (this.message == null) {
if (other.message != null)
return false;
} else if (!this.message.equals(other.message))
return false;
if (this.cause == null) {
if (other.cause != null)
return false;
} else if (!this.cause.equals(other.cause))
return false;
return true;
}
@Override
@Pure
public String toString() {
return new ToStringBuilder(this)
.addAllFields()
.toString();
}
@Pure
public String getMessage() {
return this.message;
}
@Pure
public Throwable getCause() {
return this.cause;
}
}
public static final ReliabilityResult.Unknown TIMEOUT = new ReliabilityResult.Unknown("Solver timed out");
public static final ReliabilityResult.Unknown MEMOUT = new ReliabilityResult.Unknown("Solver out of memory");
public abstract ReliabilityResult.Solution getOrThrow();
}
|