private static boolean isCollectionOfSerializable(Tree tree) { if (tree.is(Tree.Kind.PARAMETERIZED_TYPE)) { ParameterizedTypeTree typeTree = (ParameterizedTypeTree) tree; if (isSubtypeOfCollectionApi(typeTree.symbolType())) { return typeTree.typeArguments().stream().allMatch(SerializableFieldInSerializableClassCheck::isCollectionOfSerializable); } } return isSerializable(tree); }
private static boolean isCollectionOfSerializable(Tree tree) { if (tree.is(Tree.Kind.PARAMETERIZED_TYPE)) { ParameterizedTypeTree typeTree = (ParameterizedTypeTree) tree; if (isSubtypeOfCollectionApi(typeTree.symbolType())) { return typeTree.typeArguments().stream().allMatch(SerializableFieldInSerializableClassCheck::isCollectionOfSerializable); } } return isSerializable(tree); }
@CheckForNull private static MethodJavaType getMethodType(JavaSymbol.MethodJavaSymbol methodSymbol, Tree methodName) { if (!methodSymbol.isParametrized()) { return null; } Type type = null; if (methodName.is(Tree.Kind.MEMBER_SELECT)) { type = ((MemberSelectExpressionTree) methodName).identifier().symbolType(); } else if (methodName.is(Tree.Kind.IDENTIFIER)) { type = ((IdentifierTree) methodName).symbolType(); } else if (methodName.is(Tree.Kind.PARAMETERIZED_TYPE)) { type = ((ParameterizedTypeTree) methodName).symbolType(); } if (type instanceof MethodJavaType) { return (MethodJavaType) type; } return null; }
@CheckForNull private static MethodJavaType getMethodType(JavaSymbol.MethodJavaSymbol methodSymbol, Tree methodName) { if (!methodSymbol.isParametrized()) { return null; } Type type = null; if (methodName.is(Tree.Kind.MEMBER_SELECT)) { type = ((MemberSelectExpressionTree) methodName).identifier().symbolType(); } else if (methodName.is(Tree.Kind.IDENTIFIER)) { type = ((IdentifierTree) methodName).symbolType(); } else if (methodName.is(Tree.Kind.PARAMETERIZED_TYPE)) { type = ((ParameterizedTypeTree) methodName).symbolType(); } if (type instanceof MethodJavaType) { return (MethodJavaType) type; } return null; }