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


Java Generic类代码示例

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


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

示例1: appendTypeSignature

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append a type signature
 *
 * @param buf Buffer to append to
 * @param role Role (class or super)
 * @param type Type to append signature of
 * @param annotatedSignatureWriter Signature writer
 * @return <code>true</code> if any nullability information was written
 * @throws IOException if we stumble and fall...
 */
protected boolean appendTypeSignature(StringBuilder buf, String role, Generic type,
        MethodSignatureWriter annotatedSignatureWriter) throws IOException {
    boolean annotated = false;

    buf.append(role).append(' ').append(type.asErasure().getInternalName()).append("\n");

    TypeList.Generic typeVariables = type.asErasure().getTypeVariables();

    if (!typeVariables.isEmpty()) {
        if (appendTypeParameters(buf, typeVariables, annotatedSignatureWriter)) {
            annotated = true;
        }
    }

    return annotated;
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:27,代码来源:AnnotationsJarWriter.java

示例2: appendJavaTypeSignature

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append a type
 *
 * @param type Type to append
 * @param nullable Nullness of type
 * @param output Output to append to
 * @param <A> Type of output
 * @return Supplied output to append to
 */
public <A extends Appendable> A appendJavaTypeSignature(Generic type, Nullness nullable, A output) {
    try {
        if (type.isPrimitive()) {
            appendBaseType(type, output);
        }
        else {
            appendReferenceTypeSignature(type, nullable, output);
        }

        return output;
    }
    catch (Exception e) {
        throw new RuntimeException(String.format("Could not write java type signature %s", type));
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:25,代码来源:MethodSignatureWriter.java

示例3: appendReferenceTypeSignature

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append a referency type
 *
 * @param type Type to append
 * @param nullable Nullness of type
 * @param output Output to append to
 * @param <A> Type of output
 * @return Supplied output to append to
 */
public <A extends Appendable> A appendReferenceTypeSignature(Generic type, Nullness nullable, A output) {
    try {
        if (type.isArray()) {
            appendArrayTypeSignature(type, nullable, output);
        }
        else if (type.getSort() == Sort.VARIABLE) {
            appendTypeVariableSignature(type, nullable, output);
        }
        else {
            appendClassTypeSignature(type, nullable, output);
        }

        return output;
    }
    catch (Exception e) {
        throw new RuntimeException(String.format("Could not write reference type signature %s", type));
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:28,代码来源:MethodSignatureWriter.java

示例4: appendTypeArguments

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append type arguments
 *
 * @param typeArguments Type arguments to append
 * @param output Output to append to
 * @param <A> Type of output
 * @return Supplied output to append to
 */
public <A extends Appendable> A appendTypeArguments(TypeList.Generic typeArguments, A output) {
    try {
        output.append('<');

        for (Generic typeArgument : typeArguments) {
            appendTypeArgument(typeArgument, output);
        }

        output.append('>');

        return output;
    }
    catch (Exception e) {
        throw new RuntimeException(String.format("Could not write type arguments %s", typeArguments));
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:25,代码来源:MethodSignatureWriter.java

示例5: appendTypeParameters

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append type parameters
 *
 * @param typeParameters Type parameters to append
 * @param output Output to append to
 * @param <A> Type of output
 * @return Supplied output to append to
 */
public <A extends Appendable> A appendTypeParameters(TypeList.Generic typeParameters, A output) {
    try {
        output.append('<');

        for (Generic typeArgument : typeParameters) {
            appendTypeParameter(typeArgument, output);
        }

        output.append('>');
        return output;
    }
    catch (Exception e) {
        throw new RuntimeException(String.format("Could not write type parameters %s", typeParameters));
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:24,代码来源:MethodSignatureWriter.java

示例6: appendTypeParameter

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append a type parameter
 *
 * @param typeParameter Type parameters to append
 * @param output Output to append to
 * @param <A> Type of output
 * @return Supplied output to append to
 */
public <A extends Appendable> A appendTypeParameter(Generic typeParameter, A output) {
    try {
        output.append(typeParameter.getSymbol());

        TypeList.Generic upperBounds = typeParameter.getUpperBounds();

        if (upperBounds.size() == 0) {
            throw new IllegalArgumentException(
                    String.format("Type parameter '%s' must have upper bounds", typeParameter));
        }

        if (upperBounds.get(0).isInterface()) {
            output.append(':');
        }

        for (Generic upperBound : upperBounds) {
            appendClassOrInterfaceBound(upperBound, output);
        }

        return output;
    }
    catch (Exception e) {
        throw new RuntimeException(String.format("Could not write type parameter %s", typeParameter));
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:34,代码来源:MethodSignatureWriter.java

示例7: fixName

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
static String fixName(TypeDescription.Generic type, String currentName)
{
    if (type.asErasure().equals(PROVIDER))
    {
        String name = currentName.toLowerCase();
        int providerIndex = name.indexOf("provider");
        if (providerIndex != - 1)
        {
            name = currentName.substring(0, providerIndex);
        }
        else
        {
            name = currentName;
        }
        return name;
    }
    else
    {
        return currentName;
    }
}
 
开发者ID:Diorite,项目名称:Diorite,代码行数:22,代码来源:Controller.java

示例8:

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
<T, B extends AnnotatedCodeElement & NamedElement.WithRuntimeName> ControllerInjectValueData<T> createValue
        (int index, TypeDescription classType, TypeDescription.ForLoadedType.Generic type, B member, String name,
         Map<Class<? extends Annotation>, ? extends Annotation> parentRawScopeAnnotations,
         Map<Class<? extends Annotation>, ? extends Annotation> parentRawQualifierAnnotations)
{
    Map<Class<? extends Annotation>, ? extends Annotation> scopeAnnotations;
    {
        Map<Class<? extends Annotation>, ? extends Annotation> memberRawScopeAnnotations = this.extractRawScopeAnnotations(member);
        Map<Class<? extends Annotation>, Annotation> rawScopeAnnotations = new HashMap<>(parentRawScopeAnnotations);
        rawScopeAnnotations.putAll(memberRawScopeAnnotations);
        scopeAnnotations = this.transformAll(classType, name, member, rawScopeAnnotations);
    }
    Map<Class<? extends Annotation>, ? extends Annotation> qualifierAnnotations;
    {
        Map<Class<? extends Annotation>, ? extends Annotation> memberRawQualifierAnnotations = this.extractRawQualifierAnnotations(member);
        Map<Class<? extends Annotation>, Annotation> rawQualifierAnnotations = new HashMap<>(parentRawQualifierAnnotations);
        rawQualifierAnnotations.putAll(memberRawQualifierAnnotations);
        qualifierAnnotations = this.transformAll(classType, name, member, rawQualifierAnnotations);
    }
    return new ControllerInjectValueData<>(index, name, type, scopeAnnotations, qualifierAnnotations);
}
 
开发者ID:Diorite,项目名称:Diorite,代码行数:22,代码来源:Controller.java

示例9: appendTypeParameters

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append type parameters
 *
 * @param buf Buffer to append to
 * @param typeParameters Type parameters
 * @param annotatedSignatureWriter Signature writer
 * @return <code>true</code> if any nullability information was written
 * @throws IOException if we fail completely...
 */
protected boolean appendTypeParameters(StringBuilder buf, TypeList.Generic typeParameters,
        MethodSignatureWriter annotatedSignatureWriter) throws IOException {
    String plainTypeVariables = this.signatureWriter.appendTypeParameters(typeParameters, new StringBuilder())
            .toString();
    String annotatedTypeVariables = annotatedSignatureWriter
            .appendTypeParameters(typeParameters, new StringBuilder()).toString();
    buf.append(plainTypeVariables).append("\n");
    buf.append(annotatedTypeVariables).append("\n");
    boolean annotated = !plainTypeVariables.equals(annotatedTypeVariables);
    return annotated;
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:21,代码来源:AnnotationsJarWriter.java

示例10: appendTypeArguments

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append type arguments
 *
 * @param buf Buffer to append to
 * @param typeArguments Type arguments
 * @return <code>true</code> if any nullability information was written
 * @throws IOException I'm sorry, this usually doesn't happen to me...
 */
protected boolean appendTypeArguments(StringBuilder buf, TypeList.Generic typeArguments) throws IOException {
    String plainTypeVariables = this.signatureWriter.appendTypeArguments(typeArguments, new StringBuilder())
            .toString();
    String annotatedTypeVariables = this.signatureWriter.appendTypeArguments(typeArguments, new StringBuilder())
            .toString();
    buf.append(plainTypeVariables).append("\n");
    buf.append(annotatedTypeVariables).append("\n");
    boolean annotated = plainTypeVariables.equals(annotatedTypeVariables);
    return annotated;
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:19,代码来源:AnnotationsJarWriter.java

示例11: appendBaseType

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append a base type
 *
 * @param type Type to append
 * @param output Output to append to
 * @param <A> Type of output
 * @return Supplied output to append to
 */
public <A extends Appendable> A appendBaseType(Generic type, A output) {
    try {
        output.append(type.asErasure().getDescriptor());
        return output;
    }
    catch (Exception e) {
        throw new RuntimeException(String.format("Could not write class type signature %s", type));
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:18,代码来源:MethodSignatureWriter.java

示例12: appendSimpleClassTypeSignature

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append a simple class type
 *
 * @param type Type to append
 * @param output Output to append to
 * @param <A> Type of output
 * @return Supplied output to append to
 */
public <A extends Appendable> A appendSimpleClassTypeSignature(Generic type, A output) {
    try {
        output.append(type.asErasure().getSimpleName());

        if (type.getSort() == Sort.PARAMETERIZED) {
            appendTypeArguments(type.getTypeArguments(), output);
        }

        return output;
    }
    catch (Exception e) {
        throw new RuntimeException(String.format("Could not write type signature %s", type));
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:23,代码来源:MethodSignatureWriter.java

示例13: appendTypeVariableSignature

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append a type variable signature
 *
 * @param typeVariable Type variable to append signature
 * @param nullable Nullness of type variable
 * @param output Output to append to
 * @param <A> Type of output
 * @return Supplied output to append to
 */
public <A extends Appendable> A appendTypeVariableSignature(Generic typeVariable, Nullness nullable, A output) {
    try {
        output.append('T').append(nullable.getMarker()).append(typeVariable.getTypeName()).append(';');
        return output;
    }
    catch (Exception e) {
        throw new RuntimeException(String.format("Could not type variable %s", typeVariable));
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:19,代码来源:MethodSignatureWriter.java

示例14: appendArrayTypeSignature

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append an array type signature
 *
 * @param type Array type to append
 * @param nullable Nullness of type
 * @param output Output to append to
 * @param <A> Type of output
 * @return Supplied output to append to
 */
public <A extends Appendable> A appendArrayTypeSignature(Generic type, Nullness nullable, A output) {
    try {
        output.append('[').append(nullable.getMarker());
        appendJavaTypeSignature(Validate.notNull(type.getComponentType()), Nullness.UNDEFINED, output);
        return output;
    }
    catch (Exception e) {
        throw new RuntimeException(String.format("Could not write array type %s", type));
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:20,代码来源:MethodSignatureWriter.java

示例15: appendClassOrInterfaceBound

import net.bytebuddy.description.type.TypeDescription.Generic; //导入依赖的package包/类
/**
 * Append a class or interface bound
 *
 * @param bound Bound to append
 * @param output Output to append to
 * @param <A> Type of output
 * @return Supplied output to append to
 */
public <A extends Appendable> A appendClassOrInterfaceBound(Generic bound, A output) {
    try {
        output.append(':');

        appendReferenceTypeSignature(bound, Nullness.UNDEFINED, output);

        return output;
    }
    catch (Exception e) {
        throw new RuntimeException(String.format("Could write class or interface bound %s", bound));
    }
}
 
开发者ID:jochenseeber,项目名称:gradle-project-config,代码行数:21,代码来源:MethodSignatureWriter.java


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