Proper equals on servers

This commit is contained in:
md_5
2013-04-12 08:22:17 +10:00
parent 5d1a2c59a7
commit 5592f81e97
5 changed files with 24 additions and 11 deletions

View File

@@ -4,6 +4,7 @@ import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Synchronized;
@@ -95,4 +96,19 @@ public abstract class ServerInfo
{
return !restricted || player.hasPermission( "bungeecord.server." + name );
}
@Override
public boolean equals(Object obj)
{
return ( obj instanceof ServerInfo ) && Objects.equals( getAddress(), ( (ServerInfo) obj ).getAddress() );
}
@Override
public int hashCode()
{
int hash = 7;
hash = 73 * hash + Objects.hashCode( getClass() );
hash = 73 * hash + Objects.hashCode( getAddress() );
return hash;
}
}