Skip to content

Commit 4786811

Browse files
authored
Merge pull request #602 from scireum/feature/sbi/SequencedCollections
Simplifies code by utilizing sequenced collection helpers
2 parents 78eac9d + 21f47ee commit 4786811

File tree

12 files changed

+18
-18
lines changed

12 files changed

+18
-18
lines changed

src/main/java/sirius/db/es/ElasticQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ private <X> List<X> autoinit(List<X> list) {
410410
* @return the query itself for fluent method calls
411411
*/
412412
public ElasticQuery<E> withEffectiveIndices(List<Class<? extends E>> entitiesToQuery) {
413-
this.descriptor = mixing.getDescriptor(entitiesToQuery.get(0));
413+
this.descriptor = mixing.getDescriptor(entitiesToQuery.getFirst());
414414
this.additionalDescriptors = entitiesToQuery.stream().skip(1).map(type -> mixing.getDescriptor(type)).toList();
415415

416416
return this;

src/main/java/sirius/db/es/LowLevelClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ public Optional<String> resolveIndexForAlias(String aliasName) {
365365
.handle();
366366
}
367367

368-
return Optional.of(indexNames.get(0));
368+
return Optional.of(indexNames.getFirst());
369369
}
370370

371371
/**

src/main/java/sirius/db/es/constraints/BoolQueryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public ObjectNode build() {
187187
}
188188

189189
if (musts == 1 && mustNots == 0 && filters == 0 && shoulds == 0 && Strings.isEmpty(name)) {
190-
return must.get(0);
190+
return must.getFirst();
191191
}
192192

193193
ObjectNode query = Json.createObject();

src/main/java/sirius/db/es/constraints/ElasticFilterFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public ElasticConstraint maxScore(@Nonnull List<ElasticConstraint> constraints)
420420
}
421421

422422
if (effectiveConstraints.size() == 1) {
423-
return effectiveConstraints.get(0);
423+
return effectiveConstraints.getFirst();
424424
}
425425

426426
ArrayNode queries = Json.createArray();

src/main/java/sirius/db/es/suggest/SuggestionResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public List<TermSuggestion> getSingleTermSuggestions(String suggester) {
7777
return Collections.emptyList();
7878
}
7979

80-
return textPartSuggestions.get(0).getTermSuggestions();
80+
return textPartSuggestions.getFirst().getTermSuggestions();
8181
}
8282

8383
/**

src/main/java/sirius/db/jdbc/SmartQuery.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ protected Iterator<E> pullNextBlock() {
322322

323323
List<E> block = queryNextBlock();
324324
if (!block.isEmpty()) {
325-
lastValue = block.get(block.size() - 1);
325+
lastValue = block.getLast();
326326
orderByValuesOfLastEntityDuringFetch = extractOrderByValues(lastValue);
327327
}
328328
return block.iterator();
@@ -760,7 +760,7 @@ private void createJoinFetch(Mapping field, List<Mapping> fields, List<Mapping>
760760
List<Mapping> fetchPath = new ArrayList<>();
761761
Mapping parent = field.getParent();
762762
while (parent != null) {
763-
fetchPath.add(0, parent);
763+
fetchPath.addFirst(parent);
764764
parent = parent.getParent();
765765
}
766766
JoinFetch jf = rootFetch;

src/main/java/sirius/db/jdbc/constraints/CompoundValue.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ public Tuple<String, List<Object>> compileExpression(SmartQuery.Compiler compile
8080
}
8181
}
8282
if (components.size() == 1) {
83-
return Tuple.create(sqlRepresentation.get(0), parameters);
83+
return Tuple.create(sqlRepresentation.getFirst(), parameters);
8484
}
8585
return Tuple.create("(" + Strings.join(sqlRepresentation, ", ") + ")", parameters);
8686
}
8787

8888
@Override
8989
public String toString() {
9090
if (components.size() == 1) {
91-
return Objects.toString(components.get(0));
91+
return Objects.toString(components.getFirst());
9292
}
9393
return "(" + components.stream().map(Objects::toString).collect(Collectors.joining(", ")) + ")";
9494
}

src/main/java/sirius/db/mixing/properties/MultiPointLocationProperty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public Object transformFromDatasource(Class<? extends BaseMapper<?, ?, ?>> mappe
104104
Object coordinates = ((Document) object.get()).get("coordinates");
105105
if (coordinates instanceof List<?>) {
106106
return ((List<List<Double>>) coordinates).stream()
107-
.map(entry -> Tuple.create(entry.get(0), entry.get(1)))
107+
.map(entry -> Tuple.create(entry.getFirst(), entry.get(1)))
108108
.collect(Collectors.toCollection(ArrayList::new));
109109
}
110110
}

src/main/java/sirius/db/mixing/query/BaseQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public E queryOne() {
349349
if (result.size() != 1) {
350350
return null;
351351
} else {
352-
return result.get(0);
352+
return result.getFirst();
353353
}
354354
}
355355
}

src/main/java/sirius/db/mixing/query/constraints/FilterFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public final C and(List<C> constraints) {
392392
return null;
393393
}
394394
if (effectiveConstraints.size() == 1) {
395-
return effectiveConstraints.get(0);
395+
return effectiveConstraints.getFirst();
396396
}
397397

398398
return effectiveAnd(effectiveConstraints);
@@ -432,7 +432,7 @@ public final C or(List<C> constraints) {
432432
return null;
433433
}
434434
if (effectiveConstraints.size() == 1) {
435-
return effectiveConstraints.get(0);
435+
return effectiveConstraints.getFirst();
436436
}
437437

438438
return effectiveOr(effectiveConstraints);

0 commit comments

Comments
 (0)