1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.probfunction.math.impl; |
5 | |
6 | import de.uka.ipd.sdq.probfunction.math.ISample; |
7 | import de.uka.ipd.sdq.probfunction.math.util.MathTools; |
8 | |
9 | /** |
10 | * @author Ihssane |
11 | * |
12 | */ |
13 | public class SampleImpl implements ISample { |
14 | |
15 | |
16 | private double probability; |
17 | private Object value; |
18 | |
19 | /** |
20 | * @param value |
21 | * @param probability |
22 | */ |
23 | protected SampleImpl(Object value, double probability) { |
24 | super(); |
25 | this.probability = probability; |
26 | this.value = value; |
27 | } |
28 | |
29 | public double getProbability() { |
30 | return probability; |
31 | } |
32 | |
33 | public void setProbability(double probability) { |
34 | this.probability = probability; |
35 | } |
36 | |
37 | public Object getValue() { |
38 | return value; |
39 | } |
40 | |
41 | public void setValue(Object value) { |
42 | this.value = value; |
43 | } |
44 | |
45 | /** |
46 | * @see java.lang.Object#equals(java.lang.Object) |
47 | */ |
48 | @Override |
49 | public boolean equals(Object obj) { |
50 | if(obj instanceof ISample) { |
51 | return this.getValue().equals(((ISample) obj).getValue()) |
52 | && MathTools.equalsDouble(this.getProbability(), |
53 | ((ISample) obj).getProbability()); |
54 | } |
55 | return false; |
56 | } |
57 | |
58 | |
59 | @Override |
60 | public String toString() { |
61 | return "(" + getValue() + ", " + MathTools.asString( getProbability() ) + ")"; |
62 | } |
63 | |
64 | } |