forked from fanruan/demo-tabledata-redis
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.9 KiB
73 lines
1.9 KiB
package com.fr.plugin.db.redis.core; |
|
|
|
import com.fr.config.holder.Conf; |
|
import com.fr.config.holder.factory.Holders; |
|
import com.fr.config.utils.UniqueKey; |
|
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 UniqueKey { |
|
|
|
public static final int DEFAULT_REDIS_PORT = 6379; |
|
|
|
private Conf<String> host = Holders.simple(StringKit.EMPTY); |
|
private Conf<Integer> port = Holders.simple(DEFAULT_REDIS_PORT); |
|
private Conf<String> password = Holders.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 = (Conf<String>) host.clone(); |
|
cloned.port = (Conf<Integer>) port.clone(); |
|
cloned.password = (Conf<String>) password.clone(); |
|
return cloned; |
|
} |
|
}
|
|
|