@@ -26,9 +26,11 @@ public class MethodPaintComponent extends DataTextIOPaintComponent
2626 implements DataFromPointDataProvider {
2727
2828 private Method displayingMethod ;
29+ private Class <?>[] wantedType ;
2930
3031 public MethodPaintComponent (Method displayingMethod , int x , int y ) {
3132 super (displayingMethod .toString (), x , y );
33+ this .wantedType = displayingMethod .getParameterTypes ();
3234 this .displayingMethod = displayingMethod ;
3335 init ();
3436 }
@@ -100,6 +102,7 @@ public Object provideInformationToDataFromPoint(
100102 Object operatingInstance = null ;
101103 try {
102104 operatingInstance = toPoints .get (0 ).fetchData ();
105+ System .out .println (operatingInstance .getClass ());
103106 } catch (NoSuchElementException | NoConnectingLineSegmentException
104107 | DataFromPointNoDataProviderException
105108 | DataFromPointProviderCannotProvideDataException e1 ) {
@@ -116,14 +119,18 @@ public Object provideInformationToDataFromPoint(
116119 DataToPoint toPoint = toPoints .get (i +1 );
117120 try {
118121 args [i ] = toPoint .fetchData ();
122+ if (wantedType [i ].isAssignableFrom (String .class )) {
123+ args [i ] = wantedType [i ].cast (args [i ]);
124+ }
119125 } catch (NoSuchElementException | NoConnectingLineSegmentException
120126 | DataFromPointNoDataProviderException
121127 | DataFromPointProviderCannotProvideDataException e ) {
122128 e .printStackTrace ();
123129 // TODO Handle Exception
124130 // arguments must be valid
125131 throw new IllegalStateException ();
126- }
132+ }
133+
127134 }
128135
129136 try {
0 commit comments