private void gatherFields(Multimap<ProtoType, ProtoMember> sink, ProtoType type, Object o) { if (o instanceof Map) { for (Map.Entry<?, ?> entry : ((Map<?, ?>) o).entrySet()) { ProtoMember protoMember = (ProtoMember) entry.getKey(); sink.put(type, protoMember); gatherFields(sink, protoMember.type(), entry.getValue()); } } else if (o instanceof List) { for (Object e : (List) o) { gatherFields(sink, type, e); } } }
Multimap<ProtoType, ProtoMember> fields() { Multimap<ProtoType, ProtoMember> result = LinkedHashMultimap.create(); gatherFields(result, optionType, map); return result; }