public <T extends RedGEntity> T findSingleEntity(final Class<T> type, final Predicate<T> filter) {
        return this.entities.stream()
                .filter(obj -> Objects.equals(type, obj.getClass()))
                .map(type::cast)
                .filter(filter)
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("Could not find an entity that satisfies the filter!"));
    }
public < T extends RedGEntity > T findSingleEntity ( final Class < T > type , final Predicate < T > filter ) { return this . entities . stream ( ) . filter ( obj -> Objects . equals ( type , obj . getClass ( ) ) ) . map ( type :: cast ) . filter ( filter ) . findFirst ( ) . orElseThrow ( ( ) -> new IllegalArgumentException ( "Could not find an entity that satisfies the filter!" ) ) ; }
Finds a single entity in the list of entities to insert into the database. If multiple entities match the {@link Predicate}, the entity that was added
first will be returned.

@param type   The class of the entity
@param filter A predicate that gets called for every entity that has the requested type. Should return {@code true} only for the entity that should be
found
@param <T>    The entity type
@return The found entity. If no entity is found an {@link IllegalArgumentException} gets thrown.