注釈型 NestedEntity
@Documented @Target(FIELD) @Retention(RUNTIME) public @interface NestedEntity
Specify this annotation for fields that is nested validatable entity as follows. Whenever this annotation is specified for an object that does not implement the ValidatableEntity annotation, UnsupportedOperationException will be thrown at runtime.
This annotation can also be specified for collection classes that implement interfaces such as List, Map, and Set. When this annotation is specified for a collection class, the type specified in the generics of the collection is parsed, and if the type specified in the generics implements the ValidatableEntity interface, validation can be performed. If the type specified in the generic does not implement the ValidatableEntity interface, UnsupportedOperationException will be thrown at runtime.
For List and Set, the zeroth generic type (of course) must be a ValidatableEntity, and for Map the value, like Map<String, ConcreteValidatableEntity>), of the value generic must be a ValidatableEntity.
public class ConcreteEntity implements ValidatableEntity, Serializable {
@NestedEntity
private ValidatableEntity entity;
@NestedEntity
private List<ConcreteValidatableEntity> validatableEntityList;
@NestedEntity
private Map<String, ConcreteValidatableEntity> validatableEntityMap;
@NestedEntity
private Set<ConcreteValidatableEntity> validatableEntitySet;
}
- 導入されたバージョン:
- 1.0.0