Package org.cruxframework.crux.core.utils.JClassUtils

Examples of org.cruxframework.crux.core.utils.JClassUtils.PropertyInfo


      PropertyInfo[] fromPropertiesInfo = JClassUtils.extractBeanPropertiesInfo(fromType);
      PropertyInfo[] toPropertiesInfo = JClassUtils.extractBeanPropertiesInfo(toType);

      for (PropertyInfo fromPropertyInfo : fromPropertiesInfo)
      {
        PropertyInfo toPropertyInfo = getEquivalentPropertyInfo(fromPropertyInfo, toPropertiesInfo);
        if (toPropertyInfo != null)
        {
          if (JClassUtils.isSimpleType(fromPropertyInfo.getType()))
          {
            if (fromPropertyInfo.getType().equals(toPropertyInfo.getType()))
            {
              srcWriter.println(toVariable+"."+toPropertyInfo.getWriteMethod().getName()+"("+fromVariable+"."+fromPropertyInfo.getReadMethod().getName()+"());");
            }
            else
            {
              throw new CruxGeneratorException("Can not create a BeanCopier. Incopatibles type for property ["+fromPropertyInfo.getName()+"].");
            }
          }
          else
          {
            JClassType fromPropClass = fromPropertyInfo.getType().isClassOrInterface();
            JClassType toPropClass = toPropertyInfo.getType().isClassOrInterface();
            if (fromPropClass.isAssignableTo(toPropClass))
            {
              srcWriter.println(toVariable+"."+toPropertyInfo.getWriteMethod().getName()+"("+fromVariable+"."+fromPropertyInfo.getReadMethod().getName()+"());");
            }
            else
            {
              srcWriter.println("if ("+fromVariable+"."+fromPropertyInfo.getReadMethod().getName()+"() != null){");
              srcWriter.println(toVariable+"."+toPropertyInfo.getWriteMethod().getName()+"(GWT.create("+toPropClass.getQualifiedSourceName()+".class));");
              generateCopyBeanCode(srcWriter, fromVariable+"."+fromPropertyInfo.getReadMethod().getName()+"()",
                  toVariable+"."+toPropertyInfo.getReadMethod().getName()+"()",
                  fromPropertyInfo.getType().isClassOrInterface(),
                  toPropertyInfo.getType().isClassOrInterface());
              srcWriter.println("}else{");
              srcWriter.println(toVariable+"."+toPropertyInfo.getWriteMethod().getName()+"(null);");
              srcWriter.println("}");
            }
          }
        }
      }
View Full Code Here

TOP

Related Classes of org.cruxframework.crux.core.utils.JClassUtils.PropertyInfo

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.