isReadable abstract method

bool isReadable()

Determines whether this field can be read from (i.e., retrieved a value) through Jetleaf's reflective or dependency injection mechanisms.

A field is considered readable if all of the following are true:

  1. It is not static — readable fields must belong to an instance.
  2. It is not const — constant fields are compile-time constants.
  3. It is either:
    • non-final, meaning it can always be reassigned, or
    • late final, meaning it can be assigned once after construction.

Examples

class Example {
  final User user1;           // ✅ readable (final)
  late final User user2;      // ✅ readable (late final)
  User? user3;                // ✅ readable (mutable)
  static User? user4;         // ❌ not readable (static)
  const String key = 'abc';   // ❌ not readable (const)
}

final fields = Class.of(Example).getFields();
for (final field in fields) {
  print('${field.getName()}: ${field.isReadable()}');
}

Output:

user1: true
user2: true
user3: true
user4: false
key: false

This method performs an internal access check to ensure the caller has DomainPermission.READ_FIELDS before inspecting the field’s properties.

Implementation

bool isReadable();