/** * Creates a new factory for binding an enumeration. * * @param annotationType The annotation type. * @param enumerationDescription The enumeration to bind. */ public Factory(Class<T> annotationType, EnumerationDescription enumerationDescription) { this(annotationType, FieldAccess.forEnumeration(enumerationDescription), enumerationDescription.getEnumerationType().asGenericType()); }
/** * {@inheritDoc} */ public Resolved resolve(TypeDescription instrumentedType, MethodDescription instrumentedMethod, Assigner assigner, Assigner.Typing typing) { return new Resolved.Simple(FieldAccess.forEnumeration(enumerationDescription), enumerationDescription.getEnumerationType()); }
/** * Defines the given enumeration values to be provided as arguments to the invoked method where the values * are read from the enumeration class on demand. * * @param enumerationDescription The enumeration descriptions to provide as arguments. * @return A method call that hands the provided arguments to the invoked method. */ public MethodCall with(EnumerationDescription... enumerationDescription) { List<ArgumentLoader.Factory> argumentLoaders = new ArrayList<ArgumentLoader.Factory>(enumerationDescription.length); for (EnumerationDescription anEnumerationDescription : enumerationDescription) { argumentLoaders.add(new ArgumentLoader.ForStackManipulation(FieldAccess.forEnumeration(anEnumerationDescription), anEnumerationDescription.getEnumerationType())); } return with(argumentLoaders); }
} else if (value instanceof Enum<?>) { EnumerationDescription enumerationDescription = new EnumerationDescription.ForLoadedEnumeration((Enum<?>) value); return new ForStackManipulation(FieldAccess.forEnumeration(enumerationDescription), enumerationDescription.getEnumerationType()); } else { return new ForInstance.Factory(value);