Java Code Examples for net.bytebuddy.description.type.TypeDescription#getInterfaces()

The following examples show how to use net.bytebuddy.description.type.TypeDescription#getInterfaces() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HierarchyMatch.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isMatch(TypeDescription typeDescription) {
    List<String> parentTypes = new ArrayList<String>(Arrays.asList(this.parentTypes));

    TypeList.Generic implInterfaces = typeDescription.getInterfaces();
    for (TypeDescription.Generic implInterface : implInterfaces) {
        matchHierarchyClass(implInterface, parentTypes);
    }

    if (typeDescription.getSuperClass() != null) {
        matchHierarchyClass(typeDescription.getSuperClass(), parentTypes);
    }

    return parentTypes.size() == 0;

}
 
Example 2
Source File: TypeAttributeAppender.java    From byte-buddy with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void apply(ClassVisitor classVisitor, TypeDescription instrumentedType, AnnotationValueFilter annotationValueFilter) {
    AnnotationAppender annotationAppender = new AnnotationAppender.Default(new AnnotationAppender.Target.OnType(classVisitor));
    annotationAppender = AnnotationAppender.ForTypeAnnotations.ofTypeVariable(annotationAppender,
            annotationValueFilter,
            AnnotationAppender.ForTypeAnnotations.VARIABLE_ON_TYPE,
            instrumentedType.getTypeVariables());
    TypeDescription.Generic superClass = instrumentedType.getSuperClass();
    if (superClass != null) {
        annotationAppender = superClass.accept(AnnotationAppender.ForTypeAnnotations.ofSuperClass(annotationAppender, annotationValueFilter));
    }
    int interfaceIndex = 0;
    for (TypeDescription.Generic interfaceType : instrumentedType.getInterfaces()) {
        annotationAppender = interfaceType.accept(AnnotationAppender.ForTypeAnnotations.ofInterfaceType(annotationAppender,
                annotationValueFilter,
                interfaceIndex++));
    }
    for (AnnotationDescription annotation : instrumentedType.getDeclaredAnnotations()) {
        annotationAppender = annotationAppender.append(annotation, annotationValueFilter);
    }
}
 
Example 3
Source File: TypeAttributeAppender.java    From byte-buddy with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void apply(ClassVisitor classVisitor, TypeDescription instrumentedType, AnnotationValueFilter annotationValueFilter) {
    AnnotationAppender annotationAppender = new AnnotationAppender.Default(new AnnotationAppender.Target.OnType(classVisitor));
    AnnotationAppender.ForTypeAnnotations.ofTypeVariable(annotationAppender,
            annotationValueFilter,
            AnnotationAppender.ForTypeAnnotations.VARIABLE_ON_TYPE,
            typeVariableIndex,
            instrumentedType.getTypeVariables());
    TypeList.Generic interfaceTypes = instrumentedType.getInterfaces();
    int interfaceTypeIndex = this.interfaceTypeIndex;
    for (TypeDescription.Generic interfaceType : interfaceTypes.subList(this.interfaceTypeIndex, interfaceTypes.size())) {
        annotationAppender = interfaceType.accept(AnnotationAppender.ForTypeAnnotations.ofInterfaceType(annotationAppender,
                annotationValueFilter,
                interfaceTypeIndex++));
    }
    AnnotationList declaredAnnotations = instrumentedType.getDeclaredAnnotations();
    for (AnnotationDescription annotationDescription : declaredAnnotations.subList(annotationIndex, declaredAnnotations.size())) {
        annotationAppender = annotationAppender.append(annotationDescription, annotationValueFilter);
    }
}
 
Example 4
Source File: EnhancerImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private boolean alreadyEnhanced(TypeDescription managedCtClass) {
	for ( TypeDescription.Generic declaredInterface : managedCtClass.getInterfaces() ) {
		if ( declaredInterface.asErasure().isAssignableTo( Managed.class ) ) {
			return true;
		}
	}
	return false;
}
 
Example 5
Source File: EitherInterfaceMatch.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isMatch(TypeDescription typeDescription) {
    MatchResult matchResult = new MatchResult();
    for (TypeDescription.Generic generic : typeDescription.getInterfaces()) {
        matchHierarchyClazz(generic, matchResult);
    }

    if (typeDescription.getSuperClass() != null) {
        matchHierarchyClazz(typeDescription.getSuperClass(), matchResult);
    }

    return matchResult.result();
}