I have an interface name Types
public interface Types
{
public String getName();
}
Two enum classes are extending this interface like
public enum AlphaTypes implements Types
{
Alpha("alpha"),Common("common")
private String name;
private AlphaTypes(String name)
{
this.name = name;
}
@Override
public String getName()
{
return name;
}
}
public enum BetaTypes implements Types
{
Beta("beta"),Common("common")
private String name;
private BetaTypes(String name)
{
this.name = name;
}
@Override
public String getName()
{
return name;
}
}
The requirement is have a map which takes Types as key
like Map<Types,Object> map;
How to implement equals and hashcode, such that the map keys are unique even for common enum values?