Skip to content

Commit

Permalink
Simplify class Interval
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Steffen Märcker authored and merkste committed Aug 27, 2021
1 parent 09c5dcf commit 8a20d38
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions prism/src/prism/Interval.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,25 @@

/**
* This class stores an interval of numerical values.
*
* @param <T> Type of the interval
*/
public class Interval
public class Interval<T extends Object>
{
// Lower/upper value
public Object lower;
public Object upper;
public T lower;
public T upper;

/**
* Construct an Interval.
* (lower and upper should be of the same type: Integer or Double)
*/
public Interval(Object lower, Object upper)
{
this.lower = lower;
this.upper = upper;
}

/**
* Construct an integer Interval.
* Both bounds lower and upper should be of the same type.
*/
public Interval(Integer lower, Integer upper)
public Interval(T lower, T upper)
{
this.lower = lower;
this.upper = upper;
}

/**
* Construct a double Interval.
*/
public Interval(Double lower, Double upper)
{
this.lower = lower;
this.upper = upper;
}


@Override
public String toString()
{
Expand Down

0 comments on commit 8a20d38

Please sign in to comment.