| 1 | package de.uka.ipd.sdq.probfunction.math; |
| 2 | |
| 3 | import de.uka.ipd.sdq.probfunction.math.exception.ConfigurationNotSetException; |
| 4 | |
| 5 | public class PDFConfiguration { |
| 6 | |
| 7 | private static PDFConfiguration currentConfiguration = null; |
| 8 | |
| 9 | private int numSamplingPoints; |
| 10 | |
| 11 | private double distance; |
| 12 | |
| 13 | private IUnit unit; |
| 14 | |
| 15 | private static Object lock = new Object(); |
| 16 | |
| 17 | private PDFConfiguration(int numSamplingPoints, double distance, IUnit unit) { |
| 18 | super(); |
| 19 | this.numSamplingPoints = numSamplingPoints; |
| 20 | this.distance = distance; |
| 21 | this.unit = unit; |
| 22 | } |
| 23 | |
| 24 | public double getDistance() { |
| 25 | return distance; |
| 26 | } |
| 27 | |
| 28 | public int getNumSamplingPoints() { |
| 29 | return numSamplingPoints; |
| 30 | } |
| 31 | |
| 32 | public IUnit getUnit() { |
| 33 | return unit; |
| 34 | } |
| 35 | |
| 36 | public static PDFConfiguration getCurrentConfiguration() throws ConfigurationNotSetException{ |
| 37 | synchronized (lock) { |
| 38 | if (currentConfiguration == null) |
| 39 | throw new ConfigurationNotSetException(); |
| 40 | return currentConfiguration; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | public static void setCurrentConfiguration(int numSamplingPoints, double distance, IUnit unit){ |
| 45 | synchronized (lock) { |
| 46 | currentConfiguration = new PDFConfiguration(numSamplingPoints,distance,unit); |
| 47 | } |
| 48 | } |
| 49 | } |