Class Result<T extends JoltPhysicsObject>
java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.template.Result<T>
- Type Parameters:
T
- the datatype produced when successful
- All Implemented Interfaces:
ConstJoltPhysicsObject
,AutoCloseable
,Comparable<JoltPhysicsObject>
- Direct Known Subclasses:
BcsResult
,ConstraintResult
,GroupFilterResult
,PathResult
,PhysicsMaterialResult
,PhysicsSceneResult
,RagdollResult
,SbcsResult
,SettingsResult
,ShapeResult
The result of an operation that might fail.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract T
get()
Return the result of a successful operation.getError()
Return the error message.protected abstract String
getError
(long resultVa) Return the error message.boolean
hasError()
Test whether an error occurred.protected abstract boolean
hasError
(long resultVa) Test whether an error occurred.boolean
isValid()
Test whether the value returned byget()
is valid.protected abstract boolean
isValid
(long resultVa) Test whether the value returned byget()
is valid.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, va
-
Constructor Details
-
Result
protected Result()Instantiate with no native object assigned.This no-arg constructor was made explicit to avoid javadoc warnings from JDK 18+.
-
-
Method Details
-
get
Return the result of a successful operation.- Returns:
- a new JVM object with a new native object assigned
-
getError
Return the error message.- Returns:
- a string of text
-
hasError
public boolean hasError()Test whether an error occurred.- Returns:
true
if error, otherwisefalse
-
isValid
public boolean isValid()Test whether the value returned byget()
is valid.- Returns:
true
if valid, otherwisefalse
-
getError
Return the error message.- Parameters:
resultVa
- the virtual address of the result (not zero)- Returns:
- a string of text
-
hasError
protected abstract boolean hasError(long resultVa) Test whether an error occurred.- Parameters:
resultVa
- the virtual address of the result (not zero)- Returns:
true
if error, otherwisefalse
-
isValid
protected abstract boolean isValid(long resultVa) Test whether the value returned byget()
is valid.- Parameters:
resultVa
- the virtual address of the result (not zero)- Returns:
true
if valid, otherwisefalse
-