• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 import java.lang.annotation.Documented;
2 import java.lang.annotation.Retention;
3 import java.lang.annotation.RetentionPolicy;
4 
5 import javax.annotation.meta.TypeQualifier;
6 import javax.annotation.meta.TypeQualifierValidator;
7 import javax.annotation.meta.When;
8 
9 @Documented
10 @TypeQualifier(applicableTo=String.class)
11 @Retention(RetentionPolicy.RUNTIME)
12 public @interface FixedLengthString {
value()13 	int value();
14 
15 	class Checker implements TypeQualifierValidator<FixedLengthString> {
16 
forConstantValue(FixedLengthString annotation, Object v)17 		public When forConstantValue(FixedLengthString annotation, Object v) {
18 			if (!(v instanceof String))
19 				return When.NEVER;
20 			String s = (String) v;
21 			if (s.length() == annotation.value())
22 				return When.ALWAYS;
23 			return When.NEVER;
24 		}
25 	}
26 }