• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

torand / FasterSQL / 15346133148

30 May 2025 11:50AM UTC coverage: 70.397% (+0.1%) from 70.298%
15346133148

push

github

torand
chore: test javadoc publish

235 of 420 branches covered (55.95%)

Branch coverage included in aggregate %.

1237 of 1671 relevant lines covered (74.03%)

3.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.43
/src/main/java/io/github/torand/fastersql/statement/Helpers.java
1
/*
2
 * Copyright (c) 2024-2025 Tore Eide Andersen
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package io.github.torand.fastersql.statement;
17

18
import java.util.Collection;
19
import java.util.Objects;
20
import java.util.Optional;
21
import java.util.function.Supplier;
22
import java.util.stream.Stream;
23

24
import static io.github.torand.fastersql.util.collection.CollectionHelper.streamSafely;
25
import static java.util.stream.Collectors.joining;
26

27
/**
28
 * Provides statement utility functions.
29
 */
30
public final class Helpers {
31
    private Helpers() {}
32

33
    /**
34
     * Generates a string with comma separated statement parameter markers.
35
     * @param count the number of parameter markers.
36
     * @return the generated parameter marker string.
37
     */
38
    public static String paramMarkers(long count) {
39
        return Stream.generate(() -> "?").limit(count).collect(joining(", "));
11✔
40
    }
41

42
    /**
43
     * Returns the wrapped object if specified object is an optional, else returns the object itself.
44
     * @param obj the object.
45
     * @return the unwrapped object.
46
     */
47
    public static Object unwrapOptional(Object obj) {
48
        if (obj instanceof Optional<?> opt) {
3!
49
            return opt.orElse(null);
×
50
        } else {
51
            return obj;
2✔
52
        }
53
    }
54

55
    /**
56
     * Returns a collection of non-null values produces by the specified suppliers.
57
     * @param suppliers the suppliers.
58
     * @return the collection of supplied values.
59
     * @param <T> the supplier value type.
60
     */
61
    @SafeVarargs
62
    public static <T> Collection<T> unwrapSuppliers(Supplier<T>... suppliers) {
63
        return streamSafely(suppliers).map(Supplier::get).filter(Objects::nonNull).toList();
8✔
64
    }
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc