Record Class Range
java.lang.Object
java.lang.Record
net.flectone.pulse.model.value.Range
- Record Components:
value- the block radius, or the marker value of the named typetype- which of the two forms this range takes
How far a message travels, either a radius in blocks or one of the named scopes
such as the whole server or the entire proxy network.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionRange(int value) Creates a range covering the given radius in blocks.Range(int value, Range.Type type) Creates an instance of aRangerecord class.Range(Range.Type type) Creates a range for one of the named scopes. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static RangeReads a range from its config representation, accepting either a block count or a scope name.fromString(String string) Parses a range, returning empty instead of throwing when the text is not a valid range.static Rangeget(int range) Returns a range covering the given radius in blocks.static Rangeget(Range.Type type) Returns the shared instance for a named scope.final inthashCode()Returns a hash code value for this object.booleanis(Range.Type type) Whether this range uses the given form.toJson()Writes this range back to its config representation, a number for block ranges and a name otherwise.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.intvalue()Returns the value of thevaluerecord component.
-
Constructor Details
-
Range
Creates an instance of aRangerecord class. -
Range
public Range(int value) Creates a range covering the given radius in blocks.- Parameters:
value- the radius in blocks, must not be negative
-
Range
Creates a range for one of the named scopes.- Parameters:
type- the named scope
-
-
Method Details
-
get
Returns a range covering the given radius in blocks.- Parameters:
range- the radius in blocks- Returns:
- the block range
-
get
Returns the shared instance for a named scope.- Parameters:
type- the named scope, must not beRange.Type.BLOCKS- Returns:
- the shared range for that scope
- Throws:
IllegalArgumentException- ifRange.Type.BLOCKSis passed, as it has no single default
-
fromJson
-
fromString
-
toJson
Writes this range back to its config representation, a number for block ranges and a name otherwise.- Returns:
- the config value
-
is
Whether this range uses the given form.- Parameters:
type- the form to test- Returns:
- true if the types match
-
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
value
-
type
-