-1

I have a class and its controller.In the controller i am defining as below:

//controller 
def empData = new Employee(name:'test',joinDate:'03-Jan-2010',qualifications:['Developer','Tester'])
println("emp Info:"+empData);

//class

import groovy.transform.ToString
@ToString
class Employee{
public String name
public Date joinDate
public Map<String,String[]> qualifications
}

enter image description here

In the println i see the path of the object like com.Employee@515 How to get all the details of the empData object instead of path?

Studentlearner
  • 99
  • 2
  • 11

1 Answers1

0

I couple of different things you can do:

Like the comment said you can define you own toString() method in the Domain object and do what you want like this for example:

String toString() {
    String name = ""
    if (lastName) name = name+lastName
    if (firstName) name = name+", "+firstName
    if (middleName) name = name+" "+middleName
    name = name+" - "+position
    name = name+" - "+city
    return name
}

Also you could just print the fields from your object:

println("emp first name Info:"+empData.first_name);

Joe
  • 1,219
  • 8
  • 13