Class FlixelDefaultReflectionHandler
- All Implemented Interfaces:
FlixelReflection
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncallMethod(Object target, String methodName, Object... args) Invokes a method by name on the target.booleancompareMethods(Object methodA, Object methodB) Compares two method-like references for logical equality.<T> Tcopy(T source) Creates a shallow copy of the source object.Reads a field value from the target instance.Returns a list of available field names for the target.booleanChecks whether a field with the given name exists on the target instance.booleanisClassFinal(String classPath) Checks whether the class at the given class path is declared as final.booleanReturns whether a value should be treated as an object value in reflection contexts.objectFields(Class<?> type) Returns all fields declared on a type and its superclasses.Field[]objectFieldsArray(Class<?> type) Returns all fields declared on a type and its superclasses as an array.Reads a property value from the target.voidWrites a field value to the target instance.voidsetProperty(Object target, String propertyName, Object value) Writes a property value on the target.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.stringdotjar.flixelgdx.backend.reflect.FlixelReflection
resolvePropertyPath
-
Constructor Details
-
FlixelDefaultReflectionHandler
public FlixelDefaultReflectionHandler()
-
-
Method Details
-
hasField
Description copied from interface:FlixelReflectionChecks whether a field with the given name exists on the target instance.Implementations should include inherited fields from superclasses. Returning
falsemeans the field cannot be resolved for read or write operations.- Specified by:
hasFieldin interfaceFlixelReflection- Parameters:
target- The object instance to inspect.fieldName- The field name to search for.- Returns:
trueif the field exists on the target type, otherwisefalse.
-
field
Description copied from interface:FlixelReflectionReads a field value from the target instance.Implementations should resolve inherited fields and may allow non-public access depending on platform constraints. If the field cannot be resolved or read, an exception should be thrown.
- Specified by:
fieldin interfaceFlixelReflection- Parameters:
target- The object instance to read from.fieldName- the field name to read- Returns:
- the current field value
-
setField
Description copied from interface:FlixelReflectionWrites a field value to the target instance.If a field is immutable, final, unsupported, or cannot be written safely, implementations should throw an explicit exception instead of silently failing.
- Specified by:
setFieldin interfaceFlixelReflection- Parameters:
target- The object instance to modify.fieldName- The field name to write.value- The new value to store.
-
property
Description copied from interface:FlixelReflectionReads a property value from the target.Implementations may resolve JavaBean getters when available and fall back to direct field access when appropriate.
- Specified by:
propertyin interfaceFlixelReflection- Parameters:
target- The object instance to inspect.propertyName- The property name to resolve.- Returns:
- The resolved property value.
-
setProperty
Description copied from interface:FlixelReflectionWrites a property value on the target.Implementations may resolve JavaBean setters when available and fall back to direct field writes when appropriate. Unsupported writes should throw an explicit exception.
- Specified by:
setPropertyin interfaceFlixelReflection- Parameters:
target- The object instance to modify.propertyName- The property name to resolve.value- The new property value.
-
fields
Description copied from interface:FlixelReflectionReturns a list of available field names for the target.The result should include inherited fields. Implementations may return a cached immutable list for performance.
- Specified by:
fieldsin interfaceFlixelReflection- Parameters:
target- The object instance to inspect.- Returns:
- Field names available on the target type.
-
callMethod
Description copied from interface:FlixelReflectionInvokes a method by name on the target.Implementations should resolve overloads using argument arity and type compatibility where supported by the platform runtime.
- Specified by:
callMethodin interfaceFlixelReflection- Parameters:
target- The object instance to invoke on.methodName- The method name.args- Arguments for invocation.- Returns:
- The invocation result, or
nullfor void methods.
-
isObject
Description copied from interface:FlixelReflectionReturns whether a value should be treated as an object value in reflection contexts.This is useful for parity with dynamic reflection APIs and for differentiating scalar values from richer object structures.
- Specified by:
isObjectin interfaceFlixelReflection- Parameters:
value- Value to classify.- Returns:
trueif the value is treated as an object value.
-
copy
public <T> T copy(T source) Description copied from interface:FlixelReflectionCreates a shallow copy of the source object.Implementations typically require a no-argument constructor and then copy non-static field values from source to destination.
- Specified by:
copyin interfaceFlixelReflection- Type Parameters:
T- Source type.- Parameters:
source- Source instance.- Returns:
- Copied instance.
-
compareMethods
Description copied from interface:FlixelReflectionCompares two method-like references for logical equality.Implementations may use identity and equality checks depending on how method references are represented on the current platform.
- Specified by:
compareMethodsin interfaceFlixelReflection- Parameters:
methodA- First method reference.methodB- Second method reference.- Returns:
trueif both represent the same method target
-
objectFields
Description copied from interface:FlixelReflectionReturns all fields declared on a type and its superclasses.Implementations should cache the result per class to avoid repeated hierarchy traversal.
- Specified by:
objectFieldsin interfaceFlixelReflection- Parameters:
type- Class to inspect.- Returns:
- All resolved fields.
-
objectFieldsArray
Description copied from interface:FlixelReflectionReturns all fields declared on a type and its superclasses as an array.- Specified by:
objectFieldsArrayin interfaceFlixelReflection- Parameters:
type- Class to inspect.- Returns:
- All resolved fields as an array.
-
isClassFinal
Description copied from interface:FlixelReflectionChecks whether the class at the given class path is declared as final.When a class cannot be resolved, implementations may return
falseto preserve compatibility with existing behavior.- Specified by:
isClassFinalin interfaceFlixelReflection- Parameters:
classPath- Fully qualified class name.- Returns:
truewhen the resolved class is final.
-