org.zodiac.rocketmq.client.config.RegistrarStrategy Maven / Gradle / Ivy
The newest version!
package org.zodiac.rocketmq.client.config;
import java.util.HashMap;
import java.util.Map;
public enum RegistrarStrategy {
SEQUENTIAL(1),
PARALLEL(2),
;
private final int strategy;
private RegistrarStrategy(int strategy) {
this.strategy = strategy;
RegisterStrategyHolder.STRATEGY_REGISTER_STRATEGY_MAPPING.put(this.strategy, this);
}
public int getStrategy() {
return strategy;
}
public static RegistrarStrategy ofStrategy(Integer strategy) {
return null == strategy ? null : RegisterStrategyHolder.STRATEGY_REGISTER_STRATEGY_MAPPING.get(strategy);
}
public static RegistrarStrategy ofStrategy(int strategy) {
return RegisterStrategyHolder.STRATEGY_REGISTER_STRATEGY_MAPPING.get(strategy);
}
private static class RegisterStrategyHolder {
private static final Map STRATEGY_REGISTER_STRATEGY_MAPPING = new HashMap<>();
}
}