KeyValueOf<K, V> class final

KeyValueOf Annotation

A reflectable annotation used to declare a key-value type relationship, such as for maps, configuration entries, or type-safe dictionaries.

Purpose

  • Provides explicit metadata about both key and value types.
  • Supports optional package scoping for each type.
  • Used by dependency resolution or serialization frameworks where generic type information is erased at runtime.

Behavior

  • Stores optional kPkg and vPkg (package names for key and value).
  • Exposes getKey and getValue to resolve Class<K> and Class<V>.

Example

@KeyValueOf("com.example.keys", "com.example.values")
final KeyValueOf<String, User> userMapping = KeyValueOf();

final keyClass = userMapping.getKey();
final valueClass = userMapping.getValue();
print(keyClass.getQualifiedName());   // com.example.keys.String
print(valueClass.getQualifiedName()); // com.example.values.User

Notes

  • Provides strong typing for frameworks handling generic maps.
  • Useful for reflection-based object factories and parsers.
Annotations
  • @Generic.new(KeyValueOf)
  • @Target.new({TargetKind.field})

Constructors

KeyValueOf([String? kPkg, String? vPkg])
KeyValueOf Annotation
const

Properties

annotationType Type
Returns the annotation _type of this annotation.
no setter
hashCode int
Returns a hash code consistent with equality definition.
no setterinherited
kPkg String?
Optional package name for the key type.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
vPkg String?
Optional package name for the value type.
final

Methods

equals(Object other) bool
Checks whether the given object is logically equivalent to this annotation.
inherited
getKey() → Class<K>
Resolves the key type into a Class<K> representation.
getValue() → Class<V>
Resolves the value type into a Class<V> representation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Returns a string representation of this annotation.
inherited

Operators

operator ==(Object other) bool
Checks if this annotation is equal to another object.
inherited