This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new c9fcda2f5d9 Remove unused methods in ReflectionUtil (#19260)
c9fcda2f5d9 is described below
commit c9fcda2f5d98d4bf13f52d004fff5a347598e8d3
Author: Hongsheng Zhong <[email protected]>
AuthorDate: Sat Jul 16 14:54:53 2022 +0800
Remove unused methods in ReflectionUtil (#19260)
---
.../data/pipeline/core/util/ReflectionUtil.java | 24 ----------------------
.../pipeline/core/util/ReflectionUtilTest.java | 8 --------
2 files changed, 32 deletions(-)
diff --git
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtil.java
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtil.java
index 80b3f6b2a50..80a7bb279e2 100644
---
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtil.java
+++
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtil.java
@@ -68,30 +68,6 @@ public final class ReflectionUtil {
throw new ClassCastException("field " + fieldName + " is " +
value.getClass().getName() + " can cast to " + valueClass.getName());
}
- /**
- * Get static field value.
- *
- * @param targetClass target class
- * @param fieldName field name
- * @param valueClass expected value class
- * @param <T> expected value class
- * @return target filed value
- * @throws NoSuchFieldException no such field exception
- * @throws IllegalAccessException illegal access exception
- */
- @SuppressWarnings("unchecked")
- public static <T> T getStaticFieldValue(final Class<?> targetClass, final
String fieldName, final Class<T> valueClass) throws NoSuchFieldException,
IllegalAccessException {
- Field field = getField(targetClass, fieldName, true);
- Object value = field.get(null);
- if (null == value) {
- return null;
- }
- if (valueClass.isAssignableFrom(value.getClass())) {
- return (T) value;
- }
- throw new ClassCastException("field " + fieldName + " is " +
value.getClass().getName() + " can cast to " + valueClass.getName());
- }
-
private static Field getField(final Class<?> targetClass, final String
fieldName, final boolean isDeclared) throws NoSuchFieldException {
Field result = isDeclared ? targetClass.getDeclaredField(fieldName) :
targetClass.getField(fieldName);
result.setAccessible(true);
diff --git
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtilTest.java
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtilTest.java
index 32bc5932ed8..161cee7b5af 100644
---
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtilTest.java
+++
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/util/ReflectionUtilTest.java
@@ -42,11 +42,6 @@ public final class ReflectionUtilTest {
assertThat(ReflectionUtil.getFieldValue(reflectionFixture, "value",
String.class), is("bar"));
}
- @Test
- public void assertGetStaticFieldValue() throws NoSuchFieldException,
IllegalAccessException {
- assertThat(ReflectionUtil.getStaticFieldValue(ReflectionFixture.class,
"STATIC_VALUE", String.class), is("static_value"));
- }
-
@Test
public void assertInvokeMethod() throws Exception {
ReflectionFixture reflectionFixture = new ReflectionFixture();
@@ -58,9 +53,6 @@ public final class ReflectionUtilTest {
@NoArgsConstructor
private static final class ReflectionFixture {
- @SuppressWarnings("unused")
- private static final String STATIC_VALUE = "static_value";
-
@Getter
@Setter(AccessLevel.PRIVATE)
private String value;