• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JOp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.codemodel.JOp的典型用法代码示例。如果您正苦于以下问题:Java JOp类的具体用法?Java JOp怎么用?Java JOp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JOp类属于com.sun.codemodel包,在下文中一共展示了JOp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addPublicSetMethod

import com.sun.codemodel.JOp; //导入依赖的package包/类
private JMethod addPublicSetMethod(JDefinedClass jclass, JMethod internalSetMethod) {
    JMethod method = jclass.method(PUBLIC, jclass.owner().VOID, SETTER_NAME);
    JVar nameParam = method.param(String.class, "name");
    JVar valueParam = method.param(Object.class, "value");
    JBlock body = method.body();
    JBlock notFound = body._if(JOp.not(invoke(internalSetMethod).arg(nameParam).arg(valueParam)))._then();

    // if we have additional properties, then put value.
    JMethod getAdditionalProperties = jclass.getMethod("getAdditionalProperties", new JType[] {});
    if (getAdditionalProperties != null) {
        JType additionalPropertiesType = ((JClass) (getAdditionalProperties.type())).getTypeParameters().get(1);
        notFound.add(invoke(getAdditionalProperties).invoke("put").arg(nameParam)
                .arg(cast(additionalPropertiesType, valueParam)));
    }
    // else throw exception.
    else {
        notFound._throw(illegalArgumentInvocation(jclass, nameParam));
    }

    return method;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:DynamicPropertiesRule.java


示例2: addPublicWithMethod

import com.sun.codemodel.JOp; //导入依赖的package包/类
private JMethod addPublicWithMethod(JDefinedClass jclass, JMethod internalSetMethod) {
    JMethod method = jclass.method(PUBLIC, jclass, BUILDER_NAME);
    JVar nameParam = method.param(String.class, "name");
    JVar valueParam = method.param(Object.class, "value");
    JBlock body = method.body();
    JBlock notFound = body._if(JOp.not(invoke(internalSetMethod).arg(nameParam).arg(valueParam)))._then();

    // if we have additional properties, then put value.
    JMethod getAdditionalProperties = jclass.getMethod("getAdditionalProperties", new JType[] {});
    if (getAdditionalProperties != null) {
        JType additionalPropertiesType = ((JClass) (getAdditionalProperties.type())).getTypeParameters().get(1);
        notFound.add(invoke(getAdditionalProperties).invoke("put").arg(nameParam)
                .arg(cast(additionalPropertiesType, valueParam)));
    }
    // else throw exception.
    else {
        notFound._throw(illegalArgumentInvocation(jclass, nameParam));
    }
    body._return(_this());

    return method;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DynamicPropertiesRule.java


示例3: caseAQmarkExpressionNoName

import com.sun.codemodel.JOp; //导入依赖的package包/类
@Override
public void caseAQmarkExpressionNoName(AQmarkExpressionNoName node) {
    ExpressionAdapter eaCond = new ExpressionAdapter(new JExprParent(), context);
    node.getCond().apply(eaCond);
    ExpressionAdapter eaTrue = new ExpressionAdapter(new JExprParent(), context);
    node.getTrue().apply(eaTrue);
    ExpressionAdapter eaFalse = new ExpressionAdapter(new JExprParent(), context);
    node.getFalse().apply(eaFalse);
    expr = JOp.cond(eaCond.expr, eaTrue.expr, eaFalse.expr);
}
 
开发者ID:kompics,项目名称:kola,代码行数:11,代码来源:ExpressionAdapter.java


示例4: onBoolean

import com.sun.codemodel.JOp; //导入依赖的package包/类
@Override
public void onBoolean(HashCodeArguments arguments, JBlock block,
		boolean isAlwaysSet) {
	ifHasSetValueAssignPlusValueHashCode(arguments, block,
			JOp.cond(arguments.value(), JExpr.lit(1231), JExpr.lit(1237)),
			isAlwaysSet, true);
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:8,代码来源:HashCodeCodeGenerationImplementor.java


示例5: onDouble

import com.sun.codemodel.JOp; //导入依赖的package包/类
@Override
public void onDouble(HashCodeArguments arguments, JBlock block,
		boolean isAlwaysSet) {
	// long bits = doubleToLongBits(value);
	final JVar bits = block.decl(JMod.FINAL, getCodeModel().LONG, arguments
			.value().name() + "Bits", getCodeModel().ref(Double.class)
			.staticInvoke("doubleToLongBits").arg(arguments.value()));
	// return (int)(bits ^ (bits >>> 32));
	final JExpression valueHashCode = JExpr.cast(getCodeModel().INT,
			JOp.xor(bits, JOp.shrz(bits, JExpr.lit(32))));
	ifHasSetValueAssignPlusValueHashCode(arguments, block, valueHashCode,
			isAlwaysSet, true);
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:14,代码来源:HashCodeCodeGenerationImplementor.java


示例6: onDouble

import com.sun.codemodel.JOp; //导入依赖的package包/类
@Override
public void onDouble(EqualsArguments arguments, JBlock block,
		boolean isAlwaysSet) {
	final JClass Double$class = getCodeModel().ref(Double.class);
	final JExpression leftValueLongBits = Double$class.staticInvoke(
			"doubleToLongBits").arg(arguments.leftValue());
	final JExpression rightValueLongBits = Double$class.staticInvoke(
			"doubleToLongBits").arg(arguments.rightValue());
	returnFalseIfNotEqualsCondition(arguments, block, isAlwaysSet,
			JOp.ne(leftValueLongBits, rightValueLongBits));
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:12,代码来源:EqualsCodeGenerationImplementor.java


示例7: onFloat

import com.sun.codemodel.JOp; //导入依赖的package包/类
@Override
public void onFloat(EqualsArguments arguments, JBlock block,
		boolean isAlwaysSet) {
	final JClass Float$class = getCodeModel().ref(Float.class);
	final JExpression leftValueLongBits = Float$class.staticInvoke(
			"floatToIntBits").arg(arguments.leftValue());
	final JExpression rightValueLongBits = Float$class.staticInvoke(
			"floatToIntBits").arg(arguments.rightValue());
	returnFalseIfNotEqualsCondition(arguments, block, isAlwaysSet,
			JOp.ne(leftValueLongBits, rightValueLongBits));
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:12,代码来源:EqualsCodeGenerationImplementor.java


示例8: unwrapCondifiton

import com.sun.codemodel.JOp; //导入依赖的package包/类
@Override
public JExpression unwrapCondifiton(JExpression source) {
	
	final JType type = getTypeRef().getTarget().toType(outline.parent(),
			Aspect.EXPOSED);
	return JOp._instanceof(source, type);
}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:8,代码来源:SingleWrappingElementField.java


示例9: unwrapCondifiton

import com.sun.codemodel.JOp; //导入依赖的package包/类
@Override
public JExpression unwrapCondifiton(JExpression source) {

	final CReferencePropertyInfo core = (CReferencePropertyInfo) this.core;

	JExpression predicate = null;
	if (core.getElements().isEmpty()) {
		predicate = null;
	} else {
		for (CElement element : core.getElements()) {
			if (element instanceof CElementInfo) {
				CElementInfo elementinfo = (CElementInfo) element;

				final SingleWrappingReferenceElementInfoField field = new SingleWrappingReferenceElementInfoField(
						outline, prop, core, elementinfo);
				final JExpression condition = field
						.unwrapCondifiton(source);
				predicate = (predicate == null) ? condition : JOp.cor(
						predicate, condition);
			} else {
				// TODO Other cases currently not supported.
			}
		}
	}

	final JExpression isElement = codeModel.ref(JAXBContextUtils.class)
			.staticInvoke("isElement").arg(contextPath).arg(source);
	return predicate == null ? isElement : JOp.cand(JOp.not(predicate),
			isElement);
}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:31,代码来源:SingleWrappingReferenceObjectField.java


示例10: visit

import com.sun.codemodel.JOp; //导入依赖的package包/类
@Override
public JExpression visit(Expression.BinaryOp op,
			 JExpression left, JExpression right)
{
	if (op.op.javaMethod == "cmp") {
		final JExpression cmp_res =
			left.invoke("compareTo").arg(right);

		final JExpression cond;
		switch(op.op){
		case EQ: cond = cmp_res.eq(JExpr.lit(0)); break;
		case NE: cond = cmp_res.ne(JExpr.lit(0)); break;
		case LT: cond = cmp_res.lt(JExpr.lit(0)); break;
		case GT: cond = cmp_res.gt(JExpr.lit(0)); break;
		case LE: cond = cmp_res.lte(JExpr.lit(0)); break;
		case GE: cond = cmp_res.gte(JExpr.lit(0)); break;
		default: throw new RuntimeException();
		}

		return JOp.cond(cond,
				TypeInt_t.staticRef("True"),
				TypeInt_t.staticRef("False"));
	} else {
		return left.invoke(op.op.javaMethod).arg(right);
	}

}
 
开发者ID:BrainTech,项目名称:jsignalml,代码行数:28,代码来源:JavaExprGen.java


示例11: visit

import com.sun.codemodel.JOp; //导入依赖的package包/类
@Override
public JExpression visit(Expression.BinaryOp op,
			 JExpression left, JExpression right)
{
	if (op.left.type instanceof TypeInt &&
	    op.right.type instanceof TypeInt) {
		JExpression expr = binaryOp_int_int(op, left, right);
		if (expr != null)
			return expr;
	}

	if (op.op.javaMethod == "cmp") {
		final JExpression cmp_res =
			left.invoke("compareTo").arg(right);

		final JExpression cond;
		switch(op.op){
		case EQ: cond = cmp_res.eq(JExpr.lit(0)); break;
		case NE: cond = cmp_res.ne(JExpr.lit(0)); break;
		case LT: cond = cmp_res.lt(JExpr.lit(0)); break;
		case GT: cond = cmp_res.gt(JExpr.lit(0)); break;
		case LE: cond = cmp_res.lte(JExpr.lit(0)); break;
		case GE: cond = cmp_res.gte(JExpr.lit(0)); break;
		default: throw new RuntimeException();
		}

		JClass int_t = this.model.ref(TypeInt.class);
		return JOp.cond(cond, int_t.staticRef("True"),
				      int_t.staticRef("False"));
	} else {
		return left.invoke(op.op.javaMethod).arg(right);
	}

}
 
开发者ID:BrainTech,项目名称:jsignalml,代码行数:35,代码来源:JavaPrimitiveGen.java


示例12: TreeVarGenerator

import com.sun.codemodel.JOp; //导入依赖的package包/类
public TreeVarGenerator(final JBlock body, final String fieldName) {
	this.fieldPathVar = body.decl(JMod.FINAL,
			PartialCopyGenerator.this.pluginContext.codeModel._ref(PropertyTree.class),
			fieldName + "PropertyTree",
			JOp.cond(PartialCopyGenerator.this.propertyTreeParam.eq(JExpr._null()), JExpr._null(),PartialCopyGenerator.this.propertyTreeParam.invoke("get").arg(JExpr.lit(fieldName)))
	);
}
 
开发者ID:mklemm,项目名称:jaxb2-rich-contract-plugin,代码行数:8,代码来源:PartialCopyGenerator.java


示例13: getIncludeCondition

import com.sun.codemodel.JOp; //导入依赖的package包/类
private JExpression getIncludeCondition(final JVar fieldPathVar) {
	return JOp.cond(
			PartialCopyGenerator.this.propertyTreeUseParam.eq(PartialCopyGenerator.this.pluginContext.includeConst),
			fieldPathVar.ne(JExpr._null()),
			fieldPathVar.eq(JExpr._null()).cor(fieldPathVar.invoke("isLeaf").not())
	);
}
 
开发者ID:mklemm,项目名称:jaxb2-rich-contract-plugin,代码行数:8,代码来源:PartialCopyGenerator.java


示例14: generateMetaFields

import com.sun.codemodel.JOp; //导入依赖的package包/类
public void generateMetaFields() {
	if(this.classOutline.getSuperClass() != null) {
		this.selectorClass._extends(this.selectorGenerator.getInfoClass(this.classOutline.getSuperClass().implClass).selectorClass.narrow(this.rootTypeParam).narrow(this.parentTypeParam));
	}
	for (final FieldOutline fieldOutline : this.classOutline.getDeclaredFields()) {
		final JFieldVar definedField = PluginUtil.getDeclaredField(fieldOutline);
		if (definedField != null) {
			final JType elementType = PluginUtil.getElementType(fieldOutline);
			if (elementType.isReference()) {
				final ClassOutline modelClass = this.selectorGenerator.getPluginContext().getClassOutline(elementType);
				final JClass returnType;
				if (modelClass != null) {
					returnType = this.selectorGenerator.getInfoClass(modelClass.implClass).selectorClass.narrow(this.rootTypeParam).narrow(this.selectorClass.narrow(this.rootTypeParam).narrow(this.parentTypeParam));
				} else {
					returnType = this.selectorGenerator.getPluginContext().codeModel.ref(this.selectorGenerator.selectorBaseClass).narrow(this.rootTypeParam).narrow(this.selectorClass.narrow(this.rootTypeParam).narrow(this.parentTypeParam));
				}
				final JFieldVar includeField = this.selectorClass.field(JMod.PRIVATE, returnType, definedField.name(), JExpr._null());
				final JFieldRef fieldRef = JExpr._this().ref(includeField);
				final JMethod includeMethod = this.selectorClass.method(JMod.PUBLIC, returnType, definedField.name());
				if(this.selectorGenerator.selectorParamName != null) {
					final JVar includeParam = includeMethod.param(JMod.FINAL, this.selectorGenerator.getSelectorParamType(this.classOutline.implClass, elementType), this.selectorGenerator.selectorParamName);
					includeMethod.body()._return(JOp.cond(fieldRef.eq(JExpr._null()), fieldRef.assign(JExpr._new(returnType).arg(JExpr._this().ref("_root")).arg(JExpr._this()).arg(JExpr.lit(definedField.name())).arg(includeParam)), fieldRef));
				} else {
					includeMethod.body()._return(JOp.cond(fieldRef.eq(JExpr._null()), fieldRef.assign(JExpr._new(returnType).arg(JExpr._this().ref("_root")).arg(JExpr._this()).arg(JExpr.lit(definedField.name()))), fieldRef));
				}

				this.buildChildrenMethod.body()._if(fieldRef.ne(JExpr._null()))._then().add(this.productMapVar.invoke("put").arg(JExpr.lit(definedField.name())).arg(fieldRef.invoke("init")));
			}
		}
	}
	this.buildChildrenMethod.body()._return(this.productMapVar);
}
 
开发者ID:mklemm,项目名称:jaxb2-rich-contract-plugin,代码行数:33,代码来源:SelectorGenerator.java


示例15: generateAccessors

import com.sun.codemodel.JOp; //导入依赖的package包/类
private void generateAccessors(final FieldOutline fieldOutline, final String propertyName, final JType returnType, final JDefinedClass declaringClass, final F1<JExpression, JVar> getMaker, final F3<JExpression, JBlock, JVar, JVar> setMaker) {
	final String constantName = getConstantName(fieldOutline);
	final JMethod getMethod = declaringClass.method(JMod.PUBLIC, returnType, "get");
	getMethod.annotate(Override.class);
	final JVar instanceParam = getMethod.param(JMod.FINAL, fieldOutline.parent().implClass, "_instance_");
	getMethod.body()._return(JOp.cond(instanceParam.eq(JExpr._null()), JExpr._null(), getMaker.f(instanceParam)));
	final JMethod setMethod = declaringClass.method(JMod.PUBLIC, void.class, "set");
	setMethod.annotate(Override.class);
	final JVar setInstanceParam = setMethod.param(JMod.FINAL, fieldOutline.parent().implClass, "_instance_");
	final JVar valueParam = setMethod.param(JMod.FINAL, returnType, "_value_");
	if (constantName == null) {
		final JConditional ifNotNull = setMethod.body()._if(setInstanceParam.ne(JExpr._null()));
		setMaker.f(ifNotNull._then(), setInstanceParam, valueParam);
	}
}
 
开发者ID:mklemm,项目名称:jaxb2-rich-contract-plugin,代码行数:16,代码来源:MetaPlugin.java


示例16: updateArrayOfGetters

import com.sun.codemodel.JOp; //导入依赖的package包/类
/**
 * Update getters to use Java List. For example:
 * ArrayOfInvoices getInvoices() -> List<Invoice> getInvoices()
 */
private void updateArrayOfGetters(ClassOutline co, JCodeModel model) {
  JDefinedClass implClass = co.implClass;

  List<JMethod> removedMethods = new ArrayList<>();
  Iterator<JMethod> iter = implClass.methods().iterator();
  while (iter.hasNext()) {
    JMethod method = iter.next();
    if (method.type().name().startsWith("ArrayOf")) {
      removedMethods.add(method);
      iter.remove();
    }
  }

  for (JMethod removed : removedMethods) {
    // Parse the old code to get the variable name
    StringWriter oldWriter = new StringWriter();
    removed.body().state(new JFormatter(oldWriter));
    String oldBody = oldWriter.toString();
    String varName = oldBody.substring(oldBody.indexOf("return ") + "return ".length(), oldBody.indexOf(";"));

    // Build the new method
    JClass newReturnType = (JClass) ((JDefinedClass) removed.type()).fields().values().iterator().next().type();
    JMethod newMethod = implClass.method(removed.mods().getValue(), newReturnType, removed.name());
    JFieldVar field = implClass.fields().get(varName);          
    JClass typeParameter = newReturnType.getTypeParameters().get(0);
    String fieldName = model._getClass(field.type().fullName()).fields().keySet().iterator().next();

    newMethod.body()._return(
        JOp.cond(field.eq(JExpr._null()),
            JExpr._new(model.ref("java.util.ArrayList").narrow(typeParameter)),
            field.invoke("get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1))));
  }    
}
 
开发者ID:benmccann,项目名称:xero-java-client,代码行数:38,代码来源:PluginImpl.java


示例17: createFieldValuesUpdate

import com.sun.codemodel.JOp; //导入依赖的package包/类
/**
    * JavaType -> Item
    * 
    * @param getter
    * @param type
    *            (return-)type of {@code getter}
    * @param f
    *            corresponds to (field of) {@code getter}
    * @return an {@link JExpression} that evaluates to a
    *         {@link FieldValuesUpdate} containing the return value of
    *         {@code getter}. If the field type is not supported, returns
    *         {@code null}.
    * @throws JClassAlreadyExistsException
    */
   private JExpression createFieldValuesUpdate(JMethod getter, PodioType type, ApplicationField f)
    throws JClassAlreadyExistsException {
switch (type) {
case TEXT:
    return JExpr
	    ._new(jCodeModel.ref(FieldValuesUpdate.class))
	    .arg(f.getExternalId())
	    .arg("value")
	    .arg(JOp.cond(JExpr.invoke(getter).invoke("length").eq(JExpr.lit(0)), JExpr.lit(" "),
		    JExpr.invoke(getter)));
case NUMBER:
case DURATION:
case PROGRESS:
    return JExpr._new(jCodeModel.ref(FieldValuesUpdate.class)).arg(f.getExternalId()).arg("value")
	    .arg(JExpr.invoke(getter));
    // all PodioField implementations are treated equally here:
case DATE:
case MONEY:
    return JExpr.invoke(getter).invoke("getFieldValuesUpdate").arg(JExpr.lit(f.getExternalId()));
case CATEGORY_SINGLE:
    // new FieldValuesUpdate("status", "value",
    // customer.getPowerStatus().getId())
    return JExpr._new(jCodeModel.ref(FieldValuesUpdate.class)).arg(f.getExternalId()).arg("value")
	    .arg(JExpr.invoke(getter).invoke("getPodioId"));
case CATEGORY_MULTI:
    return JExpr.invoke("getFielddValuesUpdateFromMultiCategory").arg(JExpr.invoke(getter))
	    .arg(f.getExternalId());
case CONTACT:
    return JExpr.invoke("getFieldValuesUpdateFromContacts").arg(JExpr.invoke(getter)).arg(f.getExternalId());
case EMBED:
    return JExpr.invoke("getFieldValuesUpdateFromEmbeds").arg(JExpr.invoke(getter)).arg(f.getExternalId());
case APP:
    return JExpr.invoke("getFieldValuesUpdateFromApp").arg(JExpr.invoke(getter)).arg(f.getExternalId());

default:
    return null;
}
   }
 
开发者ID:daniel-sc,项目名称:podio-java-codegen,代码行数:53,代码来源:AppGenerator.java


示例18: generateEvalBody

import com.sun.codemodel.JOp; //导入依赖的package包/类
protected HoldingContainer generateEvalBody(ClassGenerator<?> g, CompleteType resolvedOutput, HoldingContainer[] inputVariables, String body, JVar[] workspaceJVars) {

    g.getEvalBlock().directStatement(String.format("//---- start of eval portion of %s function. ----//", registeredNames[0]));

    JBlock sub = new JBlock(true, true);
    JBlock topSub = sub;
    HoldingContainer out = null;


    // add outside null handling if it is defined.
    if (nullHandling == NullHandling.NULL_IF_NULL) {
      JExpression e = null;
      for (HoldingContainer v : inputVariables) {
        final JExpression isNullExpr;
        if (v.isReader()) {
          isNullExpr = JOp.cond(v.getHolder().invoke("isSet"), JExpr.lit(1), JExpr.lit(0));
        } else {
          isNullExpr = v.getIsSet();
        }
        if (e == null) {
          e = isNullExpr;
        } else {
          e = e.mul(isNullExpr);
        }
      }

      if (e != null) {
        // if at least one expression must be checked, set up the conditional.
        out = g.declare(resolvedOutput);
        e = e.eq(JExpr.lit(0));
        JConditional jc = sub._if(e);
        jc._then().assign(out.getIsSet(), JExpr.lit(0));
        sub = jc._else();
      }
    }

    if (out == null) {
      out = g.declare(resolvedOutput);
    }

    // add the subblock after the out declaration.
    g.getEvalBlock().add(topSub);


    JVar internalOutput = sub.decl(JMod.FINAL, resolvedOutput.getHolderType(g.getModel()), getReturnName(), JExpr._new(resolvedOutput.getHolderType(g.getModel())));
    addProtectedBlock(g, sub, body, inputVariables, workspaceJVars, false);

    if (sub != topSub || inputVariables.length == 0) {
      sub.assign(internalOutput.ref("isSet"), JExpr.lit(1));// Assign null if NULL_IF_NULL mode
    }
    sub.assign(out.getHolder(), internalOutput);

    g.getEvalBlock().directStatement(String.format("//---- end of eval portion of %s function. ----//", registeredNames[0]));

    return out;
  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:57,代码来源:SimpleFunctionHolder.java


示例19: generateEvalBody

import com.sun.codemodel.JOp; //导入依赖的package包/类
protected HoldingContainer generateEvalBody(ClassGenerator<?> g, HoldingContainer[] inputVariables, String body,
                                            JVar[] workspaceJVars, FieldReference ref) {

  g.getEvalBlock().directStatement(String.format("//---- start of eval portion of %s function. ----//", getRegisteredNames()[0]));

  JBlock sub = new JBlock(true, true);
  JBlock topSub = sub;
  HoldingContainer out = null;
  MajorType returnValueType = getReturnType();

  // add outside null handling if it is defined.
  if (getNullHandling() == NullHandling.NULL_IF_NULL) {
    JExpression e = null;
    for (HoldingContainer v : inputVariables) {
      if (v.isOptional()) {
        JExpression isNullExpr;
        if (v.isReader()) {
         isNullExpr = JOp.cond(v.getHolder().invoke("isSet"), JExpr.lit(1), JExpr.lit(0));
        } else {
          isNullExpr = v.getIsSet();
        }
        if (e == null) {
          e = isNullExpr;
        } else {
          e = e.mul(isNullExpr);
        }
      }
    }

    if (e != null) {
      // if at least one expression must be checked, set up the conditional.
      returnValueType = getReturnType().toBuilder().setMode(DataMode.OPTIONAL).build();
      out = g.declare(returnValueType);
      e = e.eq(JExpr.lit(0));
      JConditional jc = sub._if(e);
      jc._then().assign(out.getIsSet(), JExpr.lit(0));
      sub = jc._else();
    }
  }

  if (out == null) {
    out = g.declare(returnValueType);
  }

  // add the subblock after the out declaration.
  g.getEvalBlock().add(topSub);


  JVar internalOutput = sub.decl(JMod.FINAL, g.getHolderType(returnValueType), getReturnValue().getName(), JExpr._new(g.getHolderType(returnValueType)));
  addProtectedBlock(g, sub, body, inputVariables, workspaceJVars, false);
  if (sub != topSub) {
    sub.assign(internalOutput.ref("isSet"),JExpr.lit(1));// Assign null if NULL_IF_NULL mode
  }
  sub.assign(out.getHolder(), internalOutput);
  if (sub != topSub) {
    sub.assign(internalOutput.ref("isSet"),JExpr.lit(1));// Assign null if NULL_IF_NULL mode
  }

  g.getEvalBlock().directStatement(String.format("//---- end of eval portion of %s function. ----//", getRegisteredNames()[0]));

  return out;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:63,代码来源:DrillSimpleFuncHolder.java


示例20: _instanceof

import com.sun.codemodel.JOp; //导入依赖的package包/类
public JExpression _instanceof(JType type) {
	return JOp.cand(leftValue()._instanceof(type), rightValue()
			._instanceof(type));
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:5,代码来源:EqualsArguments.java



注:本文中的com.sun.codemodel.JOp类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WebSocketListener类代码示例发布时间:2022-05-21
下一篇:
Java MergingLexerAdapter类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap