DataType implements Cloneable { @Override public boolean equals(Object o) { if (this == o) { return true; } else if (o == null || getClass() != o.getClass()) { return false; } DataType dataType = (DataType) o; if (scale != dataType.scale) { return false; } else if (type != dataType.type) { return false; } else if (name == null) { if (dataType.name != null) { return false; } } else if (!name.equals(dataType.name)) { return false; } return true; } DataType(int type);  DataType(int type, int scale);  DataType(String name);  DataType(String name, int scale);  DataType(int type, String name);  DataType(int type, String name, int scale); int getType(); void setType(int type); String getName(); void setName(String name); int getScale(); void setScale(int scale); @Override boolean equals(Object o); @Override int hashCode(); static final int UNKNOWN; static final int DEFAULT_SCALE; }
@Test public void equals_onSameInstance_returnsTrue() throws Exception { DataType varchar = new DataType(Types.VARCHAR, "VARCHAR", 255); assertTrue(varchar.equals(varchar)); }
@Test public void equals_withDifferentScale_returnsFalse() throws Exception { DataType varchar = new DataType(Types.VARCHAR, "VARCHAR", 255); DataType other = new DataType(Types.VARCHAR, "VARCHAR", 50); assertFalse(varchar.equals(other)); }
@Test public void equals_withUnknownScale_returnsTrue() throws Exception { DataType varchar = new DataType(Types.VARCHAR, "VARCHAR"); DataType other = new DataType(Types.VARCHAR, "VARCHAR"); assertTrue(varchar.equals(other)); }
@Test public void equals_withUnsetTypeName_returnsTrue() throws Exception { DataType varchar = new DataType(Types.VARCHAR); DataType other = new DataType(Types.VARCHAR); assertTrue(varchar.equals(other)); }
@Test public void equals_withUnknownType_returnsTrue() throws Exception { DataType varchar = new DataType("VARCHAR"); DataType other = new DataType("VARCHAR"); assertTrue(varchar.equals(other)); }
@Test public void equals_withUnknownType_disparateTypeName_returnsFalse() throws Exception { DataType varchar = new DataType("VARCHAR"); DataType other = new DataType("INTEGER"); assertFalse(varchar.equals(other)); }
@Test public void equals_withDisparateType_returnsFalse() throws Exception { DataType varchar = new DataType(Types.VARCHAR); DataType other = new DataType(Types.INTEGER); assertFalse(varchar.equals(other)); }