Skip to content

Commit

Permalink
Merge pull request #708 from chidaodezhongsheng/dev
Browse files Browse the repository at this point in the history
fix ProprertyUtil checkstyle errors
  • Loading branch information
terrymanu authored Apr 9, 2018
2 parents 8eaa43f + 198ee46 commit 4d04eef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
import io.shardingjdbc.core.exception.ShardingJdbcException;

public class PropertyUtil {

private static int springBootVersion = 1;

static {
try {
Class.forName("org.springframework.boot.bind.RelaxedPropertyResolver");
} catch (ClassNotFoundException e) {
springBootVersion = 2;
}
}

/**
* Spring Boot 1.x is compatible with Spring Boot 2.x by Using Java Reflect.
* @param environment : the environment context
Expand All @@ -50,13 +50,13 @@ public class PropertyUtil {
public static <T> T handle(final Environment environment, final String prefix, final Class<T> targetClass) {
switch (springBootVersion) {
case 1:
return (T) v1(environment, prefix, targetClass);
return (T) v1(environment, prefix);
default:
return (T) v2(environment, prefix, targetClass);
}
}

private static Object v1(final Environment environment, final String prefix, final Class<?> targetClass) {
private static Object v1(final Environment environment, final String prefix) {
try {
Class<?> resolverClass = Class.forName("org.springframework.boot.bind.RelaxedPropertyResolver");
Constructor<?> resolverConstructor = resolverClass.getDeclaredConstructor(PropertyResolver.class);
Expand All @@ -69,7 +69,7 @@ private static Object v1(final Environment environment, final String prefix, fin
throw new ShardingJdbcException(ex.getMessage(), ex);
}
}

private static Object v2(final Environment environment, final String prefix, final Class<?> targetClass) {
try {
Class<?> binderClass = Class.forName("org.springframework.boot.context.properties.bind.Binder");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@
import io.shardingjdbc.core.exception.ShardingJdbcException;

public class PropertyUtil {

private static int springBootVersion = 1;

static {
try {
Class.forName("org.springframework.boot.bind.RelaxedPropertyResolver");
} catch (ClassNotFoundException e) {
springBootVersion = 2;
}
}

/**
* Spring Boot 1.x is compatible with Spring Boot 2.x by Using Java Reflect.
* @param environment : the environment context
Expand All @@ -50,13 +50,13 @@ public class PropertyUtil {
public static <T> T handle(final Environment environment, final String prefix, final Class<T> targetClass) {
switch (springBootVersion) {
case 1:
return (T) v1(environment, prefix, targetClass);
return (T) v1(environment, prefix);
default:
return (T) v2(environment, prefix, targetClass);
}
}

private static Object v1(final Environment environment, final String prefix, final Class<?> targetClass) {
private static Object v1(final Environment environment, final String prefix) {
try {
Class<?> resolverClass = Class.forName("org.springframework.boot.bind.RelaxedPropertyResolver");
Constructor<?> resolverConstructor = resolverClass.getDeclaredConstructor(PropertyResolver.class);
Expand All @@ -69,7 +69,7 @@ private static Object v1(final Environment environment, final String prefix, fin
throw new ShardingJdbcException(ex.getMessage(), ex);
}
}

private static Object v2(final Environment environment, final String prefix, final Class<?> targetClass) {
try {
Class<?> binderClass = Class.forName("org.springframework.boot.context.properties.bind.Binder");
Expand Down

0 comments on commit 4d04eef

Please sign in to comment.