private static boolean isBoolean(ParameterTypeNameAndTreeType type) { return type.paramType.is("java.lang.Boolean"); }
private static boolean isBoolean(ParameterTypeNameAndTreeType type) { return type.paramType.is("java.lang.Boolean"); }
@Override public boolean is(String fullyQualifiedName) { return fullyQualifiedName.endsWith("[]") && elementType.is(fullyQualifiedName.substring(0, fullyQualifiedName.length() - 2)); }
@Override public boolean is(String fullyQualifiedName) { return fullyQualifiedName.endsWith("[]") && elementType.is(fullyQualifiedName.substring(0, fullyQualifiedName.length() - 2)); }
@Override public boolean is(String fullyQualifiedName) { if (tag < CLASS) { // primitive type return fullyQualifiedName.equals(symbol.name); } else if (isTagged(ARRAY)) { return fullyQualifiedName.endsWith("[]") && ((ArrayJavaType) this).elementType.is(fullyQualifiedName.substring(0, fullyQualifiedName.length() - 2)); } else if (isTagged(TYPEVAR)) { return false; } return false; }
public Optional<Object> constantValue() { if (Flags.isFlagged(flags, Flags.STATIC) && Flags.isFlagged(flags, Flags.FINAL)) { if (value != null && type.is("boolean")) { return Optional.of(Integer.valueOf(1).equals(value) ? Boolean.TRUE : Boolean.FALSE); } return Optional.ofNullable(value); } return Optional.empty(); }
@Override public boolean is(String fullyQualifiedName) { if (tag < CLASS) { // primitive type return fullyQualifiedName.equals(symbol.name); } else if (isTagged(ARRAY)) { return fullyQualifiedName.endsWith("[]") && ((ArrayJavaType) this).elementType.is(fullyQualifiedName.substring(0, fullyQualifiedName.length() - 2)); } else if (isTagged(TYPEVAR)) { return false; } return false; }
private static boolean isInStringArrayInitializer(ExpressionTree arg) { return Optional.of(arg) .map(Tree::parent) .filter(tree -> tree.is(Tree.Kind.LIST)) .map(Tree::parent) .filter(tree -> tree.is(Tree.Kind.NEW_ARRAY)) .map(NewArrayTree.class::cast) .map(ExpressionTree::symbolType) .filter(Type::isArray) .map(ArrayJavaType.class::cast) .map(ArrayJavaType::elementType) .filter(type -> type.is(JAVA_LANG_STRING)) .isPresent(); }
public Optional<Object> constantValue() { if (Flags.isFlagged(flags, Flags.STATIC) && Flags.isFlagged(flags, Flags.FINAL)) { if (value != null && type.is("boolean")) { return Optional.of(Integer.valueOf(1).equals(value) ? Boolean.TRUE : Boolean.FALSE); } return Optional.ofNullable(value); } return Optional.empty(); }
private static boolean isInStringArrayInitializer(ExpressionTree arg) { return Optional.of(arg) .map(Tree::parent) .filter(tree -> tree.is(Tree.Kind.LIST)) .map(Tree::parent) .filter(tree -> tree.is(Tree.Kind.NEW_ARRAY)) .map(NewArrayTree.class::cast) .map(ExpressionTree::symbolType) .filter(Type::isArray) .map(ArrayJavaType.class::cast) .map(ArrayJavaType::elementType) .filter(type -> type.is(JAVA_LANG_STRING)) .isPresent(); }
@Override public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { JavaType annotationType = bytecodeVisitor.convertAsmType(org.objectweb.asm.Type.getType(desc), Flags.ANNOTATION); if (annotationType.is("java.lang.Synthetic")) { syntheticArgs++; } else { AnnotationInstanceResolve annotationInstance = new AnnotationInstanceResolve(annotationType.getSymbol()); methodSymbol.getParameters().scopeSymbols().get(parameter - syntheticArgs).metadata().addAnnotation(annotationInstance); return new BytecodeAnnotationVisitor(annotationInstance, bytecodeVisitor); } return null; }
@Override public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { JavaType annotationType = bytecodeVisitor.convertAsmType(org.objectweb.asm.Type.getType(desc), Flags.ANNOTATION); if (annotationType.is("java.lang.Synthetic")) { syntheticArgs++; } else { AnnotationInstanceResolve annotationInstance = new AnnotationInstanceResolve(annotationType.getSymbol()); methodSymbol.getParameters().scopeSymbols().get(parameter - syntheticArgs).metadata().addAnnotation(annotationInstance); return new BytecodeAnnotationVisitor(annotationInstance, bytecodeVisitor); } return null; }
private static boolean isSAM(ClassTree classBody) { if (hasOnlyOneMethod(classBody.members())) { // When overriding only one method of a functional interface, it can only be the single abstract method // and not one of the default methods. No need to check that the method signature matches. JavaSymbol.TypeJavaSymbol symbol = (JavaSymbol.TypeJavaSymbol) classBody.symbol(); // should be anonymous class of interface and not abstract class return symbol.getInterfaces().size() == 1 && symbol.getSuperclass().is(JAVA_LANG_OBJECT) && hasSingleAbstractMethodInHierarchy(symbol.superTypes()); } return false; }
@Override public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { JavaType annotationType = bytecodeVisitor.convertAsmType(org.objectweb.asm.Type.getType(desc)); if (annotationType.is("java.lang.Synthetic")) { syntheticArgs++; } else { AnnotationInstanceResolve annotationInstance = new AnnotationInstanceResolve(annotationType.getSymbol()); methodSymbol.getParameters().scopeSymbols().get(parameter - syntheticArgs).metadata().addAnnotation(annotationInstance); return new BytecodeAnnotationVisitor(annotationInstance, bytecodeVisitor); } return null; } }
@Override public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { JavaType annotationType = bytecodeVisitor.convertAsmType(org.objectweb.asm.Type.getType(desc)); if (annotationType.is("java.lang.Synthetic")) { syntheticArgs++; } else { AnnotationInstanceResolve annotationInstance = new AnnotationInstanceResolve(annotationType.getSymbol()); methodSymbol.getParameters().scopeSymbols().get(parameter - syntheticArgs).metadata().addAnnotation(annotationInstance); return new BytecodeAnnotationVisitor(annotationInstance, bytecodeVisitor); } return null; } }
private static boolean isSAM(ClassTree classBody) { if (hasOnlyOneMethod(classBody.members())) { // When overriding only one method of a functional interface, it can only be the single abstract method // and not one of the default methods. No need to check that the method signature matches. JavaSymbol.TypeJavaSymbol symbol = (JavaSymbol.TypeJavaSymbol) classBody.symbol(); // should be anonymous class of interface and not abstract class return symbol.getInterfaces().size() == 1 && symbol.getSuperclass().is(JAVA_LANG_OBJECT) && hasSingleAbstractMethodInHierarchy(symbol.superTypes()); } return false; }