[jboss-svn-commits] JBL Code SVN: r31233 - labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jan 26 16:13:42 EST 2010
Author: baunax
Date: 2010-01-26 16:13:42 -0500 (Tue, 26 Jan 2010)
New Revision: 31233
Modified:
labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/MethodInfo.java
Log:
added parametric return type
Modified: labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/MethodInfo.java
===================================================================
--- labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/MethodInfo.java 2010-01-26 19:55:44 UTC (rev 31232)
+++ labs/jbossrules/branches/guvnor_expressionEditor2_baunax_esteban/drools-compiler/src/main/java/org/drools/guvnor/client/modeldriven/MethodInfo.java 2010-01-26 21:13:42 UTC (rev 31233)
@@ -8,88 +8,112 @@
/**
*
* @author Toni Rikkola
- *
+ *
*/
-public class MethodInfo
- implements
- PortableObject {
+public class MethodInfo implements PortableObject {
- private String name;
- private List<String> params;
- private String returnType;
+ private String name;
+ private List<String> params;
+ private String returnClassType;
+ private String parametricReturnType;
- public MethodInfo() {
+ public MethodInfo() {
+ }
- }
+ /**
+ *
+ * @param name
+ * method name
+ * @param params
+ * method params list
+ * @param returnType
+ * method's return type
+ */
+ public MethodInfo(String name, List<String> params, Class<?> returnType, String parametricReturnType) {
+ this.name = name;
+ this.params = params;
+ this.returnClassType = returnType.getName();
+ this.parametricReturnType = parametricReturnType;
+ }
- /**
- *
- * @param name method name
- * @param params method params list
- * @param returnType method's return type
- */
- public MethodInfo(String name,
- List<String> params,
- Class<?> returnType) {
- this.name = name;
- this.params = params;
- this.returnType = returnType.getName();
- }
+ public String getNameWithParameters() {
+ if (params.isEmpty()) {
+ return name + "()";
+ }
+ StringBuilder p = new StringBuilder();
+
+ for (Iterator<String> iterator = params.iterator(); iterator.hasNext();) {
+ p.append(", ").append(iterator.next());
+ }
- public String getNameWithParameters() {
+ return name + "(" + p.substring(2) + ")";
+ }
- String n = name + "(";
+ public String getName() {
+ return name;
+ }
- for ( Iterator<String> iterator = params.iterator(); iterator.hasNext(); ) {
- n += iterator.next();
+ public List<String> getParams() {
+ return params;
+ }
- if ( iterator.hasNext() ) {
- n += ",";
- }
- }
+ public String getReturnClassType() {
+ return returnClassType;
+ }
- n += ")";
+ public String getParametricReturnType() {
+ return parametricReturnType;
+ }
- return n;
- }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime
+ * result
+ + ((parametricReturnType == null) ? 0 : parametricReturnType
+ .hashCode());
+ result = prime * result + ((params == null) ? 0 : params.hashCode());
+ result = prime * result
+ + ((returnClassType == null) ? 0 : returnClassType.hashCode());
+ return result;
+ }
- public String getName() {
- return name;
- }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ MethodInfo other = (MethodInfo) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (parametricReturnType == null) {
+ if (other.parametricReturnType != null)
+ return false;
+ } else if (!parametricReturnType.equals(other.parametricReturnType))
+ return false;
+ if (params == null) {
+ if (other.params != null)
+ return false;
+ } else if (!params.equals(other.params))
+ return false;
+ if (returnClassType == null) {
+ if (other.returnClassType != null)
+ return false;
+ } else if (!returnClassType.equals(other.returnClassType))
+ return false;
+ return true;
+ }
- public List<String> getParams() {
- return params;
- }
-
- public String getReturnType() {
- return returnType;
+ @Override
+ public String toString() {
+ return getNameWithParameters();
}
-
- public boolean equals(Object o) {
- if ( o instanceof MethodInfo ) {
- MethodInfo m = (MethodInfo) o;
-
- if ( this.getName().equals( m.getName() ) && this.getParams().size() == m.getParams().size() ) {
- int i = 0;
- for ( String param : this.params ) {
- param.equals( m.getParams().get( i ) );
- i++;
- }
- }
- }
-
- return false;
- }
-
- public int hashCode() {
- int hash = name.hashCode();
-
- int i = 0;
- for ( String p : params ) {
- hash = hash + (p.hashCode() * i);
- i++;
- }
-
- return hash;
- }
}
More information about the jboss-svn-commits
mailing list