当前位置: 首页>>代码示例>>Java>>正文


Java TypeDescription.represents方法代码示例

本文整理汇总了Java中net.bytebuddy.description.type.TypeDescription.represents方法的典型用法代码示例。如果您正苦于以下问题:Java TypeDescription.represents方法的具体用法?Java TypeDescription.represents怎么用?Java TypeDescription.represents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.bytebuddy.description.type.TypeDescription的用法示例。


在下文中一共展示了TypeDescription.represents方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolve

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Override
public Object[] resolve() {
    TypeDescription componentTypeDescription = typePool.describe(componentTypeReference.lookup()).resolve();
    Class<?> componentType;
    if (componentTypeDescription.represents(Class.class)) {
        componentType = TypeDescription.class;
    } else if (componentTypeDescription.isAssignableTo(Enum.class)) { // Enums can implement annotation interfaces, check this first.
        componentType = EnumerationDescription.class;
    } else if (componentTypeDescription.isAssignableTo(Annotation.class)) {
        componentType = AnnotationDescription.class;
    } else if (componentTypeDescription.represents(String.class)) {
        componentType = String.class;
    } else {
        throw new IllegalStateException("Unexpected complex array component type " + componentTypeDescription);
    }
    Object[] array = (Object[]) Array.newInstance(componentType, values.size());
    int index = 0;
    for (AnnotationValue<?, ?> annotationValue : values) {
        Array.set(array, index++, annotationValue.resolve());
    }
    return array;
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:23,代码来源:TypePool.java

示例2: toFrame

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
/**
 * Translates a type into a representation of its form inside a stack map frame.
 *
 * @param typeDescription The type to translate.
 * @return A stack entry representation of the supplied type.
 */
protected static Object toFrame(TypeDescription typeDescription) {
    if (typeDescription.represents(boolean.class)
            || typeDescription.represents(byte.class)
            || typeDescription.represents(short.class)
            || typeDescription.represents(char.class)
            || typeDescription.represents(int.class)) {
        return Opcodes.INTEGER;
    } else if (typeDescription.represents(long.class)) {
        return Opcodes.LONG;
    } else if (typeDescription.represents(float.class)) {
        return Opcodes.FLOAT;
    } else if (typeDescription.represents(double.class)) {
        return Opcodes.DOUBLE;
    } else {
        return typeDescription.getInternalName();
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:24,代码来源:Advice.java

示例3: apply

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
/**
 * Performs the writing of a given annotation value to an annotation visitor.
 *
 * @param annotationVisitor The annotation visitor the write process is to be applied on.
 * @param valueType         The type of the annotation value.
 * @param name              The name of the annotation type.
 * @param value             The annotation's value.
 */
public static void apply(AnnotationVisitor annotationVisitor, TypeDescription valueType, String name, Object value) {
    if (valueType.isArray()) { // The Android emulator reads annotation arrays as annotation types. Therefore, this check needs to come first.
        AnnotationVisitor arrayVisitor = annotationVisitor.visitArray(name);
        int length = Array.getLength(value);
        TypeDescription componentType = valueType.getComponentType();
        for (int index = 0; index < length; index++) {
            apply(arrayVisitor, componentType, NO_NAME, Array.get(value, index));
        }
        arrayVisitor.visitEnd();
    } else if (valueType.isAnnotation()) {
        handle(annotationVisitor.visitAnnotation(name, valueType.getDescriptor()), (AnnotationDescription) value, AnnotationValueFilter.Default.APPEND_DEFAULTS);
    } else if (valueType.isEnum()) {
        annotationVisitor.visitEnum(name, valueType.getDescriptor(), ((EnumerationDescription) value).getValue());
    } else if (valueType.represents(Class.class)) {
        annotationVisitor.visit(name, Type.getType(((TypeDescription) value).getDescriptor()));
    } else {
        annotationVisitor.visit(name, value);
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:28,代码来源:AnnotationAppender.java

示例4: make

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Override
public OffsetMapping make(ParameterDescription.InDefinedShape target,
                          AnnotationDescription.Loadable<FieldValue> annotation,
                          AdviceType adviceType) {
    if (adviceType.isDelegation() && !annotation.getValue(ForField.READ_ONLY).resolve(Boolean.class)) {
        throw new IllegalStateException("Cannot write to field for " + target + " in read-only context");
    } else {
        TypeDescription declaringType = annotation.getValue(DECLARING_TYPE).resolve(TypeDescription.class);
        return declaringType.represents(void.class)
                ? new WithImplicitType(target.getType(), annotation)
                : new WithExplicitType(target.getType(), annotation, declaringType);
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:14,代码来源:Advice.java

示例5: of

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
/**
 * Creates a skip dispatcher for a given annotation type and advice method.
 *
 * @param typeDescription The type that was specified as an annotation value.
 * @param adviceMethod    The advice method.
 * @return An appropriate skip dispatcher.
 */
protected static SkipDispatcher of(TypeDescription typeDescription, MethodDescription adviceMethod) {
    if (typeDescription.represents(void.class)) {
        return Disabled.INSTANCE;
    } else if (typeDescription.represents(OnDefaultValue.class)) {
        return ForValue.of(adviceMethod.getReturnType(), false);
    } else if (typeDescription.represents(OnNonDefaultValue.class)) {
        return ForValue.of(adviceMethod.getReturnType(), true);
    } else if (typeDescription.isPrimitive() || adviceMethod.getReturnType().isPrimitive()) {
        throw new IllegalStateException("Cannot skip method by instance type for primitive return value on " + adviceMethod);
    } else {
        return new ForType(typeDescription);
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:21,代码来源:Advice.java

示例6: isBootstrap

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Override
public boolean isBootstrap() {
    TypeDescription returnType = getReturnType().asErasure();
    if ((isMethod() && (!isStatic()
            || !(JavaType.CALL_SITE.getTypeStub().isAssignableFrom(returnType) || JavaType.CALL_SITE.getTypeStub().isAssignableTo(returnType))))
            || (isConstructor() && !JavaType.CALL_SITE.getTypeStub().isAssignableFrom(getDeclaringType().asErasure()))) {
        return false;
    }
    TypeList parameterTypes = getParameters().asTypeList().asErasures();
    switch (parameterTypes.size()) {
        case 0:
            return false;
        case 1:
            return parameterTypes.getOnly().represents(Object[].class);
        case 2:
            return JavaType.METHOD_HANDLES_LOOKUP.getTypeStub().isAssignableTo(parameterTypes.get(0))
                    && parameterTypes.get(1).represents(Object[].class);
        case 3:
            return JavaType.METHOD_HANDLES_LOOKUP.getTypeStub().isAssignableTo(parameterTypes.get(0))
                    && (parameterTypes.get(1).represents(Object.class) || parameterTypes.get(1).represents(String.class))
                    && (parameterTypes.get(2).represents(Object[].class) || JavaType.METHOD_TYPE.getTypeStub().isAssignableTo(parameterTypes.get(2)));
        default:
            if (!(JavaType.METHOD_HANDLES_LOOKUP.getTypeStub().isAssignableTo(parameterTypes.get(0))
                    && (parameterTypes.get(1).represents(Object.class) || parameterTypes.get(1).represents(String.class))
                    && (JavaType.METHOD_TYPE.getTypeStub().isAssignableTo(parameterTypes.get(2))))) {
                return false;
            }
            int parameterIndex = 4;
            for (TypeDescription parameterType : parameterTypes.subList(3, parameterTypes.size())) {
                if (!parameterType.represents(Object.class) && !parameterType.isConstantPool()) {
                    return parameterType.represents(Object[].class) && parameterIndex == parameterTypes.size();
                }
                parameterIndex++;
            }
            return true;
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:38,代码来源:MethodDescription.java

示例7: isDefaultValue

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Override
public boolean isDefaultValue(AnnotationValue<?, ?> annotationValue) {
    if (!isDefaultValue()) {
        return false;
    }
    TypeDescription returnType = getReturnType().asErasure();
    Object value = annotationValue.resolve();
    return (returnType.represents(boolean.class) && value instanceof Boolean)
            || (returnType.represents(byte.class) && value instanceof Byte)
            || (returnType.represents(char.class) && value instanceof Character)
            || (returnType.represents(short.class) && value instanceof Short)
            || (returnType.represents(int.class) && value instanceof Integer)
            || (returnType.represents(long.class) && value instanceof Long)
            || (returnType.represents(float.class) && value instanceof Float)
            || (returnType.represents(double.class) && value instanceof Double)
            || (returnType.represents(String.class) && value instanceof String)
            || (returnType.isAssignableTo(Enum.class) && value instanceof EnumerationDescription && isEnumerationType(returnType, (EnumerationDescription) value))
            || (returnType.isAssignableTo(Annotation.class) && value instanceof AnnotationDescription && isAnnotationType(returnType, (AnnotationDescription) value))
            || (returnType.represents(Class.class) && value instanceof TypeDescription)
            || (returnType.represents(boolean[].class) && value instanceof boolean[])
            || (returnType.represents(byte[].class) && value instanceof byte[])
            || (returnType.represents(char[].class) && value instanceof char[])
            || (returnType.represents(short[].class) && value instanceof short[])
            || (returnType.represents(int[].class) && value instanceof int[])
            || (returnType.represents(long[].class) && value instanceof long[])
            || (returnType.represents(float[].class) && value instanceof float[])
            || (returnType.represents(double[].class) && value instanceof double[])
            || (returnType.represents(String[].class) && value instanceof String[])
            || (returnType.isAssignableTo(Enum[].class) && value instanceof EnumerationDescription[] && isEnumerationType(returnType.getComponentType(), (EnumerationDescription[]) value))
            || (returnType.isAssignableTo(Annotation[].class) && value instanceof AnnotationDescription[] && isAnnotationType(returnType.getComponentType(), (AnnotationDescription[]) value))
            || (returnType.represents(Class[].class) && value instanceof TypeDescription[]);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:33,代码来源:MethodDescription.java

示例8: of

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
/**
 * Resolves a type locator based upon an annotation value.
 *
 * @param typeDescription The annotation's value.
 * @return The appropriate type locator.
 */
protected static TypeLocator of(TypeDescription typeDescription) {
    if (typeDescription.represents(void.class)) {
        return ForParameterType.INSTANCE;
    } else if (typeDescription.represents(TargetType.class)) {
        return ForInstrumentedType.INSTANCE;
    } else if (typeDescription.isPrimitive() || typeDescription.isArray()) {
        throw new IllegalStateException("Cannot assign proxy to " + typeDescription);
    } else {
        return new ForType(typeDescription);
    }
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:18,代码来源:Super.java

示例9: resolve

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
/**
 * Resolves the given type description to the supplied target type if it represents the {@link TargetType} placeholder.
 * Array types are resolved to their component type and rebuilt as an array of the actual target type, if necessary.
 *
 * @param typeDescription The type description that might represent the {@link TargetType} placeholder.
 * @param targetType      The actual target type.
 * @return A description of the resolved type.
 */
public static TypeDescription resolve(TypeDescription typeDescription, TypeDescription targetType) {
    int arity = 0;
    TypeDescription componentType = typeDescription;
    while (componentType.isArray()) {
        componentType = componentType.getComponentType();
        arity++;
    }
    return componentType.represents(TargetType.class)
            ? TypeDescription.ArrayProjection.of(targetType, arity)
            : typeDescription;
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:20,代码来源:TargetType.java

示例10: matches

import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Override
public boolean matches(final TypeDescription target) {
    return target.represents(Foo.class);
}
 
开发者ID:project-avral,项目名称:oo-atom,代码行数:5,代码来源:ThisOrSuperClassMatcherTest.java


注:本文中的net.bytebuddy.description.type.TypeDescription.represents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。