Package com.sun.codemodel

Examples of com.sun.codemodel.JMethod.body()


    // is it me? this==obj -> true
    final JConditional condMe = equalsMethod.body()._if(JExpr._this().eq(vObj));
    condMe._then()._return(JExpr.TRUE);

    // it's null? obj==null -> false
    final JConditional condNull = equalsMethod.body()._if(vObj.eq(JExpr._null()));
    condNull._then()._return(JExpr.FALSE);

    // paternity test (only add if equals in superclass isn't overridden)?
    // !super.equals(obj) -> false --> (super.equals(obj) == false)
    if (isSuperClass) {
View Full Code Here


    condNull._then()._return(JExpr.FALSE);

    // paternity test (only add if equals in superclass isn't overridden)?
    // !super.equals(obj) -> false --> (super.equals(obj) == false)
    if (isSuperClass) {
      final JConditional condSuper = equalsMethod.body()._if(JExpr._super().invoke("equals").arg(vObj).eq(JExpr.FALSE));
      condSuper._then()._return(JExpr.FALSE);
    }

    // suit the class? !(obj instanceof TypeB) -> false --> if ((obj instanceof TypeB) == false)
    final JConditional condInstance = equalsMethod.body()._if(vObj._instanceof(implClass).eq(JExpr.FALSE));
View Full Code Here

      final JConditional condSuper = equalsMethod.body()._if(JExpr._super().invoke("equals").arg(vObj).eq(JExpr.FALSE));
      condSuper._then()._return(JExpr.FALSE);
    }

    // suit the class? !(obj instanceof TypeB) -> false --> if ((obj instanceof TypeB) == false)
    final JConditional condInstance = equalsMethod.body()._if(vObj._instanceof(implClass).eq(JExpr.FALSE));
    condInstance._then()._return(JExpr.FALSE);

    // cast: TYPE other = (TYPE) obj;
    final JVar vOther = equalsMethod.body().decl(implClass, "other", JExpr.cast(implClass, vObj));
View Full Code Here

   
    final JMethod setProperty = namespaceFilterXMLReaderclass.method(JMod.PUBLIC, cc.implClass.owner().VOID, "setProperty");
    final JVar setPropertyName = setProperty.param(stringClass, "name");
    final JVar setPropertyValue = setProperty.param(Object.class, "value");
    setProperty._throws(SAXNotRecognizedException.class)._throws(SAXNotSupportedException.class);
    setProperty.body().add(xmlReader.invoke("setProperty").arg(setPropertyName).arg(setPropertyValue));
   
    generateHelperMethods(cc);
    generateMarshalMethods(cc);
    generateUnMarshalMethods(cc);
   
View Full Code Here

    // suit the class? !(obj instanceof TypeB) -> false --> if ((obj instanceof TypeB) == false)
    final JConditional condInstance = equalsMethod.body()._if(vObj._instanceof(implClass).eq(JExpr.FALSE));
    condInstance._then()._return(JExpr.FALSE);

    // cast: TYPE other = (TYPE) obj;
    final JVar vOther = equalsMethod.body().decl(implClass, "other", JExpr.cast(implClass, vObj));

    /*
     * check for each declared field distinguish between primitive types:
     *
     * <pre> if (field != other.field) { return false; } </pre>
View Full Code Here

    final JVar arg = generateAdd.param(JMod.FINAL, String.class, field.name());
    generateAdd.javadoc().addParam(arg).append("required parameter");
    returntype.arg(arg);

    generateAdd.javadoc().addReturn().append("<tt>true</tt> (as general contract of <tt>Collection.add</tt>). ");
    generateAdd.body().add(JExpr._this().invoke("getCoordinates").invoke("add").arg(returntype));
    generateAdd.body()._return(JExpr._this());

  }

  private void createArgFactoryMethod(final ClassOutlineImpl cc, final Collection<JFieldVar> coordinateCreateMethods) {
View Full Code Here

    for (final JFieldVar jFieldVar : fields) {
      if (jFieldVar.type().isPrimitive()) {
        // LOG.info("JConditional: " + jFieldVar.name() +
        // " is PRIMITIVE");
        condFieldCheck = equalsMethod.body()._if(JExpr.ref(jFieldVar.name()).ne(vOther.ref(jFieldVar.name())));
        condFieldCheck._then()._return(JExpr.FALSE);
      } else {
        // LOG.info("JConditional: " + jFieldVar.name() +
        // " is REFERENCE");
        condFieldCheck = equalsMethod.body()._if(JExpr.ref(jFieldVar.name()).eq(JExpr._null()));
View Full Code Here

    generateAdd.javadoc().addParam(arg).append("required parameter");
    returntype.arg(arg);

    generateAdd.javadoc().addReturn().append("<tt>true</tt> (as general contract of <tt>Collection.add</tt>). ");
    generateAdd.body().add(JExpr._this().invoke("getCoordinates").invoke("add").arg(returntype));
    generateAdd.body()._return(JExpr._this());

  }

  private void createArgFactoryMethod(final ClassOutlineImpl cc, final Collection<JFieldVar> coordinateCreateMethods) {
    final JMethod generateAdd = cc.implClass.method(JMod.PUBLIC, cc.implClass, "addToCoordinates");
View Full Code Here

        condFieldCheck = equalsMethod.body()._if(JExpr.ref(jFieldVar.name()).ne(vOther.ref(jFieldVar.name())));
        condFieldCheck._then()._return(JExpr.FALSE);
      } else {
        // LOG.info("JConditional: " + jFieldVar.name() +
        // " is REFERENCE");
        condFieldCheck = equalsMethod.body()._if(JExpr.ref(jFieldVar.name()).eq(JExpr._null()));
        condFieldCheck._then()._if(vOther.ref(jFieldVar.name()).ne(JExpr._null()))._then()._return(JExpr.FALSE);
        condFieldCheck._elseif(JExpr.ref(jFieldVar.name()).invoke("equals").arg(vOther.ref(jFieldVar.name())).eq(JExpr.FALSE))._then()
            ._return(JExpr.FALSE);
      }
    }
View Full Code Here

            ._return(JExpr.FALSE);
      }
    }

    // ir all works out, the objects are equal, return true
    equalsMethod.body()._return(JExpr.TRUE);

    // useful fields
    final JFieldRef vPrime = JExpr.ref("prime");
    final JFieldRef vResult = JExpr.ref("result");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.