@@ -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,20 @@ public Object provideInformationToDataFromPoint(
116119 DataToPoint toPoint = toPoints .get (i +1 );
117120 try {
118121 args [i ] = toPoint .fetchData ();
122+ //This usage's effects haven't been verified to be useful.
123+ // ***** DO NOT FOLLOW THIS USAGE IF YOU'RE NOT CLEAR WHAT YOU'RE DOING ******
124+ if (wantedType [i ].isAssignableFrom (String .class )) {
125+ args [i ] = wantedType [i ].cast (args [i ]);
126+ }
119127 } catch (NoSuchElementException | NoConnectingLineSegmentException
120128 | DataFromPointNoDataProviderException
121129 | DataFromPointProviderCannotProvideDataException e ) {
122130 e .printStackTrace ();
123131 // TODO Handle Exception
124132 // arguments must be valid
125133 throw new IllegalStateException ();
126- }
134+ }
135+
127136 }
128137
129138 try {
0 commit comments