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

The following examples show how to use net.bytebuddy.description.type.TypeDescription#equals() . 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: Controller.java    From Diorite with MIT License 6 votes vote down vote up
@Override
protected boolean isInjectElement(AnnotatedCodeElement element)
{
    for (AnnotationDescription annotation : AsmUtils.getAnnotationList(element))
    {
        TypeDescription annotationType = annotation.getAnnotationType();
        if (annotationType.equals(INJECT))
        {
            return true;
        }
        if (annotationType.getInheritedAnnotations().isAnnotationPresent(SHORTCUT_INJECT))
        {
            return true;
        }
    }
    return false;
}
 
Example 2
Source File: FieldDescription.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean isVisibleTo(TypeDescription typeDescription) {
    return getDeclaringType().asErasure().isVisibleTo(typeDescription)
            && (isPublic()
            || typeDescription.equals(getDeclaringType().asErasure())
            || isProtected() && getDeclaringType().asErasure().isAssignableFrom(typeDescription)
            || !isPrivate() && typeDescription.isSamePackage(getDeclaringType().asErasure())
            || isPrivate() && typeDescription.isNestMateOf(getDeclaringType().asErasure()));
}
 
Example 3
Source File: FieldDescription.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean isAccessibleTo(TypeDescription typeDescription) {
    return isPublic()
            || typeDescription.equals(getDeclaringType().asErasure())
            || !isPrivate() && typeDescription.isSamePackage(getDeclaringType().asErasure())
            || isPrivate() && typeDescription.isNestMateOf(getDeclaringType().asErasure());
}
 
Example 4
Source File: MethodDescription.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean isVisibleTo(TypeDescription typeDescription) {
    return (isVirtual() || getDeclaringType().asErasure().isVisibleTo(typeDescription))
            && (isPublic()
            || typeDescription.equals(getDeclaringType().asErasure())
            || isProtected() && getDeclaringType().asErasure().isAssignableFrom(typeDescription)
            || !isPrivate() && typeDescription.isSamePackage(getDeclaringType().asErasure())
            || isPrivate() && typeDescription.isNestMateOf(getDeclaringType().asErasure()));
}
 
Example 5
Source File: MethodDescription.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean isAccessibleTo(TypeDescription typeDescription) {
    return (isVirtual() || getDeclaringType().asErasure().isVisibleTo(typeDescription))
            && (isPublic()
            || typeDescription.equals(getDeclaringType().asErasure())
            || !isPrivate() && typeDescription.isSamePackage(getDeclaringType().asErasure()))
            || isPrivate() && typeDescription.isNestMateOf(getDeclaringType().asErasure());
}
 
Example 6
Source File: MethodVariableAccess.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public StackManipulation ofIndex(TypeDescription parameterType, int index) {
    TypeDescription targetType = bridgeTarget.getParameters().get(index).getType().asErasure();
    return parameterType.equals(targetType)
            ? Trivial.INSTANCE
            : TypeCasting.to(targetType);
}
 
Example 7
Source File: Super.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public TypeDescription resolve(TypeDescription instrumentedType, TypeDescription.Generic parameterType) {
    TypeDescription erasure = parameterType.asErasure();
    return erasure.equals(instrumentedType)
            ? instrumentedType
            : erasure;
}
 
Example 8
Source File: MethodGraph.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
/**
 * Combines the two given stores.
 *
 * @param left  The left store to be combined.
 * @param right The right store to be combined.
 * @param <W>   The type of the harmonized key of both stores.
 * @return An entry representing the combination of both stores.
 */
private static <W> Entry<W> combine(Entry<W> left, Entry<W> right) {
    Set<MethodDescription> leftMethods = left.getCandidates(), rightMethods = right.getCandidates();
    LinkedHashSet<MethodDescription> combined = new LinkedHashSet<MethodDescription>();
    combined.addAll(leftMethods);
    combined.addAll(rightMethods);
    for (MethodDescription leftMethod : leftMethods) {
        TypeDescription leftType = leftMethod.getDeclaringType().asErasure();
        for (MethodDescription rightMethod : rightMethods) {
            TypeDescription rightType = rightMethod.getDeclaringType().asErasure();
            if (leftType.equals(rightType)) {
                break;
            } else if (leftType.isAssignableTo(rightType)) {
                combined.remove(rightMethod);
                break;
            } else if (leftType.isAssignableFrom(rightType)) {
                combined.remove(leftMethod);
                break;
            }
        }
    }
    Key.Harmonized<W> key = left.getKey().combineWith(right.getKey());
    Visibility visibility = left.getVisibility().expandTo(right.getVisibility());
    return combined.size() == 1
            ? new Entry.Resolved<W>(key, combined.iterator().next(), visibility, Entry.Resolved.NOT_MADE_VISIBLE)
            : new Entry.Ambiguous<W>(key, combined, visibility);
}
 
Example 9
Source File: AsmUtils.java    From Diorite with MIT License 4 votes vote down vote up
/**
 * If given type is primitive type {@link TypeDescription#isPrimitive()} then it will return
 * wrapper type for it. Like: boolean.class {@literal ->} Boolean.class
 * If given type isn't primitive, then it will return given type.
 *
 * @param type
 *         type to get wrapper of it.
 *
 * @return non-primitive type.
 */
public static TypeDescription getWrapperClass(TypeDescription type)
{
    if (! type.isPrimitive())
    {
        return type;
    }
    if (type.equals(BOOLEAN_P))
    {
        return BOOLEAN;
    }
    if (type.equals(BYTE_P))
    {
        return BYTE;
    }
    if (type.equals(SHORT_P))
    {
        return SHORT;
    }
    if (type.equals(CHAR_P))
    {
        return CHARACTER;
    }
    if (type.equals(INT_P))
    {
        return INTEGER;
    }
    if (type.equals(LONG_P))
    {
        return LONG;
    }
    if (type.equals(FLOAT_P))
    {
        return FLOAT;
    }
    if (type.equals(DOUBLE_P))
    {
        return DOUBLE;
    }
    if (type.equals(VOID_P))
    {
        return VOID;
    }
    throw new Error("Unknown primitive type?"); // not possible?
}