/** * {@inheritDoc} */ public boolean matches(TypeDescription target) { return target.getDeclaredAnnotations().isAnnotationPresent(Enhance.class); }
/** * Validates if a method should be ignored for binding. * * @param methodDescription The method to validate. * @return {@code true} if the method should not be considered for binding. */ public static boolean check(MethodDescription methodDescription) { return methodDescription.getDeclaredAnnotations().isAnnotationPresent(IgnoreForBinding.class); } }
/** * {@inheritDoc} */ public boolean matches(TypeDescription target) { return target.getDeclaredAnnotations().isAnnotationPresent(Enhance.class); }
@Override public boolean hasAnnotation(Class<? extends Annotation> annotationType) { return typeDescription.getDeclaredAnnotations().isAnnotationPresent( annotationType ); }
@Override public boolean hasAnnotation(Class<? extends Annotation> annotationType) { return getAnnotations().isAnnotationPresent( annotationType ); }
/** * {@inheritDoc} */ public int getActualModifiers() { return getModifiers() | (getDeclaredAnnotations().isAnnotationPresent(Deprecated.class) ? Opcodes.ACC_DEPRECATED : EMPTY_MASK); }
/** * {@inheritDoc} */ public int getActualModifiers() { return getModifiers() | (getDeclaredAnnotations().isAnnotationPresent(Deprecated.class) ? Opcodes.ACC_DEPRECATED : EMPTY_MASK); }
/** * {@inheritDoc} */ public boolean isInherited() { return getAnnotationType().getDeclaredAnnotations().isAnnotationPresent(Inherited.class); }
/** * {@inheritDoc} */ public boolean isDocumented() { return getAnnotationType().getDeclaredAnnotations().isAnnotationPresent(Documented.class); }
/** * Checks if an annotated element should be assigned a value by considering the runtime type. * * @param annotationSource The annotated element of interest. * @return Indicates if dynamic type castings should be attempted for incompatible assignments. */ public static Assigner.Typing check(AnnotationSource annotationSource) { return Assigner.Typing.of(annotationSource.getDeclaredAnnotations().isAnnotationPresent(RuntimeType.class)); } }
/** * {@inheritDoc} */ public void register(DynamicType dynamicType, ClassLoader classLoader, InjectorFactory injectorFactory) { Map<TypeDescription, byte[]> auxiliaryTypes = dynamicType.getAuxiliaryTypes(); Map<TypeDescription, byte[]> independentTypes = new LinkedHashMap<TypeDescription, byte[]>(auxiliaryTypes); for (TypeDescription auxiliaryType : auxiliaryTypes.keySet()) { if (!auxiliaryType.getDeclaredAnnotations().isAnnotationPresent(AuxiliaryType.SignatureRelevant.class)) { independentTypes.remove(auxiliaryType); } } if (!independentTypes.isEmpty()) { ClassInjector classInjector = injectorFactory.resolve(); Map<TypeDescription, LoadedTypeInitializer> loadedTypeInitializers = dynamicType.getLoadedTypeInitializers(); for (Map.Entry<TypeDescription, Class<?>> entry : classInjector.inject(independentTypes).entrySet()) { loadedTypeInitializers.get(entry.getKey()).onLoad(entry.getValue()); } } } }
Map<TypeDescription, byte[]> dependentTypes = new LinkedHashMap<TypeDescription, byte[]>(auxiliaryTypes); for (TypeDescription auxiliaryType : auxiliaryTypes.keySet()) { (auxiliaryType.getDeclaredAnnotations().isAnnotationPresent(AuxiliaryType.SignatureRelevant.class) ? dependentTypes : independentTypes).remove(auxiliaryType);
@Override protected HashCodeMethod hashCodeMethod(TypeDescription instrumentedType) { TypeDefinition superClass = instrumentedType.getSuperClass(); return superClass != null && superClass.asErasure().getDeclaredAnnotations().isAnnotationPresent(Enhance.class) ? HashCodeMethod.usingSuperClassOffset() : HashCodeMethod.usingDefaultOffset(); }
/** * {@inheritDoc} */ public int getActualModifiers(boolean superFlag) { int actualModifiers = getModifiers() | (getDeclaredAnnotations().isAnnotationPresent(Deprecated.class) ? Opcodes.ACC_DEPRECATED : EMPTY_MASK); if (isPrivate()) { actualModifiers = actualModifiers & ~(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC); } else if (isProtected()) { actualModifiers = actualModifiers & ~(Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC) | Opcodes.ACC_PUBLIC; } else { actualModifiers = actualModifiers & ~Opcodes.ACC_STATIC; } return superFlag ? (actualModifiers | Opcodes.ACC_SUPER) : actualModifiers; }
@Override protected EqualsMethod equalsMethod(TypeDescription instrumentedType) { TypeDefinition superClass = instrumentedType.getSuperClass(); return superClass != null && superClass.asErasure().getDeclaredAnnotations().isAnnotationPresent(Enhance.class) ? EqualsMethod.requiringSuperClassEquality() : EqualsMethod.isolated(); } },
private void createChecks(String fullMethodSignature, AnnotationList declaredAnnotations, TimerNames timerNames) { if (declaredAnnotations.isAnnotationPresent(SLA.class)) { createSlaCheck(declaredAnnotations.ofType(SLA.class).loadSilent(), fullMethodSignature, timerNames); } if (declaredAnnotations.isAnnotationPresent(SLAs.class)) { for (SLA sla : declaredAnnotations.ofType(SLAs.class).loadSilent().value()) { createSlaCheck(sla, fullMethodSignature, timerNames); } } }
@Override protected NamingParameters getNamingParameters(MethodDescription instrumentedMethod) { if (instrumentedMethod.getDeclaredAnnotations().isAnnotationPresent(Timed.class)) { final Timed timed = instrumentedMethod.getDeclaredAnnotations().ofType(Timed.class).loadSilent(); return new NamingParameters(timed.name(), timed.absolute()); } else { return new NamingParameters("", false); } }
@Override public boolean matches(MethodDescription targetMethod) { final AnnotationList declaredAnnotationsOfType = targetMethod.getDeclaringType().asErasure().getDeclaredAnnotations(); if (declaredAnnotationsOfType.isAnnotationPresent(Remote.class)) { final Class[] remoteInterfaces = declaredAnnotationsOfType.ofType(Remote.class).loadSilent().value(); if (!new TypeList.ForLoadedTypes(remoteInterfaces).filter(isDeclaredInInterfaceHierarchy(targetMethod)).isEmpty()) { return true; } } return false; } }
@Override protected HashCodeMethod hashCodeMethod(TypeDescription instrumentedType) { TypeDefinition typeDefinition = instrumentedType.getSuperClass(); while (typeDefinition != null && !typeDefinition.represents(Object.class)) { if (typeDefinition.asErasure().getDeclaredAnnotations().isAnnotationPresent(Enhance.class)) { return HashCodeMethod.usingSuperClassOffset(); } MethodList<?> hashCode = typeDefinition.getDeclaredMethods().filter(isHashCode()); if (!hashCode.isEmpty()) { return hashCode.getOnly().isAbstract() ? HashCodeMethod.usingDefaultOffset() : HashCodeMethod.usingSuperClassOffset(); } typeDefinition = typeDefinition.getSuperClass(); } return HashCodeMethod.usingDefaultOffset(); }
@Override protected EqualsMethod equalsMethod(TypeDescription instrumentedType) { TypeDefinition typeDefinition = instrumentedType.getSuperClass(); while (typeDefinition != null && !typeDefinition.represents(Object.class)) { if (typeDefinition.asErasure().getDeclaredAnnotations().isAnnotationPresent(Enhance.class)) { return EqualsMethod.requiringSuperClassEquality(); } MethodList<?> hashCode = typeDefinition.getDeclaredMethods().filter(isHashCode()); if (!hashCode.isEmpty()) { return hashCode.getOnly().isAbstract() ? EqualsMethod.isolated() : EqualsMethod.requiringSuperClassEquality(); } typeDefinition = typeDefinition.getSuperClass().asErasure(); } return EqualsMethod.isolated(); } },