当前位置: 首页>>代码示例>>Java>>正文


Java JOp类代码示例

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


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


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