Annotation Interface RegisterType


@Retention(CLASS) @Target({PACKAGE,TYPE}) @Inherited public @interface RegisterType
Annotation to register a class or package for inclusion in the TypeRegistry.

Registered types are used to enable simplified type resolution, for example when deserializing JSON that references a type by name or when using TestFixture helpers to specify input/output types.

If this annotation is placed on a class, that class will be registered in the TypeRegistry. If placed on a package, all types in that package and its ancestor packages will be registered. If root() is set, the provided package or type prefix is used instead of the annotated element name. This is especially useful in Kotlin projects, where package-info.java is typically not used.

Types or packages marked with @RegisterType are discovered and indexed during annotation processing. This means that they must be available on the classpath at compile time, and annotation processing must be enabled for the type registry to function correctly.

Usage

Registered types can be referenced by:
  • Simple class name (e.g., "Foo")
  • Disambiguated name using trailing segments (e.g., "example.Foo")

This is especially useful when a type is referenced in serialized form using the "@class" attribute:

{
  "@class": "Foo",
  "name": "Example"
}

If multiple classes have the same simple name, Fluxzero will attempt to resolve the type using the shortest suffix that still uniquely identifies it (e.g., "billing.Foo" vs. "shipping.Foo"). If conflicts remain, the returned type is unpredictable.

Filtering using contains()

You can restrict which types are registered by specifying patterns to match against the class name:
@RegisterType(contains = {"Dto", "Request"})
This ensures that only classes whose names include "Dto" or "Request" will be registered.

Kotlin package registration

Kotlin does not normally use package-info.java. To register an entire package from Kotlin, annotate a marker type and point root() at the package:
@RegisterType(root = "com.example.messages")
object TypeRegistryMarker
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional filters to determine which types should be registered based on name matching.
    Optional explicit root package or type prefix to register.
  • Element Details

    • root

      String root
      Optional explicit root package or type prefix to register.

      When left empty, the fully qualified name of the annotated package or type is used. When set, the value may point to either a package or a type, which makes it suitable for marker classes in Kotlin projects.

      Returns:
      explicit package or type root to register
      Default:
      ""
    • contains

      String[] contains
      Optional filters to determine which types should be registered based on name matching.

      If this array is left empty (the default), all types in the annotated class or package are included. If provided, a type is only registered if one or more of these regular expressions match the class name.

      Returns:
      array of regex patterns used to match class names for registration
      Default:
      {}