0

For logging in the remote server I constantly need to print the parameters of a method to see if this method getting correct parameter.

Is there a way to print all method parameter (if they are object then with toString) in one shot. For example:

 void doSomething(String anyString, Object anyObject)
{
    System.out.println("anyString : "+anyString+" anyObject: "+anyObject.toString());
 // I want to generate above line in one shot.
}

Option 1: Source Generator :
We use source generator to generate toString equals() hashCode() using class variable. SO, is there any way to add another option in source generator to support this.?

Option 2: Using Template :
we write some code block using suggested snippet. like foreach, while , try-catch.

Note: I tried adding a custom template for this purpose, but i was just able to print the parameters name using ${enclosing_method_arguments}. Is there any way to use this?

Option 3: Our Suggestion .

Saif
  • 6,804
  • 8
  • 40
  • 61
  • "(if they are object then with toString)" String concatenation automatically calls `toString()` on an object if it's non-null, or inserts `null` if it is null. Do you want a NPE if the parameter is null? – Andy Turner Nov 27 '15 at 12:43
  • well i guess then without calling `toString()` putting them as they are in String concate will be good idea. But Still don't know how to do that :( – Saif Nov 27 '15 at 12:45

0 Answers0