org.fluentjdbc.DatabaseSaveResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluent-jdbc Show documentation
Show all versions of fluent-jdbc Show documentation
A Java library used to execute JDBC statements and build SQL
package org.fluentjdbc;
import javax.annotation.Nonnull;
import java.util.Objects;
public class DatabaseSaveResult {
private final T idValue;
private final SaveStatus saveStatus;
private DatabaseSaveResult(T idValue, SaveStatus saveStatus) {
this.idValue = idValue;
this.saveStatus = saveStatus;
}
public static DatabaseSaveResult updated(@Nonnull T idValue) {
return new DatabaseSaveResult<>(idValue, SaveStatus.UPDATED);
}
public static DatabaseSaveResult inserted(@Nonnull T idValue) {
return new DatabaseSaveResult<>(idValue, SaveStatus.INSERTED);
}
public static DatabaseSaveResult deleted(@Nonnull T idValue) {
return new DatabaseSaveResult<>(idValue, SaveStatus.DELETED);
}
public static DatabaseSaveResult unchanged(@Nonnull T idValue) {
return new DatabaseSaveResult<>(idValue, SaveStatus.UNCHANGED);
}
public T getId() {
return idValue;
}
public SaveStatus getSaveStatus() {
return saveStatus;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DatabaseSaveResult> that = (DatabaseSaveResult>) o;
return Objects.equals(idValue, that.idValue) &&
saveStatus == that.saveStatus;
}
@Override
public int hashCode() {
return Objects.hash(idValue, saveStatus);
}
@Override
public String toString() {
return getClass().getSimpleName() + "{idValue=" + idValue + ", saveStatus=" + saveStatus + '}';
}
public enum SaveStatus {
INSERTED, UNCHANGED, DELETED, UPDATED
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy