[webbeans-commits] Webbeans SVN: r1965 - in ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd: model and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Fri Mar 13 07:08:13 EDT 2009


Author: nickarls
Date: 2009-03-13 07:08:13 -0400 (Fri, 13 Mar 2009)
New Revision: 1965

Added:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java
Removed:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ParameterFieldModel.java
Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/DataSetter.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java
Log:
Initial hierarchy/overloading support for XSD

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/DataSetter.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/DataSetter.java	2009-03-13 10:23:40 UTC (rev 1964)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/DataSetter.java	2009-03-13 11:08:13 UTC (rev 1965)
@@ -7,8 +7,9 @@
 import javax.lang.model.element.VariableElement;
 
 import org.jboss.webbeans.xsd.model.ClassModel;
+import org.jboss.webbeans.xsd.model.FieldModel;
 import org.jboss.webbeans.xsd.model.MethodModel;
-import org.jboss.webbeans.xsd.model.ParameterFieldModel;
+import org.jboss.webbeans.xsd.model.ParameterModel;
 
 public class DataSetter
 {
@@ -33,7 +34,7 @@
       }
       String name = element.getSimpleName().toString();
       String type = element.asType().toString();
-      classModel.addField(new ParameterFieldModel(name, type));
+      classModel.addField(new FieldModel(name, type));
    }
 
    public static void populateMethodModel(ClassModel classModel, Element element)
@@ -52,7 +53,7 @@
       {
          String paramName = parameterElement.getSimpleName().toString();
          String paramType = parameterElement.asType().toString();
-         ParameterFieldModel parameter = new ParameterFieldModel(paramName, paramType);
+         ParameterModel parameter = new ParameterModel(paramName, paramType);
          method.addParameter(parameter);
       }
       if ("<init>".equals(name))
@@ -65,10 +66,4 @@
       }
    }
 
-   public static String getSimpleNameFromQualifiedName(String qualifiedName)
-   {
-      int lastDot = qualifiedName.lastIndexOf(".");
-      return lastDot < 0 ? qualifiedName : qualifiedName.substring(lastDot);
-   }
-
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java	2009-03-13 10:23:40 UTC (rev 1964)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ClassModel.java	2009-03-13 11:08:13 UTC (rev 1965)
@@ -1,13 +1,15 @@
 package org.jboss.webbeans.xsd.model;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 public class ClassModel extends NamedModel
 {
    private ClassModel parent;
 
-   private List<ParameterFieldModel> fields = new ArrayList<ParameterFieldModel>();
+   private List<FieldModel> fields = new ArrayList<FieldModel>();
    private List<MethodModel> methods = new ArrayList<MethodModel>();
    private List<MethodModel> constructors = new ArrayList<MethodModel>();
 
@@ -15,7 +17,7 @@
    {
    }
 
-   public void addField(ParameterFieldModel fieldModel)
+   public void addField(FieldModel fieldModel)
    {
       fields.add(fieldModel);
    }
@@ -63,4 +65,44 @@
       return lastDot < 0 ? name : name.substring(lastDot + 1);
    }
 
+   public Set<MethodModel> getMergedConstructors()
+   {
+      return new HashSet<MethodModel>(constructors);
+   }
+
+   public List<FieldModel> getFields()
+   {
+      return fields;
+   }
+
+   public Set<FieldModel> getMergedFields()
+   {
+      Set<FieldModel> mergedFields = new HashSet<FieldModel>(fields);
+      ClassModel currentParent = parent;
+      while (currentParent != null)
+      {
+         mergedFields.addAll(currentParent.getFields());
+         currentParent = currentParent.getParent();
+      }
+      return mergedFields;
+   }
+
+   public List<MethodModel> getMethods()
+   {
+      return methods;
+   }
+
+   public Set<MethodModel> getMergedMethods()
+   {
+      Set<MethodModel> mergedMethods = new HashSet<MethodModel>(methods);
+      ClassModel currentParent = parent;
+      while (currentParent != null)
+      {
+         mergedMethods.addAll(currentParent.getMethods());
+         currentParent = currentParent.getParent();
+      }
+      return mergedMethods;
+
+   }
+
 }

Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java (from rev 1962, ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ParameterFieldModel.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java	2009-03-13 11:08:13 UTC (rev 1965)
@@ -0,0 +1,31 @@
+package org.jboss.webbeans.xsd.model;
+
+public class FieldModel extends NamedModel
+{
+   protected String type;
+
+   public FieldModel(String name, String type)
+   {
+      super(name);
+      this.type = type;
+   }
+
+   public String getType()
+   {
+      return type;
+   }
+
+   @Override
+   public boolean equals(Object other)
+   {
+      FieldModel otherModel = (FieldModel) other;
+      return name.equals(otherModel.getName()) && type.equals(otherModel.getType());
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return name.hashCode() + type.hashCode();
+   }
+
+}


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/FieldModel.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java	2009-03-13 10:23:40 UTC (rev 1964)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/MethodModel.java	2009-03-13 11:08:13 UTC (rev 1965)
@@ -6,7 +6,7 @@
 public class MethodModel extends NamedModel
 {
    private String returnType;
-   private List<ParameterFieldModel> parameters = new ArrayList<ParameterFieldModel>();
+   private List<ParameterModel> parameters = new ArrayList<ParameterModel>();
 
    public MethodModel(String name, String returnType)
    {
@@ -14,12 +14,12 @@
       this.returnType = returnType;
    }
 
-   public void addParameter(ParameterFieldModel parameter)
+   public void addParameter(ParameterModel parameter)
    {
       parameters.add(parameter);
    }
 
-   public List<ParameterFieldModel> getParameters()
+   public List<ParameterModel> getParameters()
    {
       return parameters;
    }
@@ -29,4 +29,17 @@
       return returnType;
    }
 
+   @Override
+   public boolean equals(Object other)
+   {
+      MethodModel otherModel = (MethodModel) other;
+      return name.equals(otherModel.getName()) && returnType.equals(otherModel.getReturnType()) && parameters.equals(otherModel.getParameters());
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return name.hashCode() + returnType.hashCode() + parameters.hashCode();
+   }
+
 }

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ParameterFieldModel.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ParameterFieldModel.java	2009-03-13 10:23:40 UTC (rev 1964)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ParameterFieldModel.java	2009-03-13 11:08:13 UTC (rev 1965)
@@ -1,18 +0,0 @@
-package org.jboss.webbeans.xsd.model;
-
-public class ParameterFieldModel extends NamedModel
-{
-   private String type;
-
-   public ParameterFieldModel(String name, String type)
-   {
-      super(name);
-      this.type = type;
-   }
-   
-   public String getType()
-   {
-      return type;
-   }
-
-}

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xsd/model/ParameterModel.java	2009-03-13 11:08:13 UTC (rev 1965)
@@ -0,0 +1,24 @@
+package org.jboss.webbeans.xsd.model;
+
+public class ParameterModel extends FieldModel
+{
+
+   public ParameterModel(String name, String type)
+   {
+      super(name, type);
+   }
+   
+   @Override
+   public boolean equals(Object other)
+   {
+      ParameterModel otherModel = (ParameterModel) other;
+      return type.equals(otherModel.getType());
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return type.hashCode();
+   }   
+
+}




More information about the weld-commits mailing list