vendredi 28 février 2020

Is it possible to change a method's return type for the method chain?

I am implementing a method, myAssert(String s), it needs to behave like this,

condition1: it can work with isEqualTo(o) in a way of myAssert("test").isEqualTo(someObj) to check if they are 2 equal objects

condition2: it can work with startsWith(String s2) in a way of myAssert("this is a string").startsWith("this is")

Apparently myAssert needs to change its return type to be a string or an object. I know in https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html or https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html there are APIs to get information in a class.

But is there any API I can use to retrieve the information about the method channing?

Any comments are appreciated.





Aucun commentaire:

Enregistrer un commentaire