mirror of https://github.com/apache/lucene.git
SOLR-9071: rename the getters in org.apache.solr.common.util.Pair class
This commit is contained in:
parent
b42945ea92
commit
d57e0de5ea
|
@ -1493,10 +1493,10 @@ public class IndexSchema {
|
|||
return Stream.of(Handler.values())
|
||||
.filter(it -> name == null || it.nameLower.equals(name))
|
||||
.map(it -> new Pair<>(it.realName, it.fun.apply(this)))
|
||||
.filter(it->it.getValue() != null)
|
||||
.filter(it->it.second() != null)
|
||||
.collect(Collectors.toMap(
|
||||
Pair::getKey,
|
||||
Pair::getValue,
|
||||
Pair::first,
|
||||
Pair::second,
|
||||
(v1, v2) -> v2,
|
||||
LinkedHashMap::new));
|
||||
}
|
||||
|
|
|
@ -101,8 +101,8 @@ public class TestInjection {
|
|||
public static boolean injectRandomDelayInCoreCreation() {
|
||||
if (randomDelayInCoreCreation != null) {
|
||||
Pair<Boolean,Integer> pair = parseValue(randomDelayInCoreCreation);
|
||||
boolean enabled = pair.getKey();
|
||||
int chanceIn100 = pair.getValue();
|
||||
boolean enabled = pair.first();
|
||||
int chanceIn100 = pair.second();
|
||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||
int delay = RANDOM.nextInt(randomDelayMaxInCoreCreationInSec);
|
||||
log.info("Inject random core creation delay of {}s", delay);
|
||||
|
@ -119,8 +119,8 @@ public class TestInjection {
|
|||
public static boolean injectNonGracefullClose(CoreContainer cc) {
|
||||
if (cc.isShutDown() && nonGracefullClose != null) {
|
||||
Pair<Boolean,Integer> pair = parseValue(nonGracefullClose);
|
||||
boolean enabled = pair.getKey();
|
||||
int chanceIn100 = pair.getValue();
|
||||
boolean enabled = pair.first();
|
||||
int chanceIn100 = pair.second();
|
||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||
if (RANDOM.nextBoolean()) {
|
||||
throw new TestShutdownFailError("Test exception for non graceful close");
|
||||
|
@ -157,8 +157,8 @@ public class TestInjection {
|
|||
public static boolean injectFailReplicaRequests() {
|
||||
if (failReplicaRequests != null) {
|
||||
Pair<Boolean,Integer> pair = parseValue(failReplicaRequests);
|
||||
boolean enabled = pair.getKey();
|
||||
int chanceIn100 = pair.getValue();
|
||||
boolean enabled = pair.first();
|
||||
int chanceIn100 = pair.second();
|
||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, "Random test update fail");
|
||||
}
|
||||
|
@ -170,8 +170,8 @@ public class TestInjection {
|
|||
public static boolean injectFailUpdateRequests() {
|
||||
if (failUpdateRequests != null) {
|
||||
Pair<Boolean,Integer> pair = parseValue(failUpdateRequests);
|
||||
boolean enabled = pair.getKey();
|
||||
int chanceIn100 = pair.getValue();
|
||||
boolean enabled = pair.first();
|
||||
int chanceIn100 = pair.second();
|
||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||
throw new SolrException(ErrorCode.SERVER_ERROR, "Random test update fail");
|
||||
}
|
||||
|
@ -183,8 +183,8 @@ public class TestInjection {
|
|||
public static boolean injectNonExistentCoreExceptionAfterUnload(String cname) {
|
||||
if (nonExistentCoreExceptionAfterUnload != null) {
|
||||
Pair<Boolean,Integer> pair = parseValue(nonExistentCoreExceptionAfterUnload);
|
||||
boolean enabled = pair.getKey();
|
||||
int chanceIn100 = pair.getValue();
|
||||
boolean enabled = pair.first();
|
||||
int chanceIn100 = pair.second();
|
||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||
throw new NonExistentCoreException("Core not found to unload: " + cname);
|
||||
}
|
||||
|
@ -196,8 +196,8 @@ public class TestInjection {
|
|||
public static boolean injectUpdateLogReplayRandomPause() {
|
||||
if (updateLogReplayRandomPause != null) {
|
||||
Pair<Boolean,Integer> pair = parseValue(updateLogReplayRandomPause);
|
||||
boolean enabled = pair.getKey();
|
||||
int chanceIn100 = pair.getValue();
|
||||
boolean enabled = pair.first();
|
||||
int chanceIn100 = pair.second();
|
||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||
long rndTime = RANDOM.nextInt(1000);
|
||||
log.info("inject random log replay delay of {}ms", rndTime);
|
||||
|
@ -215,8 +215,8 @@ public class TestInjection {
|
|||
public static boolean injectUpdateRandomPause() {
|
||||
if (updateRandomPause != null) {
|
||||
Pair<Boolean,Integer> pair = parseValue(updateRandomPause);
|
||||
boolean enabled = pair.getKey();
|
||||
int chanceIn100 = pair.getValue();
|
||||
boolean enabled = pair.first();
|
||||
int chanceIn100 = pair.second();
|
||||
if (enabled && RANDOM.nextInt(100) >= (100 - chanceIn100)) {
|
||||
long rndTime = RANDOM.nextInt(1000);
|
||||
log.info("inject random update delay of {}ms", rndTime);
|
||||
|
|
|
@ -385,8 +385,8 @@ public class ZkStateReader implements Closeable {
|
|||
if (securityNodeListener != null) {
|
||||
addSecuritynodeWatcher(pair -> {
|
||||
ConfigData cd = new ConfigData();
|
||||
cd.data = pair.getKey() == null || pair.getKey().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.getKey()), 4, false);
|
||||
cd.version = pair.getValue() == null ? -1 : pair.getValue().getVersion();
|
||||
cd.data = pair.first() == null || pair.first().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.first()), 4, false);
|
||||
cd.version = pair.second() == null ? -1 : pair.second().getVersion();
|
||||
securityData = cd;
|
||||
securityNodeListener.run();
|
||||
});
|
||||
|
|
|
@ -17,30 +17,36 @@
|
|||
package org.apache.solr.common.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Pair<K, V> implements Serializable {
|
||||
private K key;
|
||||
public class Pair<T1, T2> implements Serializable {
|
||||
private final T1 first;
|
||||
private final T2 second;
|
||||
|
||||
public K getKey() {
|
||||
return key;
|
||||
public T1 first() {
|
||||
return first;
|
||||
}
|
||||
|
||||
private V value;
|
||||
|
||||
public K _1() {
|
||||
return key;
|
||||
public T2 second() {
|
||||
return second;
|
||||
}
|
||||
|
||||
public V _2() {
|
||||
return value;
|
||||
public Pair(T1 key, T2 value) {
|
||||
this.first = key;
|
||||
this.second = value;
|
||||
}
|
||||
|
||||
public V getValue() {
|
||||
return value;
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Pair) {
|
||||
Pair that = (Pair) obj;
|
||||
return Objects.equals(this.first, that.first) && Objects.equals(this.second, that.second);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Pair(K key, V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (this.first == null ? 0 : this.first.hashCode()) ^ (this.second == null ? 0 : this.second.hashCode());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue