Package org.djutils.math.functions
Record Class Interval<T extends Comparable<T>>
java.lang.Object
java.lang.Record
org.djutils.math.functions.Interval<T>
- Type Parameters:
 T- the payload type- Record Components:
 low- low limit of the domainlowInclusive- if true; the low limit is included; if false, the low limit is not includedhigh- high limit of the domain (inclusive)highInclusive- if true; the high limit is included; if false; the high limit is not includedpayload- the payload of this Interval. This is can be anything, but it is usually the MathFunction that is active in this Interval. When the Interval field is not used, supply any comparable class (e.g. String) and provide a null value to the constructor of Interval
- All Implemented Interfaces:
 Comparable<Interval<T>>
record Interval<T extends Comparable<T>>(double low, boolean lowInclusive, double high, boolean highInclusive, T extends Comparable<T> payload)
extends Record
implements Comparable<Interval<T>>
Immutable double interval, optionally including none, one, or both boundary values.
 
Copyright (c) 2024-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
- Author:
 - Alexander Verbraeck, Peter Knoppers, Wouter Schakel
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionintbooleancovers(double x) Check if a value falls on this Interval.booleanCheck if this Interval completely covers some other Interval.booleanCheck if this Interval is completely disjunct of some other Interval.booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.doublehigh()Returns the value of thehighrecord component.booleanReturns the value of thehighInclusiverecord component.intersection(Interval<?> other) Compute the intersection of thisIntervaland some otherInterval.doublelow()Returns the value of thelowrecord component.booleanReturns the value of thelowInclusiverecord component.payload()Returns the value of thepayloadrecord component.toString()Returns a string representation of this record class. 
- 
Constructor Details
- 
Interval
Interval(double low, boolean lowInclusive, double high, boolean highInclusive, T payload) Construct a new Interval.- Parameters:
 low- low limit of the domainlowInclusive- if true; the low limit is included; if false, the low limit is not includedhigh- high limit of the domain (inclusive)highInclusive- if true; the high limit is included; if false; the high limit is not includedpayload- the payload of this Interval
 
 - 
 - 
Method Details
- 
covers
Check if this Interval completely covers some other Interval.- Parameters:
 other- the other Interval (not necessarily carrying a similarly typed pay load)- Returns:
 - boolean; true if this Interval completely covers the other Interval; false if any part of other Interval (which may be infinitesimally small) is outside this Interval
 
 - 
disjunct
Check if this Interval is completely disjunct of some other Interval.- Parameters:
 other- the other Interval (not necessarily carrying a similarly typed pay load)- Returns:
 - boolean; true if this Interval is completely disjunct of the other Interval; false if any part of this Interval (which may be infinitesimally small) covers the other Interval
 
 - 
compareTo
- Specified by:
 compareToin interfaceComparable<T extends Comparable<T>>
 - 
covers
public boolean covers(double x) Check if a value falls on this Interval.- Parameters:
 x- the value to check- Returns:
 - true if 
xlies on this Interval 
 - 
intersection
Compute the intersection of thisIntervaland some otherInterval. The other Interval need not have the same type of payload.- Parameters:
 other- the otherInterval- Returns:
 - the intersection of the intervals (can be 
null). If not null, the payload is the payload ofthisinterval 
 - 
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. - 
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. - 
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. - 
low
public double low()Returns the value of thelowrecord component.- Returns:
 - the value of the 
lowrecord component 
 - 
lowInclusive
public boolean lowInclusive()Returns the value of thelowInclusiverecord component.- Returns:
 - the value of the 
lowInclusiverecord component 
 - 
high
public double high()Returns the value of thehighrecord component.- Returns:
 - the value of the 
highrecord component 
 - 
highInclusive
public boolean highInclusive()Returns the value of thehighInclusiverecord component.- Returns:
 - the value of the 
highInclusiverecord component 
 - 
payload
Returns the value of thepayloadrecord component.- Returns:
 - the value of the 
payloadrecord component 
 
 -