字段值与列表值对应的Map，常用于元素对象中有唯一ID时需要按照这个ID查找对象的情况<br>
例如：车牌号 =》车

@param <K> 字段名对应值得类型，不确定请使用Object
@param <V> 对象类型
@param iter 对象列表
@param fieldName 字段名（会通过反射获取其值）
@return 某个字段值与对象对应Map
@since 4.0.4
518589
public static <K, V> Map<K, V> fieldValueMap(Iterable<V> iter, String fieldName) {
		return fieldValueMap(null == iter ? null : iter.iterator(), fieldName);
	}
1184135
private static String mappingKey(Map<String, String> mapping, String fieldName) {
		if (MapUtil.isEmpty(mapping)) {
			return fieldName;
		}
		return ObjectUtil.defaultIfNull(mapping.get(fieldName), fieldName);
	}
931439
public static <T> T search(Iterable<T> iter, SearchFunction<T> fx) {
        for (final T t : iter) {
            if (fx.match(t)) return t;
        }
        return null;
    }
175283
@SuppressWarnings({"unchecked"})
    public static <T> Iterator<T> cast(Iterator<? extends T> itr) {
        return (Iterator)itr;
    }
1086852
public static String getMapFieldType(Field field) {
        String k = getMapFieldKeyType(field);
        String v = getMapFieldValueType(field);
        return "java.util.Map<" + k + ", " + v + ">";
    }
70325
public static String getMapFieldKeyType(Field field) {
        FieldType type = field.getType();
        if (!(type instanceof Message)) {
            throw new IllegalArgumentException(field.toString());
        }
        Message entryType = (Message) type;
        ScalarFieldType keyType = (ScalarFieldType) entryType.getField(MAP_ENTRY_KEY).getType();
        return ScalarFieldTypeUtil.getWrapperType(keyType);
    }
827026
public static <T, R> Iterator<R> map(final Iterator<T> iterator, final IFunction<T, R> mapper) {
        return new Iterator<R>() {
            @Override
            public boolean hasNext() {
                return iterator.hasNext();
            }

            @Override
            public R next() {
                return mapper.apply(iterator.next());
            }

            @Override
            public void remove() {
                iterator.remove();
            }
        };
    }
645869
def iterfields(klass):
    
    is_field = lambda x: isinstance(x, TypedField)

    for name, field in inspect.getmembers(klass, predicate=is_field):
        yield name, field
263199
private static Map<String, Node> getFields(Node node) {
        Map<String, Node> result = new HashMap<>();
        Iterator<KeyValue> fields = node.fields();
        while (fields.hasNext()) {
            KeyValue field = fields.next();
            result.put(field.getKey(), field.getValue());
        }
        return Collections.unmodifiableMap(result);
    }
439439
public static final Iterator createIterator(Object object) {
        LOGGER.debug("Create an iterator for class: " + (object == null ? "null" : object.getClass().getName()));

        if(object == null)
            return null;

        if(object instanceof Iterator) {
            return (Iterator)object;
        } else if(object instanceof Collection) {
            Collection collection = (Collection)object;
            return collection.iterator();
        } else if(object instanceof Map) {
            return new MapIterator((Map)object);
        } else if(object.getClass().isArray()) {
            return new ArrayIterator(object);
        } else if(object instanceof Enumeration)
            return new EnumerationIterator((Enumeration)object);
        else if(object instanceof ResultSet && !(object instanceof RowSet))
            return new ResultSetIterator((ResultSet)object);

        // check to see if there is a registered IteratorPlant that can handle this type
        Iterator ret = null;
        Iterator factories = ITERATOR_FACTORIES.keySet().iterator();
        while(factories.hasNext()) {
            IteratorPlant plant = (IteratorPlant)ITERATOR_FACTORIES.get(factories.next());
            ret = plant.createIterator(object);

            if(ret != null) return ret;
        }

        return new AtomicObjectIterator(object);
    }
787959
@SuppressWarnings("unchecked")
	public static <K, V> Map<K, V> fieldValueAsMap(Iterator<?> iter, String fieldNameForKey, String fieldNameForValue) {
		final Map<K, V> result = new HashMap<>();
		if (null != iter) {
			Object value;
			while (iter.hasNext()) {
				value = iter.next();
				result.put((K) ReflectUtil.getFieldValue(value, fieldNameForKey), (V) ReflectUtil.getFieldValue(value, fieldNameForValue));
			}
		}
		return result;
	}
342636
@Override
  public Iterator<Counter> iterator() {
    return new Iterator<Counter>() {
      private Iterator<Map.Entry<String,Map<String,Counter>>> groupIter =
          internalMap.entrySet().iterator();
      private Iterator<Map.Entry<String,Counter>> currentGroupIter = null;

      @Override
      public boolean hasNext() {
        // advance current group if necessary
        if ((currentGroupIter == null || !currentGroupIter.hasNext()) && groupIter.hasNext()) {
          currentGroupIter = groupIter.next().getValue().entrySet().iterator();
        }
        return currentGroupIter != null && currentGroupIter.hasNext();
      }

      @Override
      public Counter next() {
        if (!hasNext()) {
          throw new NoSuchElementException("No more elements in iterator");
        }
        return currentGroupIter.next().getValue();
      }

      @Override
      public void remove() {
        throw new UnsupportedOperationException("remove() is not supported by CounterMap");
      }
    };
  }
1317948
public static <E> List<E> toList(Iterable<E> iter) {
		return toList(iter.iterator());
	}
332811
protected Iterable<T> queryByField(Object ancestorKey, String fieldName, Object fieldValue) {
    Iterable values = supplier.queryIterable(getCurrentTransaction(), mapper, false, 0, -1,
      ancestorKey, null,
      null, false, null, false,
      Filter.equalsFilter(fieldName, fieldValue));
    return new MappingIterable<T, ID>(mapper, values.iterator());
  }
989403
public static <T> Key<T> of(Field field)
  {
    return new Key(field.getGenericType(),
                   qualifiers(field.getAnnotations()));
  }
281089
public static <E> List<E> toList(Iterator<E> iter) {
		final List<E> list = new ArrayList<>();
		while (iter.hasNext()) {
			list.add(iter.next());
		}
		return list;
	}
1223815
public static TypeDesc forClass(String name)
        throws IllegalArgumentException
    {
        // TODO: Figure out how to cache these. Using a plain IdentityMap poses
        // a problem. The back reference to the key causes a memory leak.

        if (name.length() < 1) {
            throw invalidName(name);
        }

        int index1 = name.lastIndexOf('[');
        int index2 = name.lastIndexOf(']');
        if (index2 >= 0) {
            if (index2 + 1 != name.length() || index1 + 1 != index2) {
                throw invalidName(name);
            }
            try {
                return forClass(name.substring(0, index1)).toArrayType();
            }
            catch (IllegalArgumentException e) {
                throw invalidName(name);
            }
        }
        else if (index1 >= 0) {
            throw invalidName(name);
        }

        switch (name.charAt(0)) {
        case 'v':
            if (name.equals("void")) {
                return VOID;
            }
            break;
        case 'b':
            if (name.equals("boolean")) {
                return BOOLEAN;
            }
            else if (name.equals("byte")) {
                return BYTE;
            }
            break;
        case 'c':
            if (name.equals("char")) {
                return CHAR;
            }
            break;
        case 's':
            if (name.equals("short")) {
                return SHORT;
            }
            break;
        case 'i':
            if (name.equals("int")) {
                return INT;
            }
            break;
        case 'l':
            if (name.equals("long")) {
                return LONG;
            }
            break;
        case 'f':
            if (name.equals("float")) {
                return FLOAT;
            }
            break;
        case 'd':
            if (name.equals("double")) {
                return DOUBLE;
            }
            break;
        }

        String desc = generateDescriptor(name);
        if (name.indexOf('/') >= 0) {
            name = name.replace('/', '.');
        }
        return intern(new ObjectType(desc, name));
    }