Skip to content

Commit 34b6384

Browse files
author
Steffen Märcker
committed
Simplify class Interval
By making Interval generic, the code is simplified. Please note that restricting the generic type to <T extends Number> is not possible yet, as this breaks code dealing with type Object only.
1 parent 658f654 commit 34b6384

1 file changed

Lines changed: 9 additions & 25 deletions

File tree

prism/src/prism/Interval.java

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,41 +28,25 @@
2828

2929
/**
3030
* This class stores an interval of numerical values.
31+
*
32+
* @param <T> Type of the interval
3133
*/
32-
public class Interval
34+
public class Interval<T extends Object>
3335
{
3436
// Lower/upper value
35-
public Object lower;
36-
public Object upper;
37-
37+
public T lower;
38+
public T upper;
39+
3840
/**
3941
* Construct an Interval.
40-
* (lower and upper should be of the same type: Integer or Double)
41-
*/
42-
public Interval(Object lower, Object upper)
43-
{
44-
this.lower = lower;
45-
this.upper = upper;
46-
}
47-
48-
/**
49-
* Construct an integer Interval.
42+
* Both bounds lower and upper should be of the same type.
5043
*/
51-
public Interval(Integer lower, Integer upper)
44+
public Interval(T lower, T upper)
5245
{
5346
this.lower = lower;
5447
this.upper = upper;
5548
}
56-
57-
/**
58-
* Construct a double Interval.
59-
*/
60-
public Interval(Double lower, Double upper)
61-
{
62-
this.lower = lower;
63-
this.upper = upper;
64-
}
65-
49+
6650
@Override
6751
public String toString()
6852
{

0 commit comments

Comments
 (0)