net.minestom.server.utils.Range Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.utils;
/**
* Represents the base for any data type that is numeric.
*
* @param The type numeric of the range object.
*/
public sealed interface Range {
record Byte(byte min, byte max) implements Range {
public Byte(byte value) {
this(value, value);
}
public boolean inRange(byte value) {
return value >= min && value <= max;
}
}
record Short(short min, short max) implements Range {
public Short(short value) {
this(value, value);
}
public boolean inRange(short value) {
return value >= min && value <= max;
}
}
record Int(int min, int max) implements Range {
public Int(int value) {
this(value, value);
}
public boolean inRange(int value) {
return value >= min && value <= max;
}
}
record Long(long min, long max) implements Range {
public Long(long value) {
this(value, value);
}
public boolean inRange(long value) {
return value >= min && value <= max;
}
}
record Float(float min, float max) implements Range {
public Float(float value) {
this(value, value);
}
public boolean inRange(float value) {
return value >= min && value <= max;
}
}
record Double(double min, double max) implements Range {
public Double(double value) {
this(value, value);
}
public boolean inRange(double value) {
return value >= min && value <= max;
}
}
}