fieldEquals = thisFieldRef.eq(otherFieldRef).cor( thisFieldRef.ne(JExpr._null()) .cand(thisFieldRef.invoke("equals").arg(otherFieldRef)));
private JExpression buildQNameCompare(QName name, JExpression localPart, JExpression namespaceUri) { JExpression localInv = JExpr.lit(name.getLocalPart()).eq(localPart); String ns = name.getNamespaceURI(); JExpression nsInv = JExpr.lit(ns).eq(namespaceUri); if (ns.equals("")) { nsInv = nsInv.cor(namespaceUri.eq(JExpr._null())); } JExpression qnameCompare = localInv.cand(nsInv); return qnameCompare; }
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()) ); } }
nsInv = nsInv.cand(xsiType.invoke("getNamespaceURI").ne(JExpr._null())); JExpression qnameCompare = localInv.cor(nsInv);
ifExpr = ifExpr.cor(holder.onOptionsItemSelectedItemId.eq(idsRefs.get(i)));
private JMethod createIsNullOrTrimmedEmpty(final JDefinedClass bean) { final JMethod method = bean.method(JMod.PRIVATE | JMod.STATIC, _boolean(), "_isNullOrTrimmedEmpty"); final JVar value = method.param(java.lang.String.class, "value"); method.body()._return(value.eq(JExpr._null()).cor(value.invoke("trim").invoke("isEmpty"))); return method; }
private JMethod getLocalClassName(EBeansHolder eBeansHolder, JDefinedClass helperClass, JCodeModel codeModel) { JClass stringClass = eBeansHolder.refClass(String.class); JMethod getLocalClassName = helperClass.method(PRIVATE | STATIC, stringClass, "getLocalClassName"); JClass contextClass = eBeansHolder.refClass("android.content.Context"); JVar contextParam = getLocalClassName.param(contextClass, "context"); JBlock body = getLocalClassName.body(); JVar packageName = body.decl(stringClass, "packageName", contextParam.invoke("getPackageName")); JVar className = body.decl(stringClass, "className", contextParam.invoke("getClass").invoke("getName")); JVar packageLen = body.decl(codeModel.INT, "packageLen", packageName.invoke("length")); JExpression condition = className.invoke("startsWith").arg(packageName).not() // .cor(className.invoke("length").lte(packageLen)) // .cor(className.invoke("charAt").arg(packageLen).ne(lit('.'))); body._if(condition)._then()._return(className); body._return(className.invoke("substring").arg(packageLen.plus(lit(1)))); return getLocalClassName; } }
JBlock then = body._if(reference.eq(JExpr._null()).cor(JExpr.invoke(reference, "getObject") .eq(JExpr._null())))._then(); then._return(JExpr._null());
private JMethod createSetFirstCharacterToUpperCase(final JDefinedClass bean) { final JMethod method = bean.method(JMod.PRIVATE | JMod.STATIC, _String(), "_setFirstCharacterToUpperCase"); final JVar value = method.param(java.lang.String.class, "value"); final JBlock body = method.body(); body._if(value.eq(JExpr._null()).cor(value.invoke("trim").invoke("isEmpty")))._then()._return(JExpr._null()); final JInvocation firstCharacter = value.invoke("substring").arg(JExpr.lit(0)).arg(JExpr.lit(1)).invoke( "toUpperCase"); final JInvocation restCharacters = value.invoke("substring").arg(JExpr.lit(1)).arg(value.invoke("length")); body._return(firstCharacter.plus(restCharacters)); return method; }
fieldEquals = thisFieldRef.eq(otherFieldRef).cor( thisFieldRef.ne(JExpr._null()) .cand(thisFieldRef.invoke("equals").arg(otherFieldRef)));
private void generateEquals() { equalsGeneric = cls().method(JMod.PUBLIC, cm.BOOLEAN, "equals"); equalsGeneric.param(cm.ref("java.lang.Object"), "other"); equalsGeneric.body().block()._if(_this().eq(ref("other"))) ._then() ._return(TRUE); equalsGeneric.body().block()._if( ref("other").eq(_null()) .cor((ref("other")._instanceof(cls()).not()))) ._then() ._return(FALSE); equalsGeneric.body().block()._return(_this().invoke("equals").arg(cast(cls(), ref("other")))); equalsTypeSpecific = cls().method(JMod.PUBLIC, cm.BOOLEAN, "equals"); equalsTypeSpecific.param(cls(), "other"); equalsTypeSpecific.body().block()._if(ref("other").eq(_null()))._then()._return(FALSE); JConditional test = equalsTypeSpecific.body().block()._if(_this().ref("value").eq(_null()).cand(ref("other").invoke("getValue").ne(_null()))); test._then().block()._return(FALSE); JConditional test2 = test._elseif(_this().ref("value").ne(_null()).cand(ref("other").invoke("getValue").eq(_null()))); test2._then().block()._return(FALSE); JConditional test3 = test2._elseif(_this().ref("value").eq(_null()).cand(ref("other").invoke("getValue").eq(_null()))); test3._then().block()._return(TRUE); test3._else().block()._return(_this().ref("value").invoke("equals").arg(ref("other").invoke("getValue"))); }