Annotation Type DtoConverters
DtoConvert.
Used with generated entity-to-DTO graph mapping (see query.mapTo(SomeDto.class)).
Declared on a neutral holder - typically a package-info.java - the same convention as
DtoMapping.
@DtoConvert alone requires repeating the same annotation on every property that needs
the same conversion - tedious when one conversion (e.g. Instant -> Calendar, or an enum
<-> String) recurs across many otherwise-unrelated properties on a target. Rather than
annotate each property individually, register the class(es) declaring those conversions once:
@DtoConverters({DateConversions.class, EnumConversions.class})
package org.example.dto;
Every public, single-parameter, non-void-returning method declared directly on a
registered type is indexed by its exact parameter type and return type. Whenever a DTO
property's resolved source value type doesn't already exactly match the target property's
type, and that property carries no explicit DtoConvert, the generator looks up the
(source type, target type) pair in this index and wires the matching method in automatically -
dispatched the same way as DtoConvert (a direct static call for a static
method, or an instance resolved via io.ebean.DtoConverterManager for an instance
method needing a real dependency).
Matching is by exact type equality on both the parameter and return type - no
widening/supertype matching - so which method applies (if any) stays fully predictable. An
explicit per-property DtoConvert always takes precedence and is never overridden by a
type-pair default. Ebean itself ships no built-in conversions (e.g. no implicit
Enum.valueOf/.name()) - the registered method fully owns its own semantics
(e.g. returning null rather than throwing on an unrecognised enum value).
This is purely a compile-time / codegen-time hint - it carries no runtime footprint (source retention).
-
Required Element Summary
Required Elements
-
Element Details
-
value
Class<?>[] valueThe type(s) declaring conversion methods to index by (parameter type, return type) - an arbitrary app-defined shape, no ebean-mandated interface.
-