001package org.junit.validator; 002 003import org.junit.runners.model.FrameworkField; 004import org.junit.runners.model.FrameworkMethod; 005import org.junit.runners.model.TestClass; 006 007import static java.util.Collections.emptyList; 008 009import java.util.List; 010 011/** 012 * Validates annotations on classes and methods. To be validated, 013 * an annotation should be annotated with {@link ValidateWith} 014 * 015 * Instances of this class are shared by multiple test runners, so they should 016 * be immutable and thread-safe. 017 * 018 * @since 4.12 019 */ 020public abstract class AnnotationValidator { 021 022 private static final List<Exception> NO_VALIDATION_ERRORS = emptyList(); 023 024 /** 025 * Validates annotation on the given class. 026 * 027 * @param testClass that is being validated 028 * @return A list of exceptions. Default behavior is to return an empty list. 029 * 030 * @since 4.12 031 */ 032 public List<Exception> validateAnnotatedClass(TestClass testClass) { 033 return NO_VALIDATION_ERRORS; 034 } 035 036 /** 037 * Validates annotation on the given field. 038 * 039 * @param field that is being validated 040 * @return A list of exceptions. Default behavior is to return an empty list. 041 * 042 * @since 4.12 043 */ 044 public List<Exception> validateAnnotatedField(FrameworkField field) { 045 return NO_VALIDATION_ERRORS; 046 047 } 048 049 /** 050 * Validates annotation on the given method. 051 * 052 * @param method that is being validated 053 * @return A list of exceptions. Default behavior is to return an empty list. 054 * 055 * @since 4.12 056 */ 057 public List<Exception> validateAnnotatedMethod(FrameworkMethod method) { 058 return NO_VALIDATION_ERRORS; 059 } 060}