本文整理汇总了Java中com.sun.codemodel.JConditional._elseif方法的典型用法代码示例。如果您正苦于以下问题:Java JConditional._elseif方法的具体用法?Java JConditional._elseif怎么用?Java JConditional._elseif使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.codemodel.JConditional
的用法示例。
在下文中一共展示了JConditional._elseif方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addInternalGetMethodJava6
import com.sun.codemodel.JConditional; //导入方法依赖的package包/类
private JMethod addInternalGetMethodJava6(JDefinedClass jclass, JsonNode propertiesNode) {
JMethod method = jclass.method(PROTECTED, jclass.owner()._ref(Object.class), DEFINED_GETTER_NAME);
JVar nameParam = method.param(String.class, "name");
JVar notFoundParam = method.param(jclass.owner()._ref(Object.class), "notFoundValue");
JBlock body = method.body();
JConditional propertyConditional = null;
if (propertiesNode != null) {
for (Iterator<Map.Entry<String, JsonNode>> properties = propertiesNode.fields(); properties.hasNext();) {
Map.Entry<String, JsonNode> property = properties.next();
String propertyName = property.getKey();
JsonNode node = property.getValue();
String fieldName = ruleFactory.getNameHelper().getPropertyName(propertyName, node);
JType propertyType = jclass.fields().get(fieldName).type();
JExpression condition = lit(propertyName).invoke("equals").arg(nameParam);
if (propertyConditional == null) {
propertyConditional = body._if(condition);
} else {
propertyConditional = propertyConditional._elseif(condition);
}
JMethod propertyGetter = jclass.getMethod(getGetterName(propertyName, propertyType, node), new JType[] {});
propertyConditional._then()._return(invoke(propertyGetter));
}
}
JClass extendsType = jclass._extends();
JBlock lastBlock = propertyConditional == null ? body : propertyConditional._else();
if (extendsType != null && extendsType instanceof JDefinedClass) {
JDefinedClass parentClass = (JDefinedClass) extendsType;
JMethod parentMethod = parentClass.getMethod(DEFINED_GETTER_NAME,
new JType[] { parentClass.owner()._ref(String.class), parentClass.owner()._ref(Object.class) });
lastBlock._return(_super().invoke(parentMethod).arg(nameParam).arg(notFoundParam));
} else {
lastBlock._return(notFoundParam);
}
return method;
}
示例2: addInternalSetMethodJava6
import com.sun.codemodel.JConditional; //导入方法依赖的package包/类
private JMethod addInternalSetMethodJava6(JDefinedClass jclass, JsonNode propertiesNode) {
JMethod method = jclass.method(PROTECTED, jclass.owner().BOOLEAN, DEFINED_SETTER_NAME);
JVar nameParam = method.param(String.class, "name");
JVar valueParam = method.param(Object.class, "value");
JBlock body = method.body();
JConditional propertyConditional = null;
if (propertiesNode != null) {
for (Iterator<Map.Entry<String, JsonNode>> properties = propertiesNode.fields(); properties.hasNext();) {
Map.Entry<String, JsonNode> property = properties.next();
String propertyName = property.getKey();
JsonNode node = property.getValue();
String fieldName = ruleFactory.getNameHelper().getPropertyName(propertyName, node);
JType propertyType = jclass.fields().get(fieldName).type();
JExpression condition = lit(propertyName).invoke("equals").arg(nameParam);
propertyConditional = propertyConditional == null ? propertyConditional = body._if(condition)
: propertyConditional._elseif(condition);
JBlock callSite = propertyConditional._then();
addSetProperty(jclass, callSite, propertyName, propertyType, valueParam, node);
callSite._return(TRUE);
}
}
JClass extendsType = jclass._extends();
JBlock lastBlock = propertyConditional == null ? body : propertyConditional._else();
if (extendsType != null && extendsType instanceof JDefinedClass) {
JDefinedClass parentClass = (JDefinedClass) extendsType;
JMethod parentMethod = parentClass.getMethod(DEFINED_SETTER_NAME,
new JType[] { parentClass.owner()._ref(String.class), parentClass.owner()._ref(Object.class) });
lastBlock._return(_super().invoke(parentMethod).arg(nameParam).arg(valueParam));
} else {
lastBlock._return(FALSE);
}
return method;
}