Package com.sun.codemodel

Examples of com.sun.codemodel.JType


    final JDefinedClass implClass = cc.implClass;
    // if no fields are present return
    if (implClass.fields().isEmpty()) {
      return;
    }
    final JType stringClass = cm._ref(String.class);
    replacedTypes = 0;
    replaceComplexTypes(implClass, "java.lang.Double", cm.DOUBLE);
    replaceComplexTypes(implClass, "double", cm.DOUBLE);
    replaceComplexTypes(implClass, "java.lang.Integer", cm.INT);
    replaceComplexTypes(implClass, "int", cm.INT);
View Full Code Here


          final JFieldVar currentField = implClass.fields().get(property.getName(false));

          // LOG.info("fieldType: " + currentField.name());
          // find the common type
          final JType currentFieldType = TypeUtil
              .getCommonBaseType(codeModel, listPossibleTypes((ClassOutlineImpl) classOutline, property));
          String currentFieldTypeName = currentFieldType.name().trim().toLowerCase();
          // if found field-type equals object, then there is no need, to document it
          if (currentFieldTypeName.equals("object")) {
            continue;
          }
          currentFieldTypeName = eliminateTypeSuffix(currentFieldTypeName);
View Full Code Here

    hashCodeMethod.body().assign(JExpr.ref("int result"), initializeResult);

    // if class contains double
    // long temp;
    JVar tempVariableForDoubleChecks = null;
    JType doubleClass = null;
    if (containsDouble == true) {
      tempVariableForDoubleChecks = hashCodeMethod.body().decl(implClass.owner().LONG, "temp");
      doubleClass = implClass.owner()._ref(Double.class);
    }

    JExpression tenaryCond;
    for (final JFieldVar jFieldVar : fields) {
      if (jFieldVar.type().isPrimitive()) {
        if (jFieldVar.type().fullName().equals("double")) {
          // temp = Double.doubleToLongBits(altitude);
          // result = prime * result + (int) (temp ^ (temp >>> 32));
          // LOG.info("implClass: " + implClass.name());
          // LOG.info("jFieldVar: " + jFieldVar.name());
          // LOG.info(" is " + jFieldVar.type().fullName());
          // LOG.info(" + " + tempVariableForDoubleChecks.name());
          // LOG.info(" + " + doubleClass.boxify().fullName());
          hashCodeMethod.body().assign(tempVariableForDoubleChecks, doubleClass.boxify().staticInvoke("doubleToLongBits").arg(jFieldVar));
          tenaryCond = JExpr.cast(implClass.owner().INT, tempVariableForDoubleChecks.xor(tempVariableForDoubleChecks.shrz(JExpr
              .direct("32"))));
        } else {
          // if field is primitive:
          // ==> result = prime * result + field;
View Full Code Here

    for (final ClassOutline classOutline : outline.getClasses()) {
      final ClassOutlineImpl cc = (ClassOutlineImpl) classOutline;
      final JDefinedClass implClass = classOutline.implClass;

      for (final FieldOutline fieldOutline : classOutline.getDeclaredFields()) {
        JType type = TypeUtil.getCommonBaseType(codeModel, Util.listPossibleTypes(cc, fieldOutline.getPropertyInfo()));
        if (((type.name().equals("BasicLink") || ((type.name().equals("Link")) && Util.upperFirst(fieldOutline.getPropertyInfo().getName(false)).equals("Icon"))))) {
          /*
           * special case for Icon. IconStyle uses protected BasicLink icon.
           *  subclasses.get(currentFieldName) will return, that
           *  possible subclasses for BasicLink are Icon and Link,
           *  hence createAndSetLink and createAndSetIcon methods
           *  are created. This isn't desired as IconStyle should
           *  define protected Icon icon.
           * 
           *  If it is possible to change the type of a variable
           *  at the CClassInfo-Level, this if block would be
           *  obsolete.
           */
          type = classIcon.unboxify();
         
        }
       
        final String currentFieldName = Util.eliminateTypeSuffix(type.name());
      // if (fieldOutline.getPropertyInfo().getName(false).equals("coordinates")) {
        // LOG.info("+1 "+ cc.implRef.name() + " " + currentFieldName + " " + fieldOutline.getPropertyInfo().getName(false));
        // }
        if (currentFieldName.equals("AbstractObject")) {
          // LOG.info("skip abstract object");
View Full Code Here

  }

  private void commonAddtoCase(final ClassOutlineImpl cc, final JFieldVar field, final boolean override, final CPropertyInfo propertyInfo) {
    // find the common type
    final JType type = TypeUtil.getCommonBaseType(codeModel, Util.listPossibleTypes(cc, propertyInfo));

    // creates the add method
    final JMethod generateAdd = cc.implClass.method(JMod.PUBLIC, cc.implClass, "addTo" + Util.upperFirst(field.name()));
    final JVar value = generateAdd.param(JMod.FINAL, type, field.name());
View Full Code Here

                //no default values for abstract classes
                typeAnno = null;
            }
        }
        if (typeAnno != null) {
            final JType type = typeAnno.getTypeClass();
            return new JAXBDefaultValueWriter(type);
        }
        return null;
    }
View Full Code Here

                List<? extends Property> propList = mapping.getWrapperStyleDrilldown();
                for (Property pro : propList) {
                    if (pro.elementName().getNamespaceURI().equals(item.getNamespaceURI())
                        && pro.elementName().getLocalPart().equals(item.getLocalPart())) {
                       
                        JType type = pro.type();
                        if (type instanceof JDefinedClass
                            && ((JDefinedClass)type).isAbstract()) {
                            //no default values for abstract classes
                            return null;
                        }
View Full Code Here

                    writer.write("();");
                    fillInFields(writer, indent, path, varName, jdc);
                }
            } else {
                boolean found = false;
                JType tp2 = tp.erasure();
                try {
                    Field f = tp2.getClass().getDeclaredField("_class");
                    f.setAccessible(true);
                    Class<?> cls = (Class)f.get(tp2);
                    if (List.class.isAssignableFrom(cls)) {
                        found = true;
View Full Code Here

                //no default values for abstract classes
                typeAnno = null;
            }
        }
        if (typeAnno != null) {
            final JType type = typeAnno.getTypeClass();
            return new JAXBDefaultValueWriter(type);
        }
        return null;
    }
View Full Code Here

                List<? extends Property> propList = mapping.getWrapperStyleDrilldown();
                for (Property pro : propList) {
                    if (pro.elementName().getNamespaceURI().equals(item.getNamespaceURI())
                        && pro.elementName().getLocalPart().equals(item.getLocalPart())) {

                        JType type = pro.type();
                        if (type instanceof JDefinedClass
                            && ((JDefinedClass)type).isAbstract()) {
                            //no default values for abstract classes
                            return null;
                        }
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JType

Copyright © 2018 www.massapicom. 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.