Alachisoft.NCache.Common.Monitoring.Node Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-common Show documentation
Show all versions of nc-common Show documentation
Internal package of Alachisoft.
package Alachisoft.NCache.Common.Monitoring;
import Alachisoft.NCache.Common.Common;
import Alachisoft.NCache.Common.Net.Address;
import com.alachisoft.ncache.serialization.core.io.InternalCompactSerializable;
import com.alachisoft.ncache.serialization.standard.io.CompactReader;
import com.alachisoft.ncache.serialization.standard.io.CompactWriter;
import java.io.IOException;
/**
* Node represent a physical machine participating either as server or client.
*/
public class Node implements InternalCompactSerializable {
private String _name;
private Address _address;
public Node() {
}
public Node(String name, Address address) {
setName(name);
setAddress(address);
}
/**
* Gets/Sets the name of the node.
*/
public final String getName() {
return _name;
}
public final void setName(String value) {
if (value != null) {
_name = value.toLowerCase();
}
}
/**
* Gets/Sets the IPAddress of the node.
*/
public final Address getAddress() {
return _address;
}
public final void setAddress(Address value) {
_address = value;
}
@Override
public boolean equals(Object obj) {
Node other = (Node) ((obj instanceof Node) ? obj : null);
boolean equal = false;
if (other != null) {
if (getName() == null && other.getName() == null) {
equal = true;
}
//if (Name != null && other.Name != null && Name = other.Name)
// equal = true;
if (equal) {
equal = false;
if (getAddress() == null && other.getAddress() == null) {
equal = true;
}
if (getAddress() != null && other.getAddress() != null && getAddress().equals(other.getAddress())) {
equal = true;
}
}
}
return equal;
}
public void Deserialize(CompactReader reader) throws IOException, ClassNotFoundException {
_name = (String) Common.readAs(reader.ReadObject(), String.class);
_address = (Address) Common.readAs(reader.ReadObject(), Address.class);
}
public void Serialize(CompactWriter writer) throws IOException {
writer.WriteObject(_name);
writer.WriteObject(_address);
}
}