com.dmj.sqldsl.model.column.SimpleColumn Maven / Gradle / Ivy
package com.dmj.sqldsl.model.column;
import java.util.Optional;
public class SimpleColumn implements Column {
private final String tableName;
private String fieldName;
private final String columnName;
public Optional getTableName() {
return Optional.ofNullable(tableName);
}
@Override
public String getFieldName() {
return Optional.ofNullable(fieldName).orElse(columnName);
}
SimpleColumn(final String tableName, final String fieldName, final String columnName) {
this.tableName = tableName;
this.fieldName = fieldName;
this.columnName = columnName;
}
public static class SimpleColumnBuilder {
private String tableName;
private String fieldName;
private String columnName;
SimpleColumnBuilder() {
}
/**
* @return {@code this}.
*/
public SimpleColumn.SimpleColumnBuilder tableName(final String tableName) {
this.tableName = tableName;
return this;
}
/**
* @return {@code this}.
*/
public SimpleColumn.SimpleColumnBuilder fieldName(final String fieldName) {
this.fieldName = fieldName;
return this;
}
/**
* @return {@code this}.
*/
public SimpleColumn.SimpleColumnBuilder columnName(final String columnName) {
this.columnName = columnName;
return this;
}
public SimpleColumn build() {
return new SimpleColumn(this.tableName, this.fieldName, this.columnName);
}
@Override
public String toString() {
return "SimpleColumn.SimpleColumnBuilder(tableName=" + this.tableName + ", fieldName=" + this.fieldName + ", columnName=" + this.columnName + ")";
}
}
public static SimpleColumn.SimpleColumnBuilder builder() {
return new SimpleColumn.SimpleColumnBuilder();
}
@Override
public boolean equals(final Object o) {
if (o == this) return true;
if (!(o instanceof SimpleColumn)) return false;
final SimpleColumn other = (SimpleColumn) o;
if (!other.canEqual((Object) this)) return false;
final Object this$tableName = this.getTableName();
final Object other$tableName = other.getTableName();
if (this$tableName == null ? other$tableName != null : !this$tableName.equals(other$tableName)) return false;
final Object this$fieldName = this.getFieldName();
final Object other$fieldName = other.getFieldName();
if (this$fieldName == null ? other$fieldName != null : !this$fieldName.equals(other$fieldName)) return false;
final Object this$columnName = this.getColumnName();
final Object other$columnName = other.getColumnName();
if (this$columnName == null ? other$columnName != null : !this$columnName.equals(other$columnName)) return false;
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof SimpleColumn;
}
@Override
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $tableName = this.getTableName();
result = result * PRIME + ($tableName == null ? 43 : $tableName.hashCode());
final Object $fieldName = this.getFieldName();
result = result * PRIME + ($fieldName == null ? 43 : $fieldName.hashCode());
final Object $columnName = this.getColumnName();
result = result * PRIME + ($columnName == null ? 43 : $columnName.hashCode());
return result;
}
public String getColumnName() {
return this.columnName;
}
}