001package co.codewizards.cloudstore.core.sync; 002 003import static java.util.Objects.*; 004 005import java.io.Serializable; 006import java.net.URL; 007import java.util.Date; 008 009import co.codewizards.cloudstore.core.Severity; 010import co.codewizards.cloudstore.core.dto.Error; 011 012@SuppressWarnings("serial") 013public class SyncState implements Serializable { 014 015 private final URL url; 016 017 private final Severity severity; 018 019 private final String message; 020 021 private final Error error; 022 023 private final Date syncStarted; 024 025 private final Date syncFinished; 026 027 public SyncState(final URL url, final Severity severity, final String message, final Error error, final Date syncStarted, final Date syncFinished) { 028 this.url = requireNonNull(url, "url"); 029 this.severity = requireNonNull(severity, "severity"); 030 this.message = message; 031 this.error = error; 032 this.syncStarted = requireNonNull(syncStarted, "syncStarted"); 033 this.syncFinished = requireNonNull(syncFinished, "syncFinished"); 034 } 035 036 /** 037 * Gets the URL that was used for the sync. 038 * @return the URL that was used for the sync. 039 */ 040 public URL getUrl() { 041 return url; 042 } 043 044 public Severity getSeverity() { 045 return severity; 046 } 047 048 public String getMessage() { 049 return message; 050 } 051 052 public Error getError() { 053 return error; 054 } 055 056 /** 057 * Gets the timestamp when the sync referenced by this {@code SyncState} stared. 058 * @return the timestamp when the sync started. Never <code>null</code>. 059 */ 060 public Date getSyncStarted() { 061 return syncStarted; 062 } 063 064 /** 065 * Gets the timestamp when the sync referenced by this {@code SyncState} finished. 066 * <p> 067 * Please note: This does not say anything about whether or not it completed (successfully). 068 * If there was an error, the {@link #getError() error} property is not <code>null</code>. 069 * @return the timestamp when the sync finished. Never <code>null</code>. 070 */ 071 public Date getSyncFinished() { 072 return syncFinished; 073 } 074}