本文整理了Java中com.sun.codemodel.JBlock.getContents()
方法的一些代码示例,展示了JBlock.getContents()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JBlock.getContents()
方法的具体详情如下:
包路径:com.sun.codemodel.JBlock
类名称:JBlock
方法名:getContents
[英]Returns a read-only view of JStatements and JDeclarationin this block.
[中]返回此块中JStatements和JDEClaration的只读视图。
代码示例来源:origin: com.googlecode.androidannotations/androidannotations
public JBlock removeBody(JMethod method) {
JBlock body = method.body();
try {
Field bodyField = JMethod.class.getDeclaredField("body");
bodyField.setAccessible(true);
bodyField.set(method, null);
} catch (Exception e) {
throw new RuntimeException(e);
}
JBlock clonedBody = new JBlock(false, false);
for (Object statement : body.getContents()) {
clonedBody.add((JStatement) statement);
}
return clonedBody;
}
代码示例来源:origin: krasa/krasa-jaxb-tools
/**
* I hate this shit
*/
private JMethod getMethodsMap(MethodType type, JFieldVar field, ClassOutline co) {
String getterBody = "return " + field.name() + ";";
for (JMethod method : co.implClass.methods()) {
String name = method.name();
if (method.type().isPrimitive()) {
if (MethodType.GETTER == type && (name.startsWith("is") || name.startsWith("get"))) {
JStatement o = (JStatement) method.body().getContents().get(0);
String s = getterBody(o);
if (s.trim().equals(getterBody)) {
return method;
}
} else if (MethodType.SETTER == type && name.startsWith("set")) {
JStatement o = (JStatement) method.body().getContents().get(0);
String s = setterBody(o);
if (s.startsWith("this." + field.name() + " =")) {
return method;
}
}
}
}
throw new RuntimeException("Failed to find " + type + " for " + field.name() + ", disable XReplacePrimitives and report a bug");
}
代码示例来源:origin: org.metatype.sxc/sxc-core
if(!tailBlock.getContents().isEmpty()) {
preElementBlock.add(removeBraces(tailBlock));
内容来源于网络,如有侵权,请联系作者删除!