Documented in Collection.js

@see Rekord.ModelCollection#buildKeyFromInput
338635
function(models, out)
  {
    var target = out || this.cloneEmpty();

    for (var i = 0; i < this.length; i++)
    {
      var a = this[ i ];
      var key = a.$key();
      var exists = false;

      if ( models instanceof ModelCollection )
      {
        exists = models.has( key );
      }
      else
      {
        for (var k = 0; k < models.length && !exists; k++)
        {
          var modelKey = this.buildKeyFromInput( models[ k ] );

          exists = (key === modelKey);
        }
      }

      if (!exists)
      {
        target.push( a );
      }
    }

    return target;
  }
1059660
public static <K, V> KeyValueSink<K, V> asMapSink(ImmutableMultimap.Builder<K, V> multimapB) {
    return new ImmutableMultimapBuilderSink<>(multimapB);
  }
226923
function persist(modelfunc, keyfield)
{
	/*jshint newcap:false */
	assert(typeof modelfunc === 'function');

	if (!modelfunc.prototype.__properties && !modelfunc.prototype.serialize)
		throw(new Error('persist only accepts polyclay models'));

	// We must supply either a keyfield parameter or already have a 'key' property.
	var keyprop = Object.getOwnPropertyDescriptor(modelfunc.prototype, 'key');
	if (!keyprop)
	{
		if (!keyfield)
			keyfield = '_id';

		Object.defineProperty(modelfunc.prototype, 'key',
		{
			get: function getKey()
			{
				return this[this.keyfield];
			},
			set: function setKey(v)
			{
				this[this.keyfield] = v;
			},
			enumerable: true
		});
	}
	else
		keyfield = 'key';

	modelfunc.prototype.keyfield = keyfield;

	_.assign(modelfunc, persist.statics);
	_.assign(modelfunc.prototype, persist.plugins);
}
918986
private Criteria buildPrefetchCriteriaMultipleKeys(Collection ids, String[] fkCols, String[] itemFkCols,
            FieldDescriptor[] itemPkFields)
    {
        Criteria crit = new Criteria();
        Criteria critValue = new Criteria();
        Iterator iter = ids.iterator();

        for (int i = 0; i < itemPkFields.length; i++)
        {
            crit.addEqualToField(itemPkFields[i].getAttributeName(), itemFkCols[i]);
        }
        
        while (iter.hasNext())
        {
            Criteria c = new Criteria();
            Identity id = (Identity) iter.next();
            Object[] val = id.getPrimaryKeyValues();

            for (int i = 0; i < val.length; i++)
            {

                if (val[i] == null)
                {
                    c.addIsNull(fkCols[i]);
                }
                else
                {
                    c.addEqualTo(fkCols[i], val[i]);
                }

            }
          
            critValue.addOrCriteria(c);
        }

        crit.addAndCriteria(critValue);
        return crit;
    }
360730
@SuppressWarnings("ConstantConditions")
  ImmutableSetMultimap<K,V> toImmutableSetMultimap() {
    final ImmutableSetMultimap.Builder<K, V>  ret = ImmutableSetMultimap.builder();

    for (final MultimapEntry<K, V> entry : entries) {
      ret.putAll(entry.key, entry.values);
    }

    return ret.build();
  }
1052481
public static Map<?, ?> convertToMap(Collection<?> coll, String keyProperty, String valueProperty) {
    Map<Object, Object> map = newHashMap();
    for (Object obj : coll) {
      Object key = PropertyUtils.getProperty(obj, keyProperty);
      Object value = PropertyUtils.getProperty(obj, valueProperty);
      if (null != key) map.put(key, value);
    }
    return map;
  }
637533
function(keyId) {
    var res = this.get("25519KeysignedKey" + keyId);
    if (res !== undefined) {
      if (!(res.pubKey instanceof ArrayBuffer)) {
        res.pubKey = convertToArrayBuffer(res.pubKey);
      }
      if (!(res.privKey instanceof ArrayBuffer)) {
        res.privKey = convertToArrayBuffer(res.privKey);
      }
      res = { pubKey: res.pubKey, privKey: res.privKey };
    }
    return Promise.resolve(res);
  }
219432
public static Map<String, ?> propsToStringKeyMap(Properties properties) {
    ImmutableMap.Builder<String, Object> mapBuilder = ImmutableMap.builder();
    for (Map.Entry<Object, Object> entry : properties.entrySet()) {
      mapBuilder.put(entry.getKey().toString(), entry.getValue());
    }
    return mapBuilder.build();
  }
961601
public static RSAPrivateKey buildPrivateKey(final byte[] keyData)
            throws NoSuchAlgorithmException, InvalidKeySpecException {
        PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(keyData);
        KeyFactory keyFactory = KeyFactory.getInstance(CIPHER_ALGORITHM);
        PrivateKey generatePrivate = keyFactory.generatePrivate(privateKeySpec);
        return (RSAPrivateKey) generatePrivate;
    }
558094
function singleToMulti(mapping) {
  const newMapping = {};
  Object.entries(mapping.mapping).forEach(m => {
    newMapping[m[0]] = [m[1]];
  });
  return {
    created: mapping.created,
    fields: [mapping.field],
    key: mapping.key,
    mapping: newMapping
  };
}
890625
public static ApiPlatform fromKeyToApiPlatform(int key) {
        if(keyToPlatform.get() == null) {
            Map<Integer, ApiPlatform> map = new HashMap<>();
            for (ApiPlatform apiPlatform : ApiPlatform.values()) {
                map.put(apiPlatform.getKey(), apiPlatform);
            }
            keyToPlatform.set(Collections.unmodifiableMap(map));
        }
        return keyToPlatform.get().get(key);
    }
771484
function (key) {
                var map = this._getMap(key, false);
                if (map == null) {
                    return false;
                }
                var item;
                if (map == this._objectKeys) {
                    item = key[this._metaDataName];
                } else if (map != this._otherKeys) {
                    item = map[key];
                } else {
                    for (var i in map) {
                        if (map.hasOwnProperty(i)) {
                            var elt = map[i];
                            if (key === elt.key) {
                                item = elt;
                                break;
                            }
                        }
                    }
                }
                if (item) {
                    return true;
                } else {
                    return false;
                }
            }
108282
function toDeepMap(source) {
  const map = new Map();
  const keys = Object.keys(source);

  keys.forEach((key) => {
    const val = source[key];

    if (val !== null && typeof val === 'object' && !Array.isArray(val)) {
      return map.set(key, toDeepMap(val));
    }

    if (!isValidNode(val)) {
      throw new Error(`Could not add node at key "${key}", make sure it's a valid node`, val);
    }

    return map.set(key, Number(val));
  });

  return map;
}
1202161
static Map<String, ?> buildSourceByJsonMapper(String jsonObjectString) {
        try {
            return JsonMapper.readValue(jsonObjectString, MAP_TYPE_REFERENCE);
        } catch (Exception e) {
            return JMExceptionManager.handleExceptionAndThrowRuntimeEx(log, e,
                    "buildSourceByJsonMapper", jsonObjectString);
        }
    }
773338
protected <T> JsonObjectBase buildSuccess(String key, T value) {
        return JsonObjectUtils.buildObjectSuccess(key, value);
    }
1312562
function mapObject(o, fn, ctxt) {
  var result = {};
  for (var key in o) {
    if (o.hasOwnProperty(key)) {
      result[key] = fn.call(ctxt, o[key], key, o);
    }
  }
  return result;
}
932410
public static NodeImpl makeIterableAndSetMapKey(final NodeImpl node, final Object key) {
    return new NodeImpl( //
        node.name, //
        node.parent, //
        true, //
        null, //
        key, //
        node.kind, //
        node.parameterTypes, //
        node.parameterIndex, //
        node.value, //
        node.containerClass, //
        node.typeArgumentIndex //
    );
  }