src/JavaMethodDescriptor.st
branchjk_new_structure
changeset 1227 5b7722ac31a4
parent 1155 d6f6d5fc0343
child 1281 b46adbe75503
--- a/src/JavaMethodDescriptor.st	Tue Dec 06 16:31:41 2011 +0000
+++ b/src/JavaMethodDescriptor.st	Tue Dec 06 22:56:28 2011 +0000
@@ -21,7 +21,7 @@
 "{ Package: 'stx:libjava' }"
 
 JavaDescriptor subclass:#JavaMethodDescriptor
-	instanceVariableNames:'parameters return'
+	instanceVariableNames:'return name parameters'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Languages-Java-Support'
@@ -55,6 +55,27 @@
 
 !JavaMethodDescriptor class methodsFor:'instance creation'!
 
+name: name parameters: parameterDescriptors
+
+    ^self new 
+        name: name;
+        parameters: parameterDescriptors;
+        yourself
+
+    "Created: / 06-12-2011 / 21:58:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+name: name parameters: parameterDescriptors return: returnDescriptor
+
+    ^self new 
+        name: name;
+        parameters: parameterDescriptors;
+        return: returnDescriptor;
+        yourself
+
+    "Created: / 06-12-2011 / 21:58:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 parameters: parameterDescriptors return: returnDescriptor
 
     ^self new 
@@ -67,6 +88,10 @@
 
 !JavaMethodDescriptor methodsFor:'accessing'!
 
+name
+    ^ name
+!
+
 parameterClassObjects
     ^ (JavaVM classForName: 'java.lang.Class') javaArrayClass 
         withAll: (parameters collect: [:p | p javaClassObject ])
@@ -108,8 +133,51 @@
     "Modified: / 06-02-2011 / 16:16:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!JavaMethodDescriptor methodsFor:'comparing'!
+
+= another
+
+    ^ self class == another class 
+        and:[ return = another return
+            and:[ name = another name
+                and:[ parameters := another parameters ]]]
+
+    "Created: / 06-12-2011 / 22:45:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+hash
+
+    return hash bitXor: (name hash bitXor: parameters hash)
+
+    "Created: / 06-12-2011 / 22:43:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+match: another
+
+    "This is somewhat relaxed method of =. It does not compare return type
+     and also do a subclass matching of arguments"
+
+    name = another name ifFalse:[ ^ false ].
+    (parameters size) == (another parameters size) ifFalse:[ ^ false ].
+
+    1 to: parameters size do:[:i|
+        ((parameters at: i) match: (another parameters at: i)) ifFalse: [ ^ false ].
+    ].
+    ^true
+
+    "Created: / 06-12-2011 / 22:55:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaMethodDescriptor methodsFor:'initialization'!
 
+name: aString
+    "Sets the method name"
+
+    name := aString
+
+    "Created: / 06-12-2011 / 21:51:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 parameters:aCollection
     parameters := aCollection asArray.