|
|
|
package com.fr.plugin.db.redis.core;
|
|
|
|
|
|
|
|
import com.fanruan.api.conf.HolderKit;
|
|
|
|
import com.fanruan.api.conf.BaseUniqueKey;
|
|
|
|
import com.fanruan.api.util.AssistKit;
|
|
|
|
import com.fanruan.api.util.StringKit;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author richie
|
|
|
|
* @version 10.0
|
|
|
|
* Created by richie on 2019-03-22
|
|
|
|
*/
|
|
|
|
public class RedisNode extends BaseUniqueKey {
|
|
|
|
|
|
|
|
public static final int DEFAULT_REDIS_PORT = 6379;
|
|
|
|
|
|
|
|
private HolderKit.Conf<String> host = HolderKit.simple(StringKit.EMPTY);
|
|
|
|
private HolderKit.Conf<Integer> port = HolderKit.simple(DEFAULT_REDIS_PORT);
|
|
|
|
private HolderKit.Conf<String> password = HolderKit.simple(StringKit.EMPTY);
|
|
|
|
|
|
|
|
public RedisNode(String host, int port, String password) {
|
|
|
|
this.setHost(host);
|
|
|
|
this.setPort(port);
|
|
|
|
this.setPassword(password);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getHost() {
|
|
|
|
return host.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setHost(String host) {
|
|
|
|
this.host.set(host);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPort() {
|
|
|
|
return port.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPort(int port) {
|
|
|
|
this.port.set(port);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getPassword() {
|
|
|
|
return password.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPassword(String password) {
|
|
|
|
this.password.set(password);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
return obj instanceof RedisNode
|
|
|
|
&& AssistKit.equals(((RedisNode) obj).getHost(), getHost())
|
|
|
|
&& ((RedisNode) obj).getPort() == getPort()
|
|
|
|
&& AssistKit.equals(((RedisNode) obj).getPassword(), getPassword());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return AssistKit.hashCode(getHost(), getPort(), getPassword());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object clone() throws CloneNotSupportedException {
|
|
|
|
RedisNode cloned = (RedisNode) super.clone();
|
|
|
|
cloned.host = (HolderKit.Conf<String>) host.clone();
|
|
|
|
cloned.port = (HolderKit.Conf<Integer>) port.clone();
|
|
|
|
cloned.password = (HolderKit.Conf<String>) password.clone();
|
|
|
|
return cloned;
|
|
|
|
}
|
|
|
|
}
|