注釈型 RequireNonEmpty


@Documented
@Target(FIELD)
@Retention(RUNTIME)
public @interface RequireNonEmpty
An annotation that indicates the field is not allowed to be set to null or empty.

Specify this annotation RequireNonNull for fields that do not allow null or empty as follows. This annotation can be specified for Array, String, List, Map, and Set, otherwise UnsupportedOperationException will be thrown at runtime.

 
 public class ConcreteEntity implements ValidatableEntity, Serializable {

      @RequireNonEmpty
      private String literal;

      @RequireNonEmpty( ErrorType = ErrorType.RECOVERABLE, message = "failed!" )
      private String[] literals;

      @RequireNonEmpty( ErrorType = ErrorType.RECOVERABLE, message = "failed!" )
      private List<String> literalList;

      @RequireNonEmpty( ErrorType = ErrorType.UNRECOVERABLE, message = "failed!" )
      private Map<String, String> literalMap;

      @RequireNonEmpty( ErrorType = ErrorType.UNRECOVERABLE, message = "failed!" )
      private Set<String> literalSet;
 }
 
 
導入されたバージョン:
1.0.0
  • 要素の詳細

    • errorType

      ErrorType errorType
      Returns the error type based on ErrorType , and ErrorType.RUNTIME is set as the default.
      戻り値:
      The error type based on the ErrorType
      デフォルト:
      RUNTIME
    • message

      String message
      Returns the error type based on ErrorType , and empty ("") is set as the default.
      戻り値:
      The message
      デフォルト:
      ""