/** * Returns the query string to execute an exists query for the given id attributes. * * @param entityName the name of the entity to create the query for, must not be {@literal null}. * @param countQueryPlaceHolder the placeholder for the count clause, must not be {@literal null}. * @param idAttributes the id attributes for the entity, must not be {@literal null}. */ public static String getExistsQueryString(String entityName, String countQueryPlaceHolder, Iterable<String> idAttributes) { String whereClause = Streamable.of(idAttributes).stream() // .map(idAttribute -> String.format(EQUALS_CONDITION_STRING, "x", idAttribute, idAttribute)) // .collect(Collectors.joining(" AND ", " WHERE ", "")); return String.format(COUNT_QUERY_STRING, countQueryPlaceHolder, entityName) + whereClause; }
@Override public <S extends T> List<S> saveAll(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities not be null!"); Streamable<S> source = Streamable.of(entities); boolean allNew = source.stream().allMatch(it -> entityInformation.isNew(it)); if (allNew) { List<S> result = source.stream().collect(Collectors.toList()); return new ArrayList<>(mongoOperations.insert(result, entityInformation.getCollectionName())); } return source.stream().map(this::save).collect(Collectors.toList()); }
@Override public <S extends T> List<S> insert(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities not be null!"); List<S> list = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList()); if (list.isEmpty()) { return list; } return new ArrayList<>(mongoOperations.insertAll(list)); }
@Override public <S extends T> Flux<S> saveAll(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities must not be null!"); Streamable<S> source = Streamable.of(entities); return source.stream().allMatch(entityInformation::isNew) ? // mongoOperations.insert(source.stream().collect(Collectors.toList()), entityInformation.getCollectionName()) : // Flux.fromIterable(entities).flatMap(this::save); }
@Override public <S extends T> Flux<S> insert(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities must not be null!"); List<S> source = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList()); return source.isEmpty() ? Flux.empty() : Flux.from(mongoOperations.insertAll(source)); }
@Override public Flux<T> findAllById(Iterable<ID> ids) { Assert.notNull(ids, "The given Iterable of Id's must not be null!"); return findAll(new Query(new Criteria(entityInformation.getIdAttribute()) .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())))); }
@Override public Iterable<T> findAllById(Iterable<ID> ids) { return findAll(new Query(new Criteria(entityInformation.getIdAttribute()) .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())))); }
@Override public <S extends T> List<S> saveAll(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities not be null!"); Streamable<S> source = Streamable.of(entities); boolean allNew = source.stream().allMatch(it -> entityInformation.isNew(it)); if (allNew) { List<S> result = source.stream().collect(Collectors.toList()); return new ArrayList<>(mongoOperations.insert(result, entityInformation.getCollectionName())); } return source.stream().map(this::save).collect(Collectors.toList()); }
@Override public <S extends T> List<S> insert(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities not be null!"); List<S> list = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList()); if (list.isEmpty()) { return list; } return new ArrayList<>(mongoOperations.insertAll(list)); }
@Override public <S extends T> Flux<S> saveAll(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities must not be null!"); Streamable<S> source = Streamable.of(entities); return source.stream().allMatch(entityInformation::isNew) ? // mongoOperations.insert(source.stream().collect(Collectors.toList()), entityInformation.getCollectionName()) : // Flux.fromIterable(entities).flatMap(this::save); }
@Override public <S extends T> Flux<S> insert(Iterable<S> entities) { Assert.notNull(entities, "The given Iterable of entities must not be null!"); List<S> source = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList()); return source.isEmpty() ? Flux.empty() : Flux.from(mongoOperations.insertAll(source)); }
@Override public Flux<T> findAllById(Iterable<ID> ids) { Assert.notNull(ids, "The given Iterable of Id's must not be null!"); return findAll(new Query(new Criteria(entityInformation.getIdAttribute()) .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())))); }
@Override public Iterable<T> findAllById(Iterable<ID> ids) { return findAll(new Query(new Criteria(entityInformation.getIdAttribute()) .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())))); }
@Override public <S extends T> Iterable<S> saveAll(Iterable<S> entities) { return Streamable.of(entities).stream() // .map(this::save) // .collect(Collectors.toList()); }
/** * Returns a new {@link Streamable} that will apply the given {@link Function} to the current one. * * @param mapper must not be {@literal null}. * @return * @see Stream#flatMap(Function) */ default <R> Streamable<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper) { Assert.notNull(mapper, "Mapping function must not be null!"); return Streamable.of(() -> stream().flatMap(mapper)); }
/** * Creates a new {@link Streamable} from the current one and the given {@link Stream} concatenated. * * @param stream must not be {@literal null}. * @return * @since 2.1 */ default Streamable<T> and(Supplier<? extends Stream<? extends T>> stream) { Assert.notNull(stream, "Stream must not be null!"); return Streamable.of(() -> Stream.concat(this.stream(), stream.get())); }
public List<TypeInformation<?>> getParameterTypes(Method method) { Assert.notNull(method, "Method most not be null!"); return Streamable.of(method.getGenericParameterTypes()).stream()// .map(this::createInfo)// .collect(Collectors.toList()); }
/** * Returns a new {@link Streamable} that will apply the given filter {@link Predicate} to the current one. * * @param predicate must not be {@literal null}. * @return * @see Stream#filter(Predicate) */ default Streamable<T> filter(Predicate<? super T> predicate) { Assert.notNull(predicate, "Filter predicate must not be null!"); return Streamable.of(() -> stream().filter(predicate)); }
private boolean isExcluded(String beanClassName, Streamable<TypeFilter> filters) { try { MetadataReader reader = getMetadataReaderFactory().getMetadataReader(beanClassName); return filters.stream().anyMatch(it -> matches(it, reader)); } catch (IOException o_O) { return true; } }
private Map<Method, RepositoryQuery> mapMethodsToQuery(RepositoryInformation repositoryInformation, QueryLookupStrategy lookupStrategy, ProjectionFactory projectionFactory) { return repositoryInformation.getQueryMethods().stream() // .map(method -> lookupQuery(method, repositoryInformation, lookupStrategy, projectionFactory)) // .peek(pair -> invokeListeners(pair.getSecond())) // .collect(Pair.toMap()); }