/** * Finalizes the build and finalizes the created type as a generic type description. * * @param annotation Type annotations place for the built generic type to declare. * @return A generic type description of the built type. */ public Generic build(Annotation... annotation) { return build(Arrays.asList(annotation)); }
/** * Finalizes the build and finalizes the created type as a generic type description. * * @param annotation Type annotations place for the built generic type to declare. * @return A generic type description of the built type. */ public Generic build(AnnotationDescription... annotation) { return build(Arrays.asList(annotation)); }
/** * Transforms this type into the upper bound of a wildcard type. * * @param annotations Type annotations to be declared by the wildcard type. * @return A generic type description of a wildcard type with this builder's type as an upper bound. */ public Generic asWildcardUpperBound(Collection<? extends AnnotationDescription> annotations) { return OfWildcardType.Latent.boundedAbove(build(), new Explicit(new ArrayList<AnnotationDescription>(annotations))); }
private static <InT, OutT> DynamicType.Unloaded<?> createDynamicTypeFromSpec(StreamingLedgerSpec<InT, OutT> spec) throws NoSuchMethodException { PackageLocalNamingStrategy generatedTypeName = new PackageLocalNamingStrategy(spec.processFunction.getClass()); TypeDefinition generatedType = Generic.Builder.parameterizedType( ProcessFunctionInvoker.class, spec.inputType.getTypeClass(), spec.resultType.getTypeClass() ).build(); TypeDefinition processFunctionType = new TypeDescription.ForLoadedType(spec.processFunction.getClass()); ForLoadedConstructor superTypeConstructor = new ForLoadedConstructor(ProcessFunctionInvoker.class.getDeclaredConstructor()); MethodDescription processMethodType = processMethodTypeFromSpec(spec); Builder<?> builder = configureByteBuddyBuilder( generatedTypeName, generatedType, processFunctionType, superTypeConstructor, processMethodType, spec.stateBindings.size()); return builder.make(); }
static TypeDefinition createTypeDefinitionFromJavaType(JavaType javaType) { if (!javaType.hasGenericTypes()) { //simply use the raw class to construct the corresponding TypeDefinition return new TypeDescription.ForLoadedType(javaType.getRawClass()); } //create the appropriate Generic TypeDescription using containedType values final List<Type> genericParameters = new ArrayList<Type>(); for(int i=0; i<javaType.containedTypeCount(); i++) { genericParameters.add(javaType.containedType(i).getRawClass()); } return Generic.Builder.parameterizedType(javaType.getRawClass(), genericParameters).build(); } }
throw new IllegalArgumentException("Require at least one enumeration constant"); TypeDescription.Generic enumType = TypeDescription.Generic.Builder.parameterizedType(Enum.class, TargetType.class).build(); return new SubclassDynamicTypeBuilder<Enum<?>>(instrumentedTypeFactory.subclass(namingStrategy.subclass(enumType), ModifierContributor.Resolver.of(Visibility.PUBLIC, TypeManifestation.FINAL, EnumerationState.ENUMERATION).resolve(),
/** * Represents the built type into an array. * * @param arity The arity of the array. * @return A builder for creating an array of the currently built type. */ public Builder asArray(int arity) { if (arity < 1) { throw new IllegalArgumentException("Cannot define an array of a non-positive arity: " + arity); } TypeDescription.Generic typeDescription = build(); while (--arity > 0) { typeDescription = new OfGenericArray.Latent(typeDescription, Empty.INSTANCE); } return new Builder.OfGenericArrayType(typeDescription); }
/** * Transforms this type into the lower bound of a wildcard type. * * @param annotations Type annotations to be declared by the wildcard type. * @return A generic type description of a wildcard type with this builder's type as an lower bound. */ public Generic asWildcardLowerBound(Collection<? extends AnnotationDescription> annotations) { return OfWildcardType.Latent.boundedBelow(build(), new Explicit(new ArrayList<AnnotationDescription>(annotations))); }
/** * Finalizes the build and finalizes the created type as a generic type description. * * @param annotations Type annotations place for the built generic type to declare. * @return A generic type description of the built type. */ public Generic build(List<? extends Annotation> annotations) { return build(new AnnotationList.ForLoadedAnnotations(annotations)); }