-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sirixdb/master
updating my fork
- Loading branch information
Showing
10 changed files
with
326 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
bundles/sirix-core/src/main/java/org/sirix/api/RevisionInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package org.sirix.api; | ||
|
||
import static com.google.common.base.Preconditions.checkArgument; | ||
import static com.google.common.base.Preconditions.checkNotNull; | ||
import java.time.Instant; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import org.sirix.access.User; | ||
import com.google.common.base.MoreObjects; | ||
|
||
public final class RevisionInfo { | ||
private final User user; | ||
|
||
private final int revision; | ||
|
||
private final Instant revisionTimestamp; | ||
|
||
private final String commitMessage; | ||
|
||
private int hash; | ||
|
||
public RevisionInfo(final User user, final int revision, final Instant revisionTimestamp, | ||
final String commitMessage) { | ||
this.user = checkNotNull(user); | ||
|
||
checkArgument(revision >= 0); | ||
|
||
this.revision = revision; | ||
this.revisionTimestamp = checkNotNull(revisionTimestamp); | ||
this.commitMessage = commitMessage; | ||
} | ||
|
||
public User getUser() { | ||
return user; | ||
} | ||
|
||
public int getRevision() { | ||
return revision; | ||
} | ||
|
||
public Instant getRevisionTimestamp() { | ||
return revisionTimestamp; | ||
} | ||
|
||
public Optional<String> getCommitMessage() { | ||
return Optional.ofNullable(commitMessage); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
if (hash == 0) { | ||
hash = Objects.hash(user, revision, revisionTimestamp, commitMessage); | ||
} | ||
return hash; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object other) { | ||
if (!(other instanceof RevisionInfo)) | ||
return false; | ||
|
||
final RevisionInfo otherRevisionInfo = (RevisionInfo) other; | ||
|
||
return this.user == otherRevisionInfo.user && this.revision == otherRevisionInfo.revision | ||
&& revisionTimestamp.equals(otherRevisionInfo.revisionTimestamp) | ||
&& Objects.equals(this.commitMessage, otherRevisionInfo.commitMessage); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.add("user", user) | ||
.add("revision", revision) | ||
.add("revisionTimestamp", revisionTimestamp) | ||
.add("commitMessage", commitMessage) | ||
.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.