Reuse a collection of objects when making new entities.

@param entities
reusable collection of entities
@return this
541334
public EntityMakerBuilder reuseEntities(Collection<Object> entities) {
        for (Object entity : entities) {
            Class aClass = entity.getClass();
            valueHolder.putIfNotNull(aClass, entity);
        }
        return this;
    }
1274108
public T withManagedEntityClasses(Class<?>... entityClasses) {
        configMap.put(MANAGED_ENTITIES, Arrays.asList(entityClasses));
        return getThis();
    }
73017
protected void reuseIterator(Session session, int newPosition) throws RepositoryException
   {
      if (!(canReuseIterator() && iterator != null && iterator.getPosition() == newPosition))
      {
         iterator = createIterator(session);
         iterator.skip(newPosition);
      }
   }
1230059
public EntityBuilder addActions(List<Action> actions) {
    	if(actions == null) {
    		throw new IllegalArgumentException("actions cannot be null.");
    	}
        for (Action action : actions) {
            addAction(action);
        }
        return this;
    }
931687
@Override
    public Collection<String> createResources(Request request)
            throws InvalidQueryException, ResourceNotFoundException, ResourceAlreadyExistsException {

        Collection<String> relativeUrls = new ArrayList<>();
        AtlasQuery atlasQuery = queryFactory.createEntityQuery(request);
        Collection<String> guids = new ArrayList<>();
        for (Map<String, Object> entityMap: atlasQuery.execute()) {
            guids.add(String.valueOf(entityMap.get("id")));
        }

        Collection<Map<String, String>> tagMaps = request.getProperty("tags");
        for (Map<String, String> tagMap : tagMaps) {
            Result termResult = getTermQueryResult(tagMap.get("name"));
            relativeUrls.addAll(tagEntities(guids, termResult.getPropertyMaps().iterator().next()));
        }
        return relativeUrls;
    }
435265
public static Object newInstance(Class<?> entity) {
		if (entity == null) {
			return null;
		}
		try {
			return entity.newInstance();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
388820
public void setEntityTypes(java.util.Collection<EntityRecognizerMetadataEntityTypesListItem> entityTypes) {
        if (entityTypes == null) {
            this.entityTypes = null;
            return;
        }

        this.entityTypes = new java.util.ArrayList<EntityRecognizerMetadataEntityTypesListItem>(entityTypes);
    }
1034448
public EntityMakerBuilder reuseEntities(Object first, Object second, Object... rest) {
        List<Object> objects = ImmutableList.builder().add(first).add(second).add(rest).build();
        return reuseEntities(objects);
    }
42216
public static <E> ArrayList<E> newArrayList(Iterable<? extends E> elements) {
		return (elements instanceof Collection) ? new ArrayList<E>((Collection<? extends E>)elements)
				: newArrayList(elements.iterator());
	}
1045493
@SuppressWarnings("deprecation")
	@Override
	public <S extends T> Iterable<S> saveAll(final Iterable<S> entities) {
		if (arangoOperations.getVersion().getVersion().compareTo("3.4.0") < 0) {
			arangoOperations.upsert(entities, UpsertStrategy.UPDATE);
		} else {
			final S first = StreamSupport.stream(entities.spliterator(), false).findFirst().get();
			arangoOperations.repsert(entities, (Class<S>) first.getClass());
		}
		return entities;
	}
598990
public static Object initialize(EntityMetadata m, Object entity, Object id)
    {
        try
        {
            if (entity == null)
            {
                entity = createNewInstance(m.getEntityClazz());
            }
            if (id != null)
            {
                PropertyAccessorHelper.setId(entity, m, id);
            }
            return entity;
        }
        catch (Exception e)
        {
            throw new PersistenceException("Error occured while instantiating entity.", e);
        }
    }
55442
function(entity, options) {
      options = options ? langx.clone(options) : {};
      var wait = options.wait;
      entity = this._prepareEntity(entity, options);
      if (!entity) return false;
      if (!wait) this.add(entity, options);
      var collection = this;
      var success = options.success;
      options.success = function(m, resp, callbackOpts) {
        if (wait) collection.add(m, callbackOpts);
        if (success) success.call(callbackOpts.context, m, resp, callbackOpts);
      };
      entity.save(null, options);
      return entity;
    }
885622
@Override
	public void put(Object entity) {
		if (entity == null) {
			throw new IllegalArgumentException("'entity' must not be [" + entity + "]");
		}
		
		if (operation != null) {
			throw new IllegalStateException("Log [" + operation + "] -> ["
					+ Log.Operation.PUT
					+ "] is not allowed: This operation must be first");
		}
		
		Key id = Keys.create(Translation.toKind(entity.getClass()), Entities.keyValue(entity));
		Entity e = datastore.get(local, id);
		
		if (e != null) {
			throw new EntityExistsException(id);
		}
		
		this.entity = entity;
		operation = Log.Operation.PUT;
	}
499340
public List<Entity> sortEntities(List<Entity> entities) {
        if (entities != null && entities.size() > 0) {
            Entity[] ents = (Entity[]) entities.toArray(new Entity[entities.size()]);
            WIMSortCompare<Entity> wimSortComparator = new WIMSortCompare<Entity>(sortControl);
            Arrays.sort(ents, wimSortComparator);
            entities.clear();
            for (int i = 0; i < ents.length; i++) {
                entities.add(ents[i]);
            }
        }
        return entities;
    }
892220
@Override
    public T create(T entity) {
        EntityManager entityManager = getEntityManager();
        entityManager.persist(entity);
        return entity;
    }
1204753
public static function newFromDatamapperObject($entities, $lastObjectId, $lastEloquentModel)
    {
        $eloquentModels = new static;

        foreach ($entities as $name => $item) {
            if (spl_object_hash($item) == $lastObjectId) {
                $model = $lastEloquentModel;
            } else {
                $model = Model::newFromDatamapperObject($item, $lastObjectId, $lastEloquentModel);
            }

            $eloquentModels->put($name, $model);
        }

        return $eloquentModels;
    }
478882
public ModelNode fromEntityList(List<T> entities)
    {
        ModelNode operation = new ModelNode();
        operation.get(OP).set(COMPOSITE);
        operation.get(ADDRESS).setEmptyList();

        List<ModelNode> steps = new ArrayList<ModelNode>();

        for(T entity : entities)
        {
            steps.add(fromEntity(entity));
        }

        operation.get(STEPS).set(steps);
        return operation;
    }