通过Editor抽取集合元素中的某些值返回为新列表<br>
例如提供的是一个Bean列表，通过Editor接口实现获取某个字段值，返回这个字段值组成的新列表

@param collection 原集合
@param editor 编辑器
@param ignoreNull 是否忽略空值
@return 抽取后的新列表
@since 4.5.7
348265
public static List<Object> extract(Iterable<?> collection, Editor<Object> editor, boolean ignoreNull) {
		final List<Object> fieldValueList = new ArrayList<>();
		Object value;
		for (Object bean : collection) {
			value = editor.edit(bean);
			if (null == value && ignoreNull) {
				continue;
			}
			fieldValueList.add(value);
		}
		return fieldValueList;
	}
589881
public HllUpdate addAll(Collection<String> elements)
    {
        if (elements == null)
        {
            throw new IllegalArgumentException("Elements cannot be null");
        }

        for (String element : elements)
        {
            this.adds.add(BinaryValue.create(element));
        }

        return this;
    }
1113617
public static void addIfNotNull(JSONWriter writer, String field,
			Date value, final SimpleDateFormat format) throws JSONException {
		if (value == null)
			return;
		writer.key(field);
		writer.value(format.format(value));
	}
183944
public static <T> void addIfNotNull(JSONWriter writer, String field,
			T value, JsonObjectWriter<T> objWriter) throws JSONException {
		if (value == null)
			return;
		writer.key(field);
		writer.object();
		objWriter.write(writer, value);
		writer.endObject();
	}
1262765
@SuppressWarnings({ "unchecked", "rawtypes" })
	public static <T> Collection<T> addAll(Collection<T> collection, Object value, Type elementType) {
		if (null == collection || null == value) {
			return collection;
		}
		if (TypeUtil.isUnknow(elementType)) {
			// 元素类型为空时，使用Object类型来接纳所有类型
			elementType = Object.class;
		} else {
			final Class<?> elementRowType = TypeUtil.getClass(elementType);
			if (null != elementRowType && (elementRowType.isInstance(value) && false == Iterable.class.isAssignableFrom(elementRowType))) {
				// 其它类型按照单一元素处理
				collection.add((T) value);
				return collection;
			}
		}

		Iterator iter;
		if (value instanceof Iterator) {
			iter = (Iterator) value;
		} else if (value instanceof Iterable) {
			iter = ((Iterable) value).iterator();
		} else if (value instanceof Enumeration) {
			iter = new EnumerationIter<>((Enumeration) value);
		} else if (ArrayUtil.isArray(value)) {
			iter = new ArrayIter<>(value);
		} else if (value instanceof CharSequence) {
			// String按照逗号分隔的列表对待
			iter = StrUtil.splitTrim((CharSequence) value, CharUtil.COMMA).iterator();
		} else {
			// 其它类型按照单一元素处理
			iter = CollUtil.newArrayList(value).iterator();
		}

		final ConverterRegistry convert = ConverterRegistry.getInstance();
		while (iter.hasNext()) {
			collection.add((T) convert.convert(elementType, iter.next()));
		}

		return collection;
	}
1163692
function ignoreFactory (ignoreList) {

    if (typeof ignoreList === 'function') {
        return ignoreList;
    }

    var fn = ignore().add(ignoreList || []);

    // @param   {String}
    // @return  {Boolean}
    return ignoreList.length ? function (src) {

        if (!src) {
            return false;
        }

        return !fn.filter([src])[0];

    } : function () {
        return false;
    };
}
961400
public void setNull(long mask) {
		for (int i = 0; i < this.numFields; i++, mask >>>= 1) {
			if ((mask & 0x1) != 0) {
				internallySetField(i, null);
			}
		}
	}
1115814
function collectionUpdate (collection, result) {
	result._id = createID(result.pattern, result.language);
	return collection.insertOne(result)
		.catch((e) => {
			// May fail due to concurrent update on the same value.
			log(`collectionUpdate: error: ${e}`);
			return Promise.resolve(PATTERN_INVALID);
		});
}
547333
private <T> void bindIfNotNull(final Class<T> interfaceType, @Nullable final Class<? extends T> implementationType) {
        if (implementationType != null) {
            bind(interfaceType).to(implementationType);
        }
    }
585312
public MultimapJoiner useForNull(final String nullText) {
		return new MultimapJoiner(entryJoiner.useForNull(nullText), separator, keyValueSeparator) {
			@Override
			protected CharSequence toString(Object part) {
				return (part == null) ? nullText : MultimapJoiner.this.toString(part);
			}

			@Override
			public MultimapJoiner useForNull(String nullText) {
				throw new UnsupportedOperationException("already specified useForNull");
			}

			@Override
			public MultimapJoiner skipNulls() {
				throw new UnsupportedOperationException("already specified useForNull");
			}
		};
	}
834695
public static Map<String, Object> beanToMap(Object bean, Map<String, Object> targetMap, final boolean isToUnderlineCase, boolean ignoreNullValue) {
		if (bean == null) {
			return null;
		}

		return beanToMap(bean, targetMap, ignoreNullValue, new Editor<String>() {

			@Override
			public String edit(String key) {
				return isToUnderlineCase ? StrUtil.toUnderlineCase(key) : key;
			}
		});
	}
1083819
public static <T> T firstNotNull(final T... objects) {
        for (final T object : objects) {
            if (object != null) {
                return object;
            }
        }
        return null;
    }
141057
@Override
	public <L extends Collection<E>> L parseCollection(BinderContext context, ParserWrapper parserWrapper, L collection)  throws Exception {
		switch (context.getSupportedFormat()) {
		case XML: {
			throw (new KriptonRuntimeException(context.getSupportedFormat() + " context does not support direct collection persistance"));
		}
		default: {
			JacksonWrapperParser wrapperParser = (JacksonWrapperParser) parserWrapper;
			JsonParser parser = wrapperParser.jacksonParser;

			try {
				collection.clear();

				if (parser.nextToken() != JsonToken.START_ARRAY) {
					throw (new KriptonRuntimeException("Invalid input format"));
				}
				if (context.getSupportedFormat().onlyText) {
					while (parser.nextToken() != JsonToken.END_ARRAY) {
						collection.add(parseOnJacksonAsString(parser));
					}
				} else {
					while (parser.nextToken() != JsonToken.END_ARRAY) {
						collection.add(parseOnJackson(parser));
					}
				}
				return collection;
			} catch (IOException e) {
				e.printStackTrace();
				throw (new KriptonRuntimeException(e));
			}
		}
		}
	}
993641
@SuppressWarnings("unchecked")
  @Override
  public <T> List<T> findAllAndModify(String jxQuery, Update update, String collectionName) {
    CollectionMetaData cmd = cmdMap.get(collectionName);
    Map<Object, T> collection = (Map<Object, T>) collectionsRef.get().get(collectionName);
    if((null == cmd) || (null == collection)) {
      throw new InvalidJsonDbApiUsageException("Collection by name '" + collectionName + "' not found. Create collection first.");
    }
    cmd.getCollectionLock().writeLock().lock();
    try {
      JXPathContext context = contextsRef.get().get(collectionName);
      Iterator<T> resultItr = context.iterate(jxQuery);
      Map<Object, T> clonedModifiedObjects = new HashMap<Object, T>();

      while (resultItr.hasNext()) {
        T objectToModify = resultItr.next();
        T clonedModifiedObject = (T) Util.deepCopy(objectToModify);

        for (Entry<String, Object> entry : update.getUpdateData().entrySet()) {
          Object newValue = Util.deepCopy(entry.getValue());
          if(encrypted && cmd.hasSecret() && cmd.isSecretField(entry.getKey())){
            newValue = dbConfig.getCipher().encrypt(newValue.toString());
          }
          try {
            BeanUtils.copyProperty(clonedModifiedObject, entry.getKey(), newValue);
          } catch (IllegalAccessException | InvocationTargetException e) {
            logger.error("Failed to copy updated data into existing collection document using BeanUtils", e);
            return null;
          }
        }
        Object id = Util.getIdForEntity(clonedModifiedObject, cmd.getIdAnnotatedFieldGetterMethod());
        clonedModifiedObjects.put(id, clonedModifiedObject);
      }

      JsonWriter jw = null;
      try {
        jw = new JsonWriter(dbConfig, cmd, collectionName, fileObjectsRef.get().get(collectionName));
      } catch (IOException ioe) {
        logger.error("Failed to obtain writer for " + collectionName, ioe);
        throw new JsonDBException("Failed to save " + collectionName, ioe);
      }
      boolean updateResult = jw.updateInJsonFile(collection, clonedModifiedObjects);
      if (updateResult) {
       collection.putAll(clonedModifiedObjects);
       //Clone it once more because we want to disconnect it from the in-memory objects before returning.
       List<T> returnObjects = new ArrayList<T>();
       for (T obj : clonedModifiedObjects.values()) {
         //Clone it once more because we want to disconnect it from the in-memory objects before returning.
         T returnObj = (T) Util.deepCopy(obj);
         if(encrypted && cmd.hasSecret() && null!= returnObj){
           CryptoUtil.decryptFields(returnObj, cmd, dbConfig.getCipher());
         }
         returnObjects.add(returnObj);
       }
       return returnObjects;
      }
      return null;
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
      logger.error("Error when decrypting value for a @Secret annotated field for entity: " + collectionName, e);
      throw new JsonDBException("Error when decrypting value for a @Secret annotated field for entity: " + collectionName, e);
    } finally {
      cmd.getCollectionLock().writeLock().unlock();
    }
  }
1276445
public static <T> List<T> filter(List<T> list, Editor<T> editor) {
		if (null == list || null == editor) {
			return list;
		}

		final List<T> list2 = (list instanceof LinkedList) ? new LinkedList<T>() : new ArrayList<T>(list.size());
		T modified;
		for (T t : list) {
			modified = editor.edit(t);
			if (null != modified) {
				list2.add(modified);
			}
		}
		return list2;
	}
25759
public static List<FieldInfo> processDefaultValue(List<Field> fields, boolean ignoreNoAnnotation,
            boolean isZipZap) {
        if (fields == null) {
            return null;
        }

        List<FieldInfo> ret = new ArrayList<FieldInfo>(fields.size());

        int maxOrder = 0;
        List<FieldInfo> unorderFields = new ArrayList<FieldInfo>(fields.size());
        Set<Integer> orders = new HashSet<Integer>();
        for (Field field : fields) {
            Ignore ignore = field.getAnnotation(Ignore.class);
            if (ignore != null) {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Field name '{}' marked @Ignore annotation will be ignored.", field.getName());
                }
                continue;
            }

            Protobuf protobuf = field.getAnnotation(Protobuf.class);
            if (protobuf == null && !ignoreNoAnnotation) {
                throw new RuntimeException("Field '" + field.getName() + "' has no @Protobuf annotation");
            }

            // check field is support for protocol buffer
            // any array except byte array is not support
            String simpleName = field.getType().getName();
            if (simpleName.startsWith("[")) {
                if ((!simpleName.equals(byte[].class.getName())) && (!simpleName.equals(Byte[].class.getName()))) {
                    throw new RuntimeException("Array type of field '" + field.getName() + "' on class '"
                            + field.getDeclaringClass().getName() + "' is not support,  please use List instead.");
                }
            }

            FieldInfo fieldInfo = new FieldInfo(field);
            FieldType annFieldType = FieldType.DEFAULT;
            int order = -1;
            if (protobuf != null) {
                fieldInfo.setRequired(protobuf.required());
                fieldInfo.setDescription(protobuf.description());
                annFieldType = protobuf.fieldType();
                order = protobuf.order();
            } else {
                fieldInfo.setRequired(false);
            }

            // process type
            if (annFieldType == FieldType.DEFAULT) {

                Class fieldTypeClass = field.getType();

                // if list
                boolean isList = fieldInfo.isList();
                if (isList) {
                    fieldTypeClass = fieldInfo.getGenericKeyType();
                }

                FieldType fieldType = TYPE_MAPPING.get(fieldTypeClass);
                if (fieldType == null) {
                    // check if type is enum
                    if (Enum.class.isAssignableFrom(fieldTypeClass)) {
                        fieldType = FieldType.ENUM;
                    } else if (fieldInfo.isMap()) {
                        fieldType = FieldType.MAP;
                    } else {
                        fieldType = FieldType.OBJECT;
                    }
                }
                
                // check if enable zagzip
                if (isZipZap) {
                    if (fieldType == FieldType.INT32) {
                        fieldType = FieldType.SINT32; // to convert to sint32 to enable zagzip
                    } else if (fieldType == FieldType.INT64) {
                        fieldType = FieldType.SINT64; // to convert to sint64 to enable zagzip
                    }
                }
                
                
                
                fieldInfo.setFieldType(fieldType);
            } else {
                fieldInfo.setFieldType(annFieldType);
            }

            if (order > 0) {
                if (orders.contains(order)) {
                    throw new RuntimeException(
                            "order id '" + order + "' from field name '" + field.getName() + "'  is duplicate");
                }
                orders.add(order);
                fieldInfo.setOrder(order);
                if (order > maxOrder) {
                    maxOrder = order;
                }
            } else {
                unorderFields.add(fieldInfo);
            }

            if (fieldInfo.isList() && (fieldInfo.getFieldType().isPrimitive() || fieldInfo.getFieldType().isEnum())) {
                Packed packed = field.getAnnotation(Packed.class);
                if (packed == null) {
                    fieldInfo.setPacked(true);
                } else {
                    fieldInfo.setPacked(packed.value());
                }
            }

            ret.add(fieldInfo);
        }

        if (unorderFields.isEmpty()) {
            return ret;
        }

        for (FieldInfo fieldInfo : unorderFields) {
            maxOrder++;
            fieldInfo.setOrder(maxOrder);

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(
                        "Field '{}' from {} with @Protobuf annotation but not set order or order is 0,"
                                + " It will set order value to {}",
                        fieldInfo.getField().getName(), fieldInfo.getField().getDeclaringClass().getName(), maxOrder);
            }
        }

        return ret;
    }
289792
private static List<String> maskNull(List<String> pTypes) {
        return (pTypes == null) ? Collections.<String>emptyList() : pTypes;
    }