Guest User

Untitled

a guest
Jan 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. package org.mitre.synthea.engine;
  2.  
  3. import java.lang.annotation.ElementType;
  4. import java.lang.annotation.Retention;
  5. import java.lang.annotation.RetentionPolicy;
  6. import java.lang.annotation.Target;
  7. import java.util.List;
  8.  
  9. import org.mitre.synthea.helpers.ValidationHelper;
  10.  
  11. public interface Validation {
  12. public default List<String> validate(Module context, List<String> path) {
  13. // just handoff to ValidationHelper
  14. return new ValidationHelper(this, context, path).validate();
  15. }
  16.  
  17. public default void validateSpecial(Module context, List<String> path, List<String> messages) {
  18. // do nothing. implementing classes can add something if they need to do any unique validation
  19. }
  20.  
  21. /**
  22. * An annotation for metadata about fields.
  23. */
  24. @Retention(RetentionPolicy.RUNTIME)
  25. @Target(ElementType.FIELD)
  26. public @interface Metadata {
  27. /**
  28. * The set of valid values that the field may have.
  29. */
  30. String[] validValues() default {};
  31.  
  32. /**
  33. * Indicates whether this field should be ignored by validation altogether.
  34. */
  35. boolean ignore() default false;
  36.  
  37. /**
  38. * Indicates whether the field must have a value set.
  39. */
  40. boolean required() default false;
  41.  
  42. /**
  43. * Indicates the minimum number of values a collection or array must contain.
  44. */
  45. int min() default 0;
  46.  
  47. /**
  48. * Indicates the maximum number of values a collection or array must contain.
  49. */
  50. int max() default Integer.MAX_VALUE;
  51.  
  52. /**
  53. * Indicates that this field is a reference to another state, which must be of a given type.
  54. */
  55. Class<? extends State> referenceToStateType() default State.class;
  56. }
  57. }
Add Comment
Please, Sign In to add comment