1 package org.pojomatic.internal.factory; 2 3 import java.lang.annotation.Annotation; 4 5 import org.objectweb.asm.Opcodes; 6 7 public class PropertyDescriptor { 8 final Class<?> type; 9 final Class<? extends Annotation>[] annotations; 10 11 String name = "x"; 12 Access access = Access.PRIVATE; 13 boolean isMethod; 14 boolean isSynthetic; 15 16 @SuppressWarnings("unchecked") 17 public PropertyDescriptor(Class<?> type) { 18 this(type, new Class[0]); 19 } 20 21 public PropertyDescriptor(Class<?> type, Class<? extends Annotation>[] annotations) { 22 this.type = type; 23 this.annotations = annotations; 24 } 25 26 public PropertyDescriptor withName(String name) { 27 this.name = name; 28 return this; 29 } 30 31 public PropertyDescriptor withAccess(Access access) { 32 this.access = access; 33 return this; 34 } 35 36 public PropertyDescriptor asMethod() { 37 isMethod = true; 38 return this; 39 } 40 41 public PropertyDescriptor asSynthetic() { 42 isSynthetic = true; 43 return this; 44 } 45 46 public int getFlags() { 47 return access.getCode() | (isSynthetic ? Opcodes.ACC_SYNTHETIC : 0); 48 } 49 }