Skip to content

Commit 188fdeb

Browse files
committed
Merged for javadoc
2 parents 8fa2c1c + f5db8bd commit 188fdeb

File tree

7 files changed

+26
-127
lines changed

7 files changed

+26
-127
lines changed

mug-guava/src/main/java/com/google/mu/safesql/ResultMapper.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
import java.sql.ResultSet;
2020
import java.sql.ResultSetMetaData;
2121
import java.sql.SQLException;
22-
import java.time.Instant;
23-
import java.time.LocalDate;
24-
import java.time.LocalTime;
25-
import java.time.OffsetDateTime;
26-
import java.time.ZonedDateTime;
2722
import java.util.HashMap;
2823
import java.util.LinkedHashSet;
2924
import java.util.List;
@@ -46,17 +41,14 @@
4641
* {@link SqlName @SqlName}.
4742
*/
4843
abstract class ResultMapper<T> {
49-
private static final ImmutableSet<Class<?>> SQL_PRIMITIVE_TYPES =
50-
ImmutableSet.of(
51-
ZonedDateTime.class, OffsetDateTime.class, Instant.class,
52-
LocalDate.class, LocalTime.class, String.class);
53-
5444
static <T> ResultMapper<T> toResultOf(Class<T> resultType) {
5545
checkArgument(
56-
!Primitives.allPrimitiveTypes().contains(resultType), "resultType cannot be primitive: %s",
57-
resultType);
46+
!Primitives.allPrimitiveTypes().contains(resultType),
47+
"resultType cannot be primitive: %s", resultType);
5848
checkArgument(resultType != Void.class, "resultType cannot be Void");
59-
if (SQL_PRIMITIVE_TYPES.contains(resultType) || Primitives.isWrapperType(resultType)) {
49+
if (resultType.getName().startsWith("java.")
50+
|| resultType.getName().startsWith("javax.")
51+
|| resultType.isArray()) {
6052
return new ResultMapper<T>() {
6153
@Override T from(ResultSet row) throws SQLException {
6254
return row.getObject(1, resultType);

mug-guava/src/main/java/com/google/mu/safesql/SafeSql.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ public SafeSql orElse(Supplier<SafeSql> fallback) {
757757
* @throws UncheckedSqlException wraps {@link SQLException} if failed
758758
* @since 8.7
759759
*/
760-
public <T> List<T> query(Connection connection, Class<T> resultType) {
760+
public <T> List<T> query(Connection connection, Class<? extends T> resultType) {
761761
return query(connection, ResultMapper.toResultOf(resultType)::from);
762762
}
763763

@@ -837,7 +837,7 @@ public <T> List<T> query(
837837
*/
838838
@MustBeClosed
839839
@SuppressWarnings("MustBeClosedChecker")
840-
public <T> Stream<T> queryLazily(Connection connection, Class<T> resultType) {
840+
public <T> Stream<T> queryLazily(Connection connection, Class<? extends T> resultType) {
841841
return queryLazily(connection, ResultMapper.toResultOf(resultType)::from);
842842
}
843843

@@ -912,7 +912,7 @@ public <T> Stream<T> queryLazily(
912912
*/
913913
@MustBeClosed
914914
@SuppressWarnings("MustBeClosedChecker")
915-
public <T> Stream<T> queryLazily(Connection connection, int fetchSize, Class<T> resultType) {
915+
public <T> Stream<T> queryLazily(Connection connection, int fetchSize, Class<? extends T> resultType) {
916916
return queryLazily(connection, fetchSize, ResultMapper.toResultOf(resultType)::from);
917917
}
918918

@@ -1055,7 +1055,7 @@ public PreparedStatement prepareStatement(Connection connection) {
10551055
* @since 8.7
10561056
*/
10571057
public static <T> Template<List<T>> prepareToQuery(
1058-
Connection connection, @CompileTimeConstant String template, Class<T> resultType) {
1058+
Connection connection, @CompileTimeConstant String template, Class<? extends T> resultType) {
10591059
return prepareToQuery(connection, template, ResultMapper.toResultOf(resultType)::from);
10601060
}
10611061

mug/src/main/java/com/google/mu/util/Substring.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@
327327
* }</pre></td>
328328
* <td><pre>{@code
329329
* // Explicitly filter out empty matches
330-
* List<String> parts = consecutive(is('-'))
330+
* List<String> parts = consecutive('-')
331331
* .repeatedly()
332332
* .split("a--b-c-")
333333
* .filter(Match::isNotEmpty)
@@ -344,7 +344,7 @@
344344
* // => ["a", ""]
345345
* }</pre></td>
346346
* <td><pre>{@code
347-
* List<String> parts = consecutive(is('-'))
347+
* List<String> parts = consecutive('-')
348348
* .repeatedly()
349349
* .split("a--")
350350
* .map(Match::toString)
@@ -660,6 +660,16 @@ public static Pattern trailing(CharPredicate matcher) {
660660
};
661661
}
662662

663+
/**
664+
* Returns a {@code Pattern} that matches the first non-empty sequence of consecutive {@code ch}
665+
* characters.
666+
*
667+
* @since 8.7
668+
*/
669+
public static Pattern consecutive(char ch) {
670+
return consecutive(CharPredicate.is(ch));
671+
}
672+
663673
/**
664674
* Returns a {@code Pattern} that matches the first non-empty sequence of consecutive characters
665675
* identified by {@code matcher}.

mug/src/main/java/com/google/mu/util/concurrent/Completion.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

mug/src/main/java/com/google/mu/util/concurrent/Fanout.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,18 +481,16 @@ Scope add(Runnable... tasks) {
481481
}
482482

483483
void run() throws StructuredConcurrencyInterruptedException {
484-
try (Completion completion = new Completion()) {
485-
withUnlimitedConcurrency().parallelize(runnables.stream().map(completion::toRun));
484+
try {
485+
withUnlimitedConcurrency().parallelize(runnables.stream());
486486
} catch (InterruptedException e) {
487487
throw new StructuredConcurrencyInterruptedException(e);
488488
}
489489
}
490490

491491
@Deprecated
492492
void runUninterruptibly() {
493-
try (Completion completion = new Completion()) {
494-
withUnlimitedConcurrency().parallelizeUninterruptibly(runnables.stream().map(completion::toRun));
495-
}
493+
withUnlimitedConcurrency().parallelizeUninterruptibly(runnables.stream());
496494
}
497495
}
498496

mug/src/main/java/com/google/mu/util/concurrent/Parallelizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,10 @@ public void parallelizeUninterruptibly(Stream<? extends Runnable> tasks) {
439439
inputs -> {
440440
List<O> outputs = new ArrayList<>(inputs.size());
441441
outputs.addAll(Collections.nCopies(inputs.size(), null));
442-
try (Completion completion = new Completion()){
442+
try {
443443
parallelize(
444444
IntStream.range(0, inputs.size()).boxed(),
445-
i -> completion.run(() -> outputs.set(i, concurrentFunction.apply(inputs.get(i)))));
445+
i -> outputs.set(i, concurrentFunction.apply(inputs.get(i))));
446446
} catch (InterruptedException e) {
447447
throw new StructuredConcurrencyInterruptedException(e);
448448
}

mug/src/test/java/com/google/mu/util/concurrent/CompletionTest.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)