mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-04 20:45:52 +01:00
Cleanup and fix hash code and equals
This commit is contained in:
@@ -48,8 +48,7 @@ public class BlameResult implements Serializable, Iterable<BlameLine> {
|
||||
private int total;
|
||||
|
||||
public BlameResult(List<BlameLine> blameLines) {
|
||||
this.blameLines = blameLines;
|
||||
this.total = blameLines.size();
|
||||
this(blameLines.size(), blameLines);
|
||||
}
|
||||
|
||||
public BlameResult(int total, List<BlameLine> blameLines) {
|
||||
|
||||
@@ -48,8 +48,6 @@ public final class Branches implements Iterable<Branch> {
|
||||
public Branches() {
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public Branches(Branch... branches) {
|
||||
this.branches = Lists.newArrayList(branches);
|
||||
}
|
||||
@@ -63,7 +61,6 @@ public final class Branches implements Iterable<Branch> {
|
||||
return getBranches().iterator();
|
||||
}
|
||||
|
||||
|
||||
public List<Branch> getBranches() {
|
||||
if (branches == null) {
|
||||
branches = Lists.newArrayList();
|
||||
@@ -71,4 +68,8 @@ public final class Branches implements Iterable<Branch> {
|
||||
|
||||
return branches;
|
||||
}
|
||||
|
||||
public void setBranches(List<Branch> branches) {
|
||||
this.branches = branches;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,6 @@ public class BrowserResult implements Serializable {
|
||||
public BrowserResult() {
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public BrowserResult(String revision, FileObject file) {
|
||||
this(revision, revision, file);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class Changeset extends BasicPropertiesAware implements ModelObject {
|
||||
*/
|
||||
public List<String> getBranches() {
|
||||
if (branches == null) {
|
||||
branches = new ArrayList<String>();
|
||||
branches = new ArrayList<>();
|
||||
}
|
||||
|
||||
return branches;
|
||||
@@ -206,7 +206,7 @@ public class Changeset extends BasicPropertiesAware implements ModelObject {
|
||||
*/
|
||||
public List<String> getParents() {
|
||||
if (parents == null) {
|
||||
parents = new ArrayList<String>();
|
||||
parents = new ArrayList<>();
|
||||
}
|
||||
|
||||
return parents;
|
||||
@@ -219,7 +219,7 @@ public class Changeset extends BasicPropertiesAware implements ModelObject {
|
||||
*/
|
||||
public List<String> getTags() {
|
||||
if (tags == null) {
|
||||
tags = new ArrayList<String>();
|
||||
tags = new ArrayList<>();
|
||||
}
|
||||
|
||||
return tags;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -37,6 +37,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class ChangesetPagingResult implements Iterable<Changeset>, Serializable {
|
||||
|
||||
@@ -71,27 +72,6 @@ public class ChangesetPagingResult implements Iterable<Changeset>, Serializable
|
||||
this.branchName = branchName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ChangesetPagingResult other = (ChangesetPagingResult) obj;
|
||||
|
||||
return Objects.equal(changesets, other.changesets)
|
||||
&& Objects.equal(total, other.total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(changesets, total);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator which can iterate over the current list of changesets.
|
||||
*
|
||||
|
||||
@@ -50,8 +50,6 @@ public class Modifications implements Serializable {
|
||||
public Modifications() {
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public Modifications(List<String> added) {
|
||||
this(added, null, null);
|
||||
}
|
||||
|
||||
@@ -46,8 +46,6 @@ public class SubRepository implements Serializable {
|
||||
public SubRepository() {
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public SubRepository(String repositoryUrl) {
|
||||
this.repositoryUrl = repositoryUrl;
|
||||
}
|
||||
|
||||
@@ -39,11 +39,8 @@ import lombok.ToString;
|
||||
@Getter
|
||||
public final class Tag {
|
||||
|
||||
private String name;
|
||||
private String revision;
|
||||
|
||||
public Tag() {
|
||||
}
|
||||
private final String name;
|
||||
private final String revision;
|
||||
|
||||
/**
|
||||
* Constructs a new tag.
|
||||
|
||||
@@ -48,8 +48,6 @@ public final class Tags implements Iterable<Tag> {
|
||||
public Tags() {
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public Tags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
@@ -21,14 +21,17 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.17
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class BlameCommandRequest extends FileBaseCommandRequest
|
||||
{
|
||||
|
||||
|
||||
@@ -21,13 +21,11 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import sonia.scm.repository.BrowserResult;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@@ -37,6 +35,8 @@ import java.util.function.Consumer;
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.17
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString
|
||||
public final class BrowseCommandRequest extends FileBaseCommandRequest
|
||||
{
|
||||
|
||||
@@ -53,14 +53,6 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest
|
||||
this.updater = updater;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public BrowseCommandRequest clone()
|
||||
{
|
||||
@@ -80,74 +72,6 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getClass() != obj.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final BrowseCommandRequest other = (BrowseCommandRequest) obj;
|
||||
|
||||
return super.equals(obj)
|
||||
&& Objects.equal(recursive, other.recursive)
|
||||
&& Objects.equal(disableLastCommit, other.disableLastCommit)
|
||||
&& Objects.equal(disableSubRepositoryDetection, other.disableSubRepositoryDetection)
|
||||
&& Objects.equal(offset, other.offset)
|
||||
&& Objects.equal(limit, other.limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(super.hashCode(), recursive, disableLastCommit,
|
||||
disableSubRepositoryDetection, offset, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
//J-
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("path", getPath())
|
||||
.add("revision", getRevision())
|
||||
.add("recursive", recursive)
|
||||
.add("disableLastCommit", disableLastCommit)
|
||||
.add("disableSubRepositoryDetection", disableSubRepositoryDetection)
|
||||
.add("limit", limit)
|
||||
.add("offset", offset)
|
||||
.toString();
|
||||
//J+
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* True to disable the last commit.
|
||||
*
|
||||
@@ -292,5 +216,6 @@ public final class BrowseCommandRequest extends FileBaseCommandRequest
|
||||
|
||||
// WARNING / TODO: This field creates a reverse channel from the implementation to the API. This will break
|
||||
// whenever the API runs in a different process than the SPI (for example to run explicit hosts for git repositories).
|
||||
@EqualsAndHashCode.Exclude
|
||||
private final transient Consumer<BrowserResult> updater;
|
||||
}
|
||||
|
||||
@@ -21,14 +21,17 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.17
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class CatCommandRequest extends FileBaseCommandRequest
|
||||
{
|
||||
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import sonia.scm.Validateable;
|
||||
import sonia.scm.repository.api.DiffFormat;
|
||||
|
||||
@@ -36,21 +36,12 @@ import sonia.scm.repository.api.DiffFormat;
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.17
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class DiffCommandRequest extends FileBaseCommandRequest
|
||||
implements Validateable
|
||||
{
|
||||
implements Validateable {
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = 4026911212676859626L;
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DiffCommandRequest clone()
|
||||
{
|
||||
@@ -70,14 +61,6 @@ public final class DiffCommandRequest extends FileBaseCommandRequest
|
||||
return clone;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
@@ -85,8 +68,6 @@ public final class DiffCommandRequest extends FileBaseCommandRequest
|
||||
||!Strings.isNullOrEmpty(getRevision());
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sets the diff format which should be used for the output.
|
||||
*
|
||||
@@ -103,7 +84,6 @@ public final class DiffCommandRequest extends FileBaseCommandRequest
|
||||
public void setAncestorChangeset(String ancestorChangeset) {
|
||||
this.ancestorChangeset = ancestorChangeset;
|
||||
}
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return the output format of the diff command.
|
||||
@@ -121,7 +101,6 @@ public final class DiffCommandRequest extends FileBaseCommandRequest
|
||||
public String getAncestorChangeset() {
|
||||
return ancestorChangeset;
|
||||
}
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** diff format */
|
||||
private DiffFormat format = DiffFormat.NATIVE;
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -38,54 +38,14 @@ import java.io.Serializable;
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.17
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public abstract class FileBaseCommandRequest
|
||||
implements Resetable, Serializable, Cloneable
|
||||
{
|
||||
implements Resetable, Serializable, Cloneable {
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = -3442101119408346165L;
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getClass() != obj.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final FileBaseCommandRequest other = (FileBaseCommandRequest) obj;
|
||||
|
||||
return Objects.equal(path, other.path)
|
||||
&& Objects.equal(revision, other.revision);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(path, revision);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -97,81 +57,26 @@ public abstract class FileBaseCommandRequest
|
||||
revision = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
//J-
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("path", path)
|
||||
.add("revision", revision)
|
||||
.toString();
|
||||
//J+
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param revision
|
||||
*/
|
||||
public void setRevision(String revision)
|
||||
{
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getRevision()
|
||||
{
|
||||
return revision;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws CloneNotSupportedException
|
||||
*/
|
||||
@Override
|
||||
protected FileBaseCommandRequest clone() throws CloneNotSupportedException
|
||||
{
|
||||
@@ -192,11 +97,7 @@ public abstract class FileBaseCommandRequest
|
||||
return clone;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String path;
|
||||
|
||||
/** Field description */
|
||||
private String revision;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user