Development Assistance Map.Entry

Discussion in 'Plugin Help/Development/Requests' started by UniqueNameDen, Mar 11, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    UniqueNameDen

    I need help with Map.Entry...
    So the problem is that Map.Entry returns as an Object
    Code:
    http://pastebin.com/3SQNHLeL
    for (Map.Entry<?, ?> commandEntry : ((Map)command.getValue()).entrySet()) {
    The first one works fine but the second one gives me an error anyway to fix this..?

    ERROR:
    Required: Map.Entry <?,?>

    Found: Object

    Solved on StackOverflow: Problem was I needed to cast Map<?, ?> instead of Map
     
    Last edited: Mar 12, 2015
  2. Offline

    Lolmewn

    Cast it to Map<?, ?> instead of just casting to Map.
     
  3. Offline

    UniqueNameDen

    Then it makes it a "map" not a "Map.Entry"
    I think you didn't fully look throught the code:
    Code:java
    1.  
    2. if ((commandEntry.getValue() instanceof Iterable)) {
    3. ImmutableList.Builder<Object> commandSubList = ImmutableList.builder();
    4. for (Object commandSubListItem : (Iterable)commandEntry.getValue()) {
    5. if (commandSubListItem != null) {
    6. commandSubList.add(commandSubListItem);
    7. }
    8. }
    9. commandBuilder.put(commandEntry.getKey().toString(), commandSubList.build());
    10. }
    11.  
     
  4. @UniqueNameDen
    Where is your command variable and where do you use the for statement?
     
  5. Offline

    UniqueNameDen

     
Thread Status:
Not open for further replies.

Share This Page