class X { public int abc() {return 1;}
* }
*
*
* [accessSpecifier] [static] [abstract] [final] [native]
* [synchronized] returnType methodName ([paramType [paramName]])
* [throws exceptionsList]
*
* @return method declaration as String
*/
@Override
public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows, boolean includingParameterName) {
StringBuilder sb = new StringBuilder();
if (includingModifiers) {
AccessSpecifier accessSpecifier = getAccessSpecifier(getModifiers());
sb.append(accessSpecifier.asString());
sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " ");
if (getModifiers().contains(STATIC)) {
sb.append("static ");
}
if (getModifiers().contains(ABSTRACT)) {
sb.append("abstract ");
}
if (getModifiers().contains(FINAL)) {
sb.append("final ");
}
if (getModifiers().contains(NATIVE)) {
sb.append("native ");
}
if (getModifiers().contains(SYNCHRONIZED)) {
sb.append("synchronized ");
}
}
sb.append(getType().toString(prettyPrinterNoCommentsConfiguration));
sb.append(" ");
sb.append(getName());
sb.append("(");
boolean firstParam = true;
for (Parameter param : getParameters()) {
if (firstParam) {
firstParam = false;
} else {
sb.append(", ");
}
if (includingParameterName) {
sb.append(param.toString(prettyPrinterNoCommentsConfiguration));
} else {
sb.append(param.getType().toString(prettyPrinterNoCommentsConfiguration));
if (param.isVarArgs()) {
sb.append("...");
}
}
}
sb.append(")");
sb.append(appendThrowsIfRequested(includingThrows));
return sb.toString();
}
public boolean isNative() {
return getModifiers().contains(NATIVE);
}
public boolean isSynchronized() {
return getModifiers().contains(SYNCHRONIZED);
}
public boolean isDefault() {
return getModifiers().contains(DEFAULT);
}
public MethodDeclaration setNative(boolean set) {
return setModifier(NATIVE, set);
}
public MethodDeclaration setSynchronized(boolean set) {
return setModifier(SYNCHRONIZED, set);
}
public MethodDeclaration setDefault(boolean set) {
return setModifier(DEFAULT, set);
}
@Override
@Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
public boolean remove(Node node) {
if (node == null)
return false;
if (body != null) {
if (node == body) {
removeBody();
return true;
}
}
return super.remove(node);
}
@Generated("com.github.javaparser.generator.core.node.RemoveMethodGenerator")
public MethodDeclaration removeBody() {
return setBody((BlockStmt) null);
}
@Override
@Generated("com.github.javaparser.generator.core.node.CloneGenerator")
public MethodDeclaration clone() {
return (MethodDeclaration) accept(new CloneVisitor(), null);
}
@Override
@Generated("com.github.javaparser.generator.core.node.GetMetaModelGenerator")
public MethodDeclarationMetaModel getMetaModel() {
return JavaParserMetaModel.methodDeclarationMetaModel;
}
@Override
@Generated("com.github.javaparser.generator.core.node.ReplaceMethodGenerator")
public boolean replace(Node node, Node replacementNode) {
if (node == null)
return false;
if (body != null) {
if (node == body) {
setBody((BlockStmt) replacementNode);
return true;
}
}
if (node == type) {
setType((Type) replacementNode);
return true;
}
return super.replace(node, replacementNode);
}
@Override
@Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
public boolean isMethodDeclaration() {
return true;
}
@Override
@Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
public MethodDeclaration asMethodDeclaration() {
return this;
}
@Generated("com.github.javaparser.generator.core.node.TypeCastingGenerator")
public void ifMethodDeclaration(Consumer