How to get Individual values from twin column select

Hello Vaadin experts,

I have a doubt in twin column select.

final TwinColSelect crops = new TwinColSelect();
CropContainer cropContainer = CropContainer.createWithTestData();
for (Crops crop : cropContainer.getItemIds()) {

		crops.setLeftColumnCaption("Available Crop's");
		crops.setRightColumnCaption("Selected Crop's");

By using crops.getValue() I am getting all te values from the right column. My problem is to iterate through the values of the right column and get the individual values.

I tried hash set ,list and iterate throught it but I am getting the following error

Caused by: java.lang.ClassCastException: java.util.Collections$UnmodifiableSet cannot be cast to java.util.HashSet
at com.zoraly.agridoc.masterregistrations.FarmerInfo$8.buttonClick(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.vaadin.event.ListenerMethod.receiveEvent(
… 22 more

Please Help me

Thanks and Regards,

TwinColSelect returns a UnmodifiableSet so you cannot just cast it to a HashSet. Instead, cast it to a java.util.Set.

Thanks for your reply.

I tried

java.util.Set cropDetailsList = new HashSet ();
cropDetailsList=(java.util.Set) crops.getValue();

But I am not getting values into the set.

Are you sure you have selected (moved items from the left to the right) in the TwinColSelect?

If you do not absolutely need a HashSet then you could just use:
java.util.Set cropDetailsList = (java.util.Set) crops.getValue();

Hey Thanks. That worked fine.