本文整理汇总了Java中com.github.javaparser.ast.Modifier.getAccessSpecifier方法的典型用法代码示例。如果您正苦于以下问题:Java Modifier.getAccessSpecifier方法的具体用法?Java Modifier.getAccessSpecifier怎么用?Java Modifier.getAccessSpecifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.Modifier
的用法示例。
在下文中一共展示了Modifier.getAccessSpecifier方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDeclarationAsString
import com.github.javaparser.ast.Modifier; //导入方法依赖的package包/类
/**
* The declaration returned has this schema:
*
* [accessSpecifier] className ([paramType [paramName]])
* [throws exceptionsList]
*/
@Override
public String getDeclarationAsString(boolean includingModifiers, boolean includingThrows,
boolean includingParameterName) {
StringBuilder sb = new StringBuilder();
if (includingModifiers) {
AccessSpecifier accessSpecifier = Modifier.getAccessSpecifier(getModifiers());
sb.append(accessSpecifier.getCodeRepresenation());
sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " ");
}
sb.append(getName());
sb.append("(");
boolean firstParam = true;
for (Parameter param : getParameters()) {
if (firstParam) {
firstParam = false;
} else {
sb.append(", ");
}
if (includingParameterName) {
sb.append(param.toStringWithoutComments());
} else {
sb.append(param.getElementType().toStringWithoutComments());
}
}
sb.append(")");
if (includingThrows) {
boolean firstThrow = true;
for (ReferenceType thr : getThrows()) {
if (firstThrow) {
firstThrow = false;
sb.append(" throws ");
} else {
sb.append(", ");
}
sb.append(thr.toStringWithoutComments());
}
}
return sb.toString();
}
示例2: getDeclarationAsString
import com.github.javaparser.ast.Modifier; //导入方法依赖的package包/类
/**
* The declaration returned has this schema:
*
* [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 = Modifier.getAccessSpecifier(getModifiers());
sb.append(accessSpecifier.getCodeRepresenation());
sb.append(accessSpecifier == AccessSpecifier.DEFAULT ? "" : " ");
if (getModifiers().contains(Modifier.STATIC)) {
sb.append("static ");
}
if (getModifiers().contains(Modifier.ABSTRACT)) {
sb.append("abstract ");
}
if (getModifiers().contains(Modifier.FINAL)) {
sb.append("final ");
}
if (getModifiers().contains(Modifier.NATIVE)) {
sb.append("native ");
}
if (getModifiers().contains(Modifier.SYNCHRONIZED)) {
sb.append("synchronized ");
}
}
// TODO verify it does not print comments connected to the type
sb.append(getElementType().toStringWithoutComments());
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.toStringWithoutComments());
} else {
sb.append(param.getElementType().toStringWithoutComments());
if (param.isVarArgs()) {
sb.append("...");
}
}
}
sb.append(")");
if (includingThrows) {
boolean firstThrow = true;
for (ReferenceType thr : getThrows()) {
if (firstThrow) {
firstThrow = false;
sb.append(" throws ");
} else {
sb.append(", ");
}
sb.append(thr.toStringWithoutComments());
}
}
return sb.toString();
}