First answer:
Change the datatype of test from Object to Entry in your example.
Second answer:
If you really need to assign it to an object (in this case, a variable called "test") somewhere along the way (for some reason) then you can do this to get it back:
Object val = ((Entry)test).getValue();