本文整理汇总了Java中net.bytebuddy.description.type.TypeDescription.Generic方法的典型用法代码示例。如果您正苦于以下问题:Java TypeDescription.Generic方法的具体用法?Java TypeDescription.Generic怎么用?Java TypeDescription.Generic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.bytebuddy.description.type.TypeDescription
的用法示例。
在下文中一共展示了TypeDescription.Generic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fixName
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的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;
}
}
示例2: isMatch
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@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);
}
if (parentTypes.size() == 0) {
return true;
}
return false;
}
示例3: matchHierarchyClass
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
private void matchHierarchyClass(TypeDescription.Generic clazz, List<String> parentTypes) {
parentTypes.remove(clazz.getTypeName());
if (parentTypes.size() == 0) {
return;
}
for (TypeDescription.Generic generic : clazz.getInterfaces()) {
matchHierarchyClass(generic, parentTypes);
}
TypeDescription.Generic superClazz = clazz.getSuperClass();
if (superClazz != null && !clazz.getTypeName().equals("java.lang.Object")) {
matchHierarchyClass(superClazz, parentTypes);
}
}
示例4: matchHierarchyClazz
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
private void matchHierarchyClazz(TypeDescription.Generic clazz, MatchResult matchResult) {
if (clazz.asRawType().getTypeName().equals(getMutexInterface())) {
matchResult.findMutexInterface = true;
return;
}
if (clazz.asRawType().getTypeName().equals(getMatchInterface())) {
matchResult.findMatchInterface = true;
}
for (TypeDescription.Generic generic : clazz.getInterfaces()) {
matchHierarchyClazz(generic, matchResult);
}
TypeDescription.Generic superClazz = clazz.getSuperClass();
if (superClazz != null && !clazz.getTypeName().equals(OBJECT_CLASS_NAME)) {
matchHierarchyClazz(superClazz, matchResult);
}
}
示例5: matchExactClass
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
private boolean matchExactClass(TypeDescription.Generic clazz) {
if (clazz.asRawType().getTypeName().equals(LISTENABLE_FUTURE_CALLBACK_CLASS_NAME)) {
return true;
}
boolean isMatch = false;
for (TypeDescription.Generic generic : clazz.getInterfaces()) {
isMatch = isMatch || matchExactClass(generic);
}
if (!isMatch) {
TypeDescription.Generic superClazz = clazz.getSuperClass();
if (superClazz != null && !clazz.getTypeName().equals("java.lang.Object")) {
isMatch = isMatch || matchExactClass(superClazz);
}
}
return isMatch;
}
示例6: subclass
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
/**
* <p>
* Creates a new builder for subclassing the provided type. If the provided type is an interface, a new class implementing
* this interface type is created.
* </p>
* <p>
* <b>Note</b>: This methods implements the supplied types <i>as is</i>, i.e. any {@link TypeDescription} values are implemented
* as raw types if they declare type variables.
* </p>
* <p>
* <b>Note</b>: Byte Buddy does not cache previous subclasses but will attempt the generation of a new subclass. For caching
* types, a external cache or {@link TypeCache} should be used.
* </p>
*
* @param superType The super class or interface type to extend. The type must be a raw type or parameterized
* type. All type variables that are referenced by the generic type must be declared by the
* generated subclass before creating the type.
* @param constructorStrategy A constructor strategy that determines the
* @return A type builder for creating a new class extending the provided class or interface.
*/
public DynamicType.Builder<?> subclass(TypeDefinition superType, ConstructorStrategy constructorStrategy) {
TypeDescription.Generic actualSuperType;
TypeList.Generic interfaceTypes;
if (superType.isPrimitive() || superType.isArray() || superType.isFinal()) {
throw new IllegalArgumentException("Cannot subclass primitive, array or final types: " + superType);
} else if (superType.isInterface()) {
actualSuperType = TypeDescription.Generic.OBJECT;
interfaceTypes = new TypeList.Generic.Explicit(superType);
} else {
actualSuperType = superType.asGenericType();
interfaceTypes = new TypeList.Generic.Empty();
}
return new SubclassDynamicTypeBuilder<Object>(instrumentedTypeFactory.subclass(namingStrategy.subclass(superType.asGenericType()),
ModifierContributor.Resolver.of(Visibility.PUBLIC, TypeManifestation.PLAIN).resolve(superType.getModifiers()),
actualSuperType).withInterfaces(interfaceTypes),
classFileVersion,
auxiliaryTypeNamingStrategy,
annotationValueFilterFactory,
annotationRetention,
implementationContextFactory,
methodGraphCompiler,
typeValidation,
ignoredMethods,
constructorStrategy);
}
示例7: Token
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
/**
* Creates a new token for a method description. All types must be represented in an detached format.
*
* @param name The internal name of the represented method.
* @param modifiers The modifiers of the represented method.
* @param typeVariableTokens The type variables of the the represented method.
* @param returnType The return type of the represented method.
* @param parameterTokens The parameter tokens of the represented method.
* @param exceptionTypes The exception types of the represented method.
* @param annotations The annotations of the represented method.
* @param defaultValue The default value of the represented method or {@code null} if no such value exists.
* @param receiverType The receiver type of the represented method or {@code null} if the receiver type is implicit.
*/
public Token(String name,
int modifiers,
List<? extends TypeVariableToken> typeVariableTokens,
TypeDescription.Generic returnType,
List<? extends ParameterDescription.Token> parameterTokens,
List<? extends TypeDescription.Generic> exceptionTypes,
List<? extends AnnotationDescription> annotations,
AnnotationValue<?, ?> defaultValue,
TypeDescription.Generic receiverType) {
this.name = name;
this.modifiers = modifiers;
this.typeVariableTokens = typeVariableTokens;
this.returnType = returnType;
this.parameterTokens = parameterTokens;
this.exceptionTypes = exceptionTypes;
this.annotations = annotations;
this.defaultValue = defaultValue;
this.receiverType = receiverType;
}
示例8: beforeDelegation
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Override
protected StackManipulation beforeDelegation(MethodDescription instrumentedMethod) {
List<StackManipulation> pushParameters = new ArrayList<>();
TypeList.Generic paramTypes = targetMethod.getParameters().asTypeList();
for (int i = 0; i < paramTypes.size(); i++) {
TypeDescription.Generic paramT = paramTypes.get(i);
pushParameters.add(MethodVariableAccess.of(paramT).loadFrom(i + 1));
if (!paramT.isPrimitive()) {
pushParameters.add(TypeCasting.to(paramT));
}
}
return new StackManipulation.Compound(pushParameters);
}
示例9: isMatch
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@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();
}
示例10: mapDefault
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
/**
* Provides a default data mapper with general read and write functionality.
*
* @param modelClass the class of the model
* @param <T> class type
* @return new default mapper instance
*/
public <T extends IdProvider> DefaultMapper<T> mapDefault(Class<T> modelClass) {
TypeDescription.Generic generic = TypeDescription.Generic.Builder
.parameterizedType(DefaultMapper.class, modelClass)
.build();
Builder<DefaultMapper<T> > builder = (Builder<DefaultMapper<T> >) buddy.makeInterface(generic);
builder = builder.annotateType(
AnnotationDescription.Builder.ofType(Mapper.class)
.define("value", modelClass.getName())
.build());
return map(builder.make()
.load(modelClass.getClassLoader(), ClassLoadingStrategy.Default.INJECTION)
.getLoaded());
}
示例11: assign
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Override
public StackManipulation assign(TypeDescription.Generic source, TypeDescription.Generic target, Typing typing) {
if (source.isPrimitive() && target.isPrimitive()) {
return PrimitiveWideningDelegate.forPrimitive(source).widenTo(target);
} else if (source.isPrimitive() /* && !target.isPrimitive() */) {
return PrimitiveBoxingDelegate.forPrimitive(source).assignBoxedTo(target, referenceTypeAwareAssigner, typing);
} else if (/* !source.isPrimitive() && */ target.isPrimitive()) {
return PrimitiveUnboxingDelegate.forReferenceType(source).assignUnboxedTo(target, referenceTypeAwareAssigner, typing);
} else /* !source.isPrimitive() && !target.isPrimitive()) */ {
return referenceTypeAwareAssigner.assign(source, target, typing);
}
}
示例12: TypeSubstituting
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
/**
* Creates a new type substituting field list.
*
* @param declaringType The field's actual declaring type.
* @param fieldDescriptions The field descriptions to be transformed.
* @param visitor The visitor to apply to a field description.
*/
public TypeSubstituting(TypeDescription.Generic declaringType,
List<? extends FieldDescription> fieldDescriptions,
TypeDescription.Generic.Visitor<? extends TypeDescription.Generic> visitor) {
this.declaringType = declaringType;
this.fieldDescriptions = fieldDescriptions;
this.visitor = visitor;
}
示例13: invokeConstructor
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
/**
* Resolves a special method invocation for a constructor invocation.
*
* @param token A token describing the constructor to be invoked.
* @return A special method invocation for a constructor representing the given method token, if available.
*/
private Implementation.SpecialMethodInvocation invokeConstructor(MethodDescription.SignatureToken token) {
TypeDescription.Generic superClass = instrumentedType.getSuperClass();
MethodList<?> candidates = superClass == null
? new MethodList.Empty<MethodDescription.InGenericShape>()
: superClass.getDeclaredMethods().filter(hasSignature(token).and(isVisibleTo(instrumentedType)));
return candidates.size() == 1
? Implementation.SpecialMethodInvocation.Simple.of(candidates.getOnly(), instrumentedType.getSuperClass().asErasure())
: Implementation.SpecialMethodInvocation.Illegal.INSTANCE;
}
示例14: assignUnboxedTo
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
@Override
public StackManipulation assignUnboxedTo(TypeDescription.Generic target, Assigner assigner, Assigner.Typing typing) {
PrimitiveUnboxingDelegate primitiveUnboxingDelegate = PrimitiveUnboxingDelegate.forPrimitive(target);
return new Compound(
assigner.assign(originalType, primitiveUnboxingDelegate.getWrapperType(), typing),
primitiveUnboxingDelegate);
}
示例15: BinderValueData
import net.bytebuddy.description.type.TypeDescription; //导入方法依赖的package包/类
BinderValueData(Predicate<TypeDescription.Generic> typePredicate, Collection<QualifierPattern> qualifiers)
{
this.typePredicate = typePredicate;
this.qualifiers = qualifiers;
}