Browse Source

重命名以及修改

master
richie 5 years ago
parent
commit
974253f240
  1. 2
      pom.xml
  2. 4
      src/main/java/com/fanruan/api/data/ConnectionKit.java
  3. 2
      src/main/java/com/fanruan/api/util/TypeKit.java
  4. 19
      src/test/java/com/fanruan/api/util/ReflectKitTest.java
  5. 19
      src/test/java/com/fanruan/api/util/TypeKitTest.java

2
pom.xml

@ -6,7 +6,7 @@
<version>10.0</version>
<packaging>jar</packaging>
<properties>
<common-version>10.0-PERSIST-SNAPSHOT</common-version>
<common-version>10.0-FEATURE-SNAPSHOT</common-version>
<maven.build.timestamp.format>yyyyMMdd</maven.build.timestamp.format>
<build-version>${version}</build-version>
<build-no>${maven.build.timestamp}</build-no>

4
src/main/java/com/fanruan/api/data/ConnectionKit.java

@ -1,6 +1,6 @@
package com.fanruan.api.data;
import com.fanruan.api.util.ReflectKit;
import com.fanruan.api.util.TypeKit;
import com.fr.data.impl.Connection;
import com.fr.file.ConnectionConfig;
import org.jetbrains.annotations.NotNull;
@ -30,7 +30,7 @@ public class ConnectionKit {
*/
public <T extends Connection> @Nullable T getConnection(@NotNull String name, Class<? extends Connection> type) {
Connection connection = getConnection(name);
if (ReflectKit.objectInstanceOf(connection, type)) {
if (TypeKit.objectInstanceOf(connection, type)) {
return (T) connection;
}
return null;

2
src/main/java/com/fanruan/api/util/ReflectKit.java → src/main/java/com/fanruan/api/util/TypeKit.java

@ -1,6 +1,6 @@
package com.fanruan.api.util;
public class ReflectKit {
public class TypeKit {
/**
* 判读指定的类是否是另一个类的子类

19
src/test/java/com/fanruan/api/util/ReflectKitTest.java

@ -1,19 +0,0 @@
package com.fanruan.api.util;
import org.junit.Assert;
import org.junit.Test;
public class ReflectKitTest {
@Test
public void classInstanceOf() {
Assert.assertTrue(ReflectKit.classInstanceOf(Integer.class, Object.class));
Assert.assertFalse(ReflectKit.classInstanceOf(Object.class, Integer.class));
}
@Test
public void objectInstanceOf() {
Assert.assertTrue(ReflectKit.objectInstanceOf(1, Integer.class));
Assert.assertFalse(ReflectKit.objectInstanceOf(1.0, Integer.class));
}
}

19
src/test/java/com/fanruan/api/util/TypeKitTest.java

@ -0,0 +1,19 @@
package com.fanruan.api.util;
import org.junit.Assert;
import org.junit.Test;
public class TypeKitTest {
@Test
public void classInstanceOf() {
Assert.assertTrue(TypeKit.classInstanceOf(Integer.class, Object.class));
Assert.assertFalse(TypeKit.classInstanceOf(Object.class, Integer.class));
}
@Test
public void objectInstanceOf() {
Assert.assertTrue(TypeKit.objectInstanceOf(1, Integer.class));
Assert.assertFalse(TypeKit.objectInstanceOf(1.0, Integer.class));
}
}
Loading…
Cancel
Save