74 lines
3.0 KiB
Diff
74 lines
3.0 KiB
Diff
From 72d003605170af32c20b72caff4ab35f3a40b254 Mon Sep 17 00:00:00 2001
|
|
From: fanmenggang <fanmenggang@huawei.com>
|
|
Date: Wed, 8 May 2019 16:15:56 +0000
|
|
Subject: [PATCH] hamcrest: eliminate class file differences
|
|
|
|
reason: eliminate class file differences
|
|
|
|
diff --git a/hamcrest-generator/src/main/java/org/hamcrest/generator/ReflectiveFactoryReader.java b/hamcrest-generator/src/main/java/org/hamcrest/generator/ReflectiveFactoryReader.java
|
|
index f51e659..5fa1c8f 100644
|
|
--- a/hamcrest-generator/src/main/java/org/hamcrest/generator/ReflectiveFactoryReader.java
|
|
+++ b/hamcrest-generator/src/main/java/org/hamcrest/generator/ReflectiveFactoryReader.java
|
|
@@ -42,8 +42,8 @@ public class ReflectiveFactoryReader implements Iterable<FactoryMethod> {
|
|
return new Iterator<FactoryMethod>() {
|
|
|
|
private int currentMethod = -1;
|
|
- private Method[] allMethods = cls.getMethods();
|
|
-
|
|
+ private Method[] tmpMethods = cls.getMethods();
|
|
+ private Method[] allMethods = sort(tmpMethods,0,tmpMethods.length - 1);
|
|
@Override
|
|
public boolean hasNext() {
|
|
while (true) {
|
|
@@ -72,6 +72,43 @@ public class ReflectiveFactoryReader implements Iterable<FactoryMethod> {
|
|
private boolean outsideArrayBounds() {
|
|
return currentMethod < 0 || allMethods.length <= currentMethod;
|
|
}
|
|
+
|
|
+ private Method[] sort(Method[] method, int low, int high) {
|
|
+ int start = low;
|
|
+ int end = high;
|
|
+ String key = method[low].toString();
|
|
+
|
|
+ while(end > start) {
|
|
+ while(end > start && method[end].toString().compareTo(key) >= 0) {
|
|
+ end--;
|
|
+ }
|
|
+
|
|
+ if(end > start) {
|
|
+ Method temp = method[end];
|
|
+ method[end] = method[start];
|
|
+ method[start] = temp;
|
|
+ start++;
|
|
+ }
|
|
+
|
|
+ while(start < end && method[start].toString().compareTo(key) <= 0) {
|
|
+ start++;
|
|
+ }
|
|
+
|
|
+ if(start < end ) {
|
|
+ Method temp = method[end];
|
|
+ method[end] = method[start];
|
|
+ method[start] = temp;
|
|
+ end--;
|
|
+ }
|
|
+ }
|
|
+ if(start > low) {
|
|
+ sort(method,low, start - 1);
|
|
+ }
|
|
+ if(end < high) {
|
|
+ sort(method,start + 1, high);
|
|
+ }
|
|
+ return method;
|
|
+ }
|
|
};
|
|
}
|
|
|
|
@@ -171,4 +208,4 @@ public class ReflectiveFactoryReader implements Iterable<FactoryMethod> {
|
|
return name.replace('$', '.');
|
|
}
|
|
|
|
-}
|
|
\ No newline at end of file
|
|
+}
|