update gradle plugin/examples
[yosql.git] / yosql-dao / yosql-dao-jdbc / src / main / java / wtf / metio / yosql / dao / jdbc / JdbcMethodExceptionHandler.java
blob6b8f385c545aa83d7afdd67a3c753e06ce365703
1 /*
2 * This file is part of yosql. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at https://creativecommons.org/publicdomain/zero/1.0/. No part of yosql,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
5 * in the LICENSE file.
6 */
8 package wtf.metio.yosql.dao.jdbc;
10 import com.squareup.javapoet.ClassName;
11 import com.squareup.javapoet.TypeName;
12 import wtf.metio.yosql.codegen.api.MethodExceptionHandler;
13 import wtf.metio.yosql.models.immutables.SqlConfiguration;
15 import java.sql.SQLException;
16 import java.util.Collections;
18 public final class JdbcMethodExceptionHandler implements MethodExceptionHandler {
20 @Override
21 public Iterable<? extends TypeName> thrownExceptions(final SqlConfiguration configuration) {
22 return configuration.catchAndRethrow()
23 .filter(Boolean.TRUE::equals)
24 .map(bool -> Collections.<TypeName>emptyList())
25 .orElseGet(() -> Collections.singletonList(ClassName.get(SQLException.class)));