本文整理匯總了Java中com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.isInterface方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassOrInterfaceDeclaration.isInterface方法的具體用法?Java ClassOrInterfaceDeclaration.isInterface怎麽用?Java ClassOrInterfaceDeclaration.isInterface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
的用法示例。
在下文中一共展示了ClassOrInterfaceDeclaration.isInterface方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visit
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override
public Node visit(ClassOrInterfaceDeclaration _n, Object _arg) {
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg);
List<ClassOrInterfaceType> extendsList = visit(_n.getExtends(), _arg);
List<ClassOrInterfaceType> implementsList = visit(_n.getImplements(), _arg);
List<BodyDeclaration<?>> members = visit(_n.getMembers(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
ClassOrInterfaceDeclaration r = new ClassOrInterfaceDeclaration(
_n.getRange(),
_n.getModifiers(), annotations, _n.isInterface(), _n.getName(), typeParameters, extendsList, implementsList, members
);
r.setComment(comment);
return r;
}
示例2: visit
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override
public Node visit(ClassOrInterfaceDeclaration _n, Object _arg) {
JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
List<TypeParameter> typeParameters = visit(_n.getTypeParameters(), _arg);
List<ClassOrInterfaceType> extendsList = visit(_n.getExtends(), _arg);
List<ClassOrInterfaceType> implementsList = visit(_n.getImplements(), _arg);
List<BodyDeclaration> members = visit(_n.getMembers(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
ClassOrInterfaceDeclaration r = new ClassOrInterfaceDeclaration(
_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
_n.getModifiers(), annotations, _n.isInterface(), _n.getName(), typeParameters, extendsList, implementsList, members
);
r.setComment(comment);
return r;
}
示例3: visit
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override
public void visit( ClassOrInterfaceDeclaration n, Void arg) {
if (!nodeName.equals(n.getNameAsString()+ ".java"))
add( new InnerNode(n));
else
isInterface = n.isInterface();
super.visit(n, arg);
}
示例4: visit
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override
public void visit(final ClassOrInterfaceDeclaration n, final Void arg) {
super.visit(n, arg);
List<?> superIfcs = n.getImplements();
implmts = superIfcs != null && !superIfcs.isEmpty() ? superIfcs.toString() : null;
if (!n.isInterface()) {
final List<ClassOrInterfaceType> e = n.getExtends();
if (!e.isEmpty()) {
extnds = e.get(0).toString();
}
}
}
示例5: visit
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override public Boolean visit(final ClassOrInterfaceDeclaration n1, final Node arg) {
final ClassOrInterfaceDeclaration n2 = (ClassOrInterfaceDeclaration) arg;
// javadoc are checked at CompilationUnit
if (n1.getModifiers() != n2.getModifiers()) {
return Boolean.FALSE;
}
if (n1.isInterface() != n2.isInterface()) {
return Boolean.FALSE;
}
if (!objEquals(n1.getName(), n2.getName())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getExtends(), n2.getExtends())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getImplements(), n2.getImplements())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getMembers(), n2.getMembers())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例6: visit
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override public Boolean visit(final ClassOrInterfaceDeclaration n1, final Node arg) {
final ClassOrInterfaceDeclaration n2 = (ClassOrInterfaceDeclaration) arg;
// javadoc are checked at CompilationUnit
if (!n1.getModifiers().equals(n2.getModifiers())) {
return false;
}
if (n1.isInterface() != n2.isInterface()) {
return false;
}
if (!objEquals(n1.getName(), n2.getName())) {
return false;
}
if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) {
return false;
}
if (!nodesEquals(n1.getTypeParameters(), n2.getTypeParameters())) {
return false;
}
if (!nodesEquals(n1.getExtends(), n2.getExtends())) {
return false;
}
if (!nodesEquals(n1.getImplements(), n2.getImplements())) {
return false;
}
if (!nodesEquals(n1.getMembers(), n2.getMembers())) {
return false;
}
return true;
}
示例7: JavaParserInterfaceDeclaration
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
public JavaParserInterfaceDeclaration(ClassOrInterfaceDeclaration wrappedNode, TypeSolver typeSolver) {
if (!wrappedNode.isInterface()) {
throw new IllegalArgumentException();
}
this.wrappedNode = wrappedNode;
this.typeSolver = typeSolver;
this.javaParserTypeAdapter = new JavaParserTypeAdapter(wrappedNode, typeSolver);
}
示例8: JavaParserInterfaceDeclaration
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
public JavaParserInterfaceDeclaration(ClassOrInterfaceDeclaration wrappedNode, TypeSolver typeSolver) {
if (!wrappedNode.isInterface()) {
throw new IllegalArgumentException();
}
this.wrappedNode = wrappedNode;
this.typeSolver = typeSolver;
this.javaParserTypeAdapter = new JavaParserTypeAdapter<>(wrappedNode, typeSolver);
}
示例9: visit
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override
public Node visit(final ClassOrInterfaceDeclaration n, final Object arg) {
if (!(n.isInterface())) {
// Preserve the value of flag indicating that enclosing class
// has found the default constructor.
boolean storedprev = founddefault;
founddefault = false;
// Generates a new list, which might even be empty.
Vector<BodyDeclaration> lnewlist = new Vector<BodyDeclaration>();
/* Code for unfolding field declaration */
if (n.getMembers() != null) {
for (final BodyDeclaration b : n.getMembers()) {
BodyDeclaration mydecl = (BodyDeclaration) b.accept(this, arg);
// Append the expanded list to list of bodydeclaration
if (mydecl instanceof ListFieldDeclaration) {
lnewlist.addAll(((ListFieldDeclaration) mydecl).getVarDecls());
} else {
lnewlist.add(mydecl);
}
}
}
/*
Code for detecting declaration of default contructor.
Clone metadata from class declaration.
*/
if (!(founddefault)) {
lnewlist.add(new ConstructorDeclaration(n.getModifiers(),
new Vector<AnnotationExpr>(),
new Vector<TypeParameter>(),
n.getName(),
new Vector<Parameter>(),
new Vector<NameExpr>(),
new BlockStmt(new Vector<Statement>())));
}
// Restore the value for the flag relative to enclosing class
founddefault = storedprev;
// Set the generated list
n.setMembers(lnewlist);
}
return n;
}
示例10: parse
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
/**
*
* @throws FileNotFoundException
* @throws ParseException
*/
public void parse() throws FileNotFoundException, ParseException {
InputStream in = this.inputStream;
// boolean arg in parse() is for taknig the javadoc into account
// sadly it is not supported yet by the github javaparser
this.unit = JavaParser.parse(in, "UTF-8", true);
PackageDeclaration pkg = this.unit.getPackage();
if (pkg != null && pkg.getName() != null) {
this.packageName = pkg.getName().getName();
this.loc++;
}
if (this.unit.getImports() != null) {
this.imports = new ArrayList<>();
for (ImportDeclaration imp : this.unit.getImports()) {
this.imports.add(imp.getName().toString());
}
}
// for each class in the source file
if (this.unit.getTypes() != null) {
for (TypeDeclaration td : this.unit.getTypes()) {
if (td instanceof ClassOrInterfaceDeclaration) {
ClassOrInterfaceDeclaration classOrInt = (ClassOrInterfaceDeclaration) td;
if (classOrInt.isInterface()) {
this.interfaces.add(parseInterface(td));
} else {
this.classes.add(parseClass(td));
}
this.loc++;
} else if (td instanceof EnumDeclaration) {
this.enums.add(parseEnum(td));
this.loc++;
}
}
} else {
// TODO: parse package-info.java
// not done yet because of the non support of javadoc by github javaparser.parser
if (this.unit.getAllContainedComments() != null) {
for (Comment com : this.unit.getAllContainedComments()) {
this.packageInfoComments.addAll(ParserUtils.prepareComments(com.getContent()));
}
}
this.packageInfo = true;
}
}
示例11: visit
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
/**
* Increment classes metric
*
* @param declaration
* @param collector
*/
@Override
public void visit(ClassOrInterfaceDeclaration declaration, Collector collector) {
if (declaration.isInterface()) {
collector.incrementMetric("Interfaces");
} else {
collector.incrementMetric("Classes");
if (declaration.isFinal()) {
collector.incrementMetric("Final Classes");
}
if (declaration.isAbstract()) {
collector.incrementMetric("Abstract Classes");
}
}
if (className.endsWith("Test")) {
collector.incrementMetric("Test Classes");
}
super.visit(declaration, collector);
}