diff --git a/scm-core/src/main/java/sonia/scm/repository/BlameResult.java b/scm-core/src/main/java/sonia/scm/repository/BlameResult.java index 5002dfc34e..50d4db6c28 100644 --- a/scm-core/src/main/java/sonia/scm/repository/BlameResult.java +++ b/scm-core/src/main/java/sonia/scm/repository/BlameResult.java @@ -21,216 +21,59 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.collect.Lists; +import lombok.EqualsAndHashCode; +import lombok.ToString; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; import java.util.Iterator; import java.util.List; -//~--- JDK imports ------------------------------------------------------------ - /** * Changeset information by line for a given file. * * @author Sebastian Sdorra * @since 1.8 */ -@XmlRootElement(name = "blame-result") -@XmlAccessorType(XmlAccessType.FIELD) -public class BlameResult implements Serializable, Iterable -{ +@EqualsAndHashCode +@ToString +public class BlameResult implements Serializable, Iterable { - /** Field description */ private static final long serialVersionUID = -8606237881465520606L; - //~--- constructors --------------------------------------------------------- + private List blameLines; + private int total; - /** - * Constructs ... - * - */ - public BlameResult() {} - - /** - * Constructs ... - * - * - * @param blameLines - */ - public BlameResult(List blameLines) - { + public BlameResult(List blameLines) { this.blameLines = blameLines; this.total = blameLines.size(); } - /** - * Constructs ... - * - * - * @param total - * @param blameLines - */ - public BlameResult(int total, List blameLines) - { + public BlameResult(int total, List blameLines) { this.total = total; this.blameLines = blameLines; } - //~--- methods -------------------------------------------------------------- - - /** - * {@inheritDoc} - * - * - * @param obj - * - * @return - */ @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - final BlameResult other = (BlameResult) obj; - - return Objects.equal(total, other.total) - && Objects.equal(blameLines, other.blameLines); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public int hashCode() - { - return Objects.hashCode(total, blameLines); - } - - /** - * Method description - * - * - * @return - * - * @since 1.17 - */ - @Override - public Iterator iterator() - { + public Iterator iterator() { return getBlameLines().iterator(); } - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public String toString() - { - //J- - return MoreObjects.toStringHelper(this) - .add("total", total) - .add("blameLines", blameLines) - .toString(); - //J+ - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public List getBlameLines() - { - if ( blameLines == null ){ + public List getBlameLines() { + if (blameLines == null) { blameLines = Lists.newArrayList(); } return blameLines; } - /** - * Method description - * - * - * @param i - * - * @return - */ - public BlameLine getLine(int i) - { + public BlameLine getLine(int i) { return blameLines.get(i); } - /** - * Method description - * - * - * @return - */ - public int getTotal() - { + public int getTotal() { return total; } - - //~--- set methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param blameLines - */ - public void setBlameLines(List blameLines) - { - this.blameLines = blameLines; - } - - /** - * Method description - * - * - * @param total - */ - public void setTotal(int total) - { - this.total = total; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - @XmlElement(name = "blameline") - @XmlElementWrapper(name = "blamelines") - private List blameLines; - - /** Field description */ - private int total; } diff --git a/scm-core/src/main/java/sonia/scm/repository/Branches.java b/scm-core/src/main/java/sonia/scm/repository/Branches.java index 54b285d143..430290fbd8 100644 --- a/scm-core/src/main/java/sonia/scm/repository/Branches.java +++ b/scm-core/src/main/java/sonia/scm/repository/Branches.java @@ -21,166 +21,54 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.collect.Lists; +import lombok.EqualsAndHashCode; +import lombok.Setter; +import lombok.ToString; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; import java.util.Iterator; import java.util.List; -//~--- JDK imports ------------------------------------------------------------ - /** * Represents all branches of a repository. * * @author Sebastian Sdorra * @since 1.18 */ -@XmlRootElement(name="branches") -@XmlAccessorType(XmlAccessType.FIELD) -public final class Branches implements Iterable -{ +@EqualsAndHashCode +@ToString +@Setter +public final class Branches implements Iterable { - /** - * Constructs a new instance of branches. - * This constructor should only be called from JAXB. - * - */ - public Branches() {} + private List branches; - /** - * Constructs a new instance of branches. - * - * - * @param branches list of branches. - */ - public Branches(Branch... branches) - { + public Branches() { + } + + ; + + public Branches(Branch... branches) { this.branches = Lists.newArrayList(branches); } - /** - * Constructs a new instance of branches. - * - * - * @param branches list of branches. - */ - public Branches(List branches) - { + public Branches(List branches) { this.branches = branches; } - //~--- methods -------------------------------------------------------------- - - /** - * {@inheritDoc} - * - * - * @param obj - * - * @return - */ @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - final Branches other = (Branches) obj; - - return Objects.equal(branches, other.branches); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public int hashCode() - { - return Objects.hashCode(branches); - } - - /** - * Method description - * - * - * @return - */ - @Override - public Iterator iterator() - { + public Iterator iterator() { return getBranches().iterator(); } - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public String toString() - { - //J- - return MoreObjects.toStringHelper(this) - .add("branches", branches) - .toString(); - //J+ - } - //~--- get methods ---------------------------------------------------------- - - /** - * Returns all branches of a repository. - * - * - * @return all branches - */ - public List getBranches() - { - if (branches == null) - { + public List getBranches() { + if (branches == null) { branches = Lists.newArrayList(); } return branches; } - - //~--- set methods ---------------------------------------------------------- - - /** - * Sets all branches. - * - * - * @param branches branches - */ - public void setBranches(List branches) - { - this.branches = branches; - } - - //~--- fields --------------------------------------------------------------- - - /** branches */ - @XmlElement(name="branch") - private List branches; } diff --git a/scm-core/src/main/java/sonia/scm/repository/BrowserResult.java b/scm-core/src/main/java/sonia/scm/repository/BrowserResult.java index 2c5a041189..db30fe22a2 100644 --- a/scm-core/src/main/java/sonia/scm/repository/BrowserResult.java +++ b/scm-core/src/main/java/sonia/scm/repository/BrowserResult.java @@ -21,28 +21,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -//~--- non-JDK imports -------------------------------------------------------- +import lombok.EqualsAndHashCode; +import lombok.ToString; -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; -//~--- JDK imports ------------------------------------------------------------ - -/** - * - * @author Sebastian Sdorra - * @since 1.5 - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "browser-result") +@EqualsAndHashCode +@ToString public class BrowserResult implements Serializable { private String revision; @@ -52,6 +40,8 @@ public class BrowserResult implements Serializable { public BrowserResult() { } + ; + public BrowserResult(String revision, FileObject file) { this(revision, revision, file); } @@ -73,36 +63,4 @@ public class BrowserResult implements Serializable { public FileObject getFile() { return file; } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - - if (getClass() != obj.getClass()) { - return false; - } - - final BrowserResult other = (BrowserResult) obj; - - return Objects.equal(revision, other.revision) - && Objects.equal(file, other.file); - } - - @Override - public int hashCode() { - return Objects.hashCode(revision, file); - } - - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("revision", revision) - .add("files", file) - .toString(); - } - - } diff --git a/scm-core/src/main/java/sonia/scm/repository/Changeset.java b/scm-core/src/main/java/sonia/scm/repository/Changeset.java index 654739fa25..f6566806fd 100644 --- a/scm-core/src/main/java/sonia/scm/repository/Changeset.java +++ b/scm-core/src/main/java/sonia/scm/repository/Changeset.java @@ -21,30 +21,25 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -import com.google.common.base.Objects; +import lombok.EqualsAndHashCode; import sonia.scm.BasicPropertiesAware; import sonia.scm.ModelObject; import sonia.scm.util.Util; import sonia.scm.util.ValidationUtil; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.Date; import java.util.List; - /** * Represents a changeset/commit of a repository. * * @author Sebastian Sdorra */ -@XmlRootElement(name = "changeset") -@XmlAccessorType(XmlAccessType.FIELD) +@EqualsAndHashCode public class Changeset extends BasicPropertiesAware implements ModelObject { private static final long serialVersionUID = -8373308448928993039L; @@ -91,8 +86,7 @@ public class Changeset extends BasicPropertiesAware implements ModelObject { this(id, date, author, null); } - public Changeset(String id, Long date, Person author, String description) - { + public Changeset(String id, Long date, Person author, String description) { this.id = id; this.date = date; this.author = author; @@ -100,66 +94,18 @@ public class Changeset extends BasicPropertiesAware implements ModelObject { } @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) { - return false; - } - - final Changeset other = (Changeset) obj; - - //J- - return Objects.equal(id, other.id) - && Objects.equal(date, other.date) - && Objects.equal(author, other.author) - && Objects.equal(description, other.description) - && Objects.equal(parents, other.parents) - && Objects.equal(tags, other.tags) - && Objects.equal(branches, other.branches) - && Objects.equal(properties, other.properties); - //J+ - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public int hashCode() - { - return Objects.hashCode(id, date, author, description, parents, tags, - branches, properties); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public String toString() - { + public String toString() { StringBuilder out = new StringBuilder("changeset: "); out.append(id).append("\n"); - if (parents != null) - { + if (parents != null) { out.append("parents: ").append(Util.toString(parents)).append("\n"); } out.append("author: ").append(author).append("\n"); - if (date != null) - { + if (date != null) { out.append("date: ").append(Util.formatDate(new Date(date))).append("\n"); } @@ -170,7 +116,6 @@ public class Changeset extends BasicPropertiesAware implements ModelObject { return out.toString(); } - /** * Returns a timestamp of the creation date of the {@link Changeset}. * @@ -185,11 +130,9 @@ public class Changeset extends BasicPropertiesAware implements ModelObject { this.setDate(timestamp); } - /** * Returns the author of the changeset. * - * * @return author of the changeset */ public Person getAuthor() { @@ -201,13 +144,10 @@ public class Changeset extends BasicPropertiesAware implements ModelObject { * only related to one branch, but in the case of receive hooks it is possible * that a changeset is related to more than a branch. * - * * @return branches of the changeset */ - public List getBranches() - { - if (branches == null) - { + public List getBranches() { + if (branches == null) { branches = new ArrayList(); } @@ -217,29 +157,24 @@ public class Changeset extends BasicPropertiesAware implements ModelObject { /** * Returns the creation date of the changeset. * - * * @return date of the changeset */ - public Long getDate() - { + public Long getDate() { return date; } /** * Return the description (commit message) of the changeset. * - * * @return description of the changeset */ - public String getDescription() - { + public String getDescription() { return description; } /** * Returns the id of the changeset. * - * * @return id of the changeset */ @Override @@ -263,18 +198,14 @@ public class Changeset extends BasicPropertiesAware implements ModelObject { } - /** * Return the ids of the parent changesets. * - * * @return * @since 1.11 */ - public List getParents() - { - if (parents == null) - { + public List getParents() { + if (parents == null) { parents = new ArrayList(); } @@ -284,13 +215,10 @@ public class Changeset extends BasicPropertiesAware implements ModelObject { /** * Returns tags associated with this changeset. * - * * @return tags of the changeset */ - public List getTags() - { - if (tags == null) - { + public List getTags() { + if (tags == null) { tags = new ArrayList(); } @@ -300,91 +228,75 @@ public class Changeset extends BasicPropertiesAware implements ModelObject { /** * Returns true if the changeset is valid. * - * * @return true if the changeset is valid */ @Override - public boolean isValid() - { + public boolean isValid() { return Util.isNotEmpty(id) && ValidationUtil.isValid(author) - && (date != null); + && (date != null); } /** * Sets the author of the changeset. * - * * @param author author of the changeset */ - public void setAuthor(Person author) - { + public void setAuthor(Person author) { this.author = author; } /** * Sets the branches of the changeset. * - * * @param branches branches of the changeset */ - public void setBranches(List branches) - { + public void setBranches(List branches) { this.branches = branches; } /** * Sets the date of the changeset. * - * * @param date date of the changeset */ - public void setDate(Long date) - { + public void setDate(Long date) { this.date = date; } /** * Sets the description (commit message) of the changeset. * - * * @param description description of the changeset */ - public void setDescription(String description) - { + public void setDescription(String description) { this.description = description; } /** * Sets the id of the changeset. * - * * @param id id of the changeset */ - public void setId(String id) - { + public void setId(String id) { this.id = id; } /** * Sets the parents of the changeset. * - * * @param parents parents of the changeset * @since 1.11 */ - public void setParents(List parents) - { + public void setParents(List parents) { this.parents = parents; } /** * Sets the tags of the changeset * - * * @param tags tags of the changeset */ - public void setTags(List tags) - { + public void setTags(List tags) { this.tags = tags; } diff --git a/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java b/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java index 4bbe54ba54..f5bd3a06d4 100644 --- a/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java +++ b/scm-core/src/main/java/sonia/scm/repository/ChangesetPagingResult.java @@ -21,56 +21,40 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.MoreObjects; import com.google.common.base.Objects; +import lombok.Setter; +import lombok.ToString; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; import java.util.Iterator; import java.util.List; -//~--- JDK imports ------------------------------------------------------------ - /** * The changeset paging result is used to do a paging over the * {@link Changeset}s of a {@link Repository}. * * @author Sebastian Sdorra */ -@XmlRootElement(name = "changeset-paging") -@XmlAccessorType(XmlAccessType.FIELD) -public class ChangesetPagingResult implements Iterable, Serializable -{ +@ToString +@Setter +public class ChangesetPagingResult implements Iterable, Serializable { - /** Field description */ private static final long serialVersionUID = -8678755403658841733L; - //~--- constructors --------------------------------------------------------- + private List changesets; + private int total; + private String branchName; /** * Constructs a new changeset paging result. * - */ - public ChangesetPagingResult() {} - - /** - * Constructs a new changeset paging result. - * - * - * @param total total number of changesets + * @param total total number of changesets * @param changesets current list of fetched changesets */ - public ChangesetPagingResult(int total, List changesets) - { + public ChangesetPagingResult(int total, List changesets) { this.total = total; this.changesets = changesets; this.branchName = null; @@ -79,38 +63,23 @@ public class ChangesetPagingResult implements Iterable, Serializable /** * Constructs a new changeset paging result for a specific branch. * - * - * @param total total number of changesets + * @param total total number of changesets * @param changesets current list of fetched changesets * @param branchName branch name this result was created for */ - public ChangesetPagingResult(int total, List changesets, String branchName) - { + public ChangesetPagingResult(int total, List changesets, String branchName) { this.total = total; this.changesets = changesets; this.branchName = branchName; } - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param obj - * - * @return - */ @Override - public boolean equals(Object obj) - { - if (obj == null) - { + public boolean equals(Object obj) { + if (obj == null) { return false; } - if (getClass() != obj.getClass()) - { + if (getClass() != obj.getClass()) { return false; } @@ -120,94 +89,46 @@ public class ChangesetPagingResult implements Iterable, Serializable && Objects.equal(total, other.total); } - /** - * Method description - * - * - * @return - */ @Override - public int hashCode() - { + public int hashCode() { return Objects.hashCode(changesets, total); } /** * Returns an iterator which can iterate over the current list of changesets. * - * * @return iterator for current list of changesets * @since 1.8 */ @Override - public Iterator iterator() - { + public Iterator iterator() { Iterator it = null; - if (changesets != null) - { + if (changesets != null) { it = changesets.iterator(); } return it; } - /** - * Method description - * - * - * @return - */ - @Override - public String toString() - { - //J- - return MoreObjects.toStringHelper(this) - .add("changesets", changesets) - .add("total", total) - .add("branch", branchName) - .toString(); - //J+ - } - - //~--- get methods ---------------------------------------------------------- - /** * Returns the current list of changesets. * - * * @return current list of changesets */ - public List getChangesets() - { + public List getChangesets() { return changesets; } /** * Returns the total number of changesets. * - * * @return total number of changesets */ - public int getTotal() - { + public int getTotal() { return total; } - void setChangesets(List changesets) - { - this.changesets = changesets; - } - - void setTotal(int total) - { - this.total = total; - } - - void setBranchName(String branchName) { - this.branchName = branchName; - } - /** * Returns the branch name this result was created for. This can either be an explicit branch ("give me all * changesets for branch xyz") or an implicit one ("give me the changesets for the default"). @@ -216,13 +137,4 @@ public class ChangesetPagingResult implements Iterable, Serializable return branchName; } - //~--- fields --------------------------------------------------------------- - - @XmlElement(name = "changeset") - @XmlElementWrapper(name = "changesets") - private List changesets; - - private int total; - - private String branchName; } diff --git a/scm-core/src/main/java/sonia/scm/repository/FileObject.java b/scm-core/src/main/java/sonia/scm/repository/FileObject.java index 6cc65d69ea..82d6bed205 100644 --- a/scm-core/src/main/java/sonia/scm/repository/FileObject.java +++ b/scm-core/src/main/java/sonia/scm/repository/FileObject.java @@ -21,18 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.base.Strings; +import lombok.EqualsAndHashCode; +import lombok.ToString; import sonia.scm.LastModifiedAware; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; @@ -49,98 +46,70 @@ import static java.util.Optional.ofNullable; * @author Sebastian Sdorra * @since 1.5 */ -@XmlRootElement(name = "file") -@XmlAccessorType(XmlAccessType.FIELD) -public class FileObject implements LastModifiedAware, Serializable -{ +@EqualsAndHashCode +@ToString +public class FileObject implements LastModifiedAware, Serializable { - /** serial version uid */ private static final long serialVersionUID = -5562537629609891499L; - //~--- methods -------------------------------------------------------------- + private String description; /** - * {@inheritDoc} + * directory indicator */ - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - final FileObject other = (FileObject) obj; - - //J- - return Objects.equal(name, other.name) - && Objects.equal(path, other.path) - && Objects.equal(directory, other.directory) - && Objects.equal(description, other.description) - && Objects.equal(length, other.length) - && Objects.equal(subRepository, other.subRepository) - && Objects.equal(commitDate, other.commitDate) - && Objects.equal(partialResult, other.partialResult) - && Objects.equal(computationAborted, other.computationAborted); - //J+ - } + private boolean directory; /** - * {@inheritDoc} + * commit date */ - @Override - public int hashCode() - { - return Objects.hashCode( - name, - path, - directory, - description, - length, - subRepository, - commitDate, - partialResult, - computationAborted); - } + private Long commitDate; /** - * {@inheritDoc} + * file length */ - @Override - public String toString() - { - //J- - return MoreObjects.toStringHelper(this) - .add("name", name) - .add("path", path) - .add("directory", directory) - .add("description", description) - .add("length", length) - .add("subRepository", subRepository) - .add("commitDate", commitDate) - .add("partialResult", partialResult) - .add("computationAborted", computationAborted) - .toString(); - //J+ - } + private Long length; - //~--- get methods ---------------------------------------------------------- + /** + * filename + */ + private String name; + + /** + * file path + */ + private String path; + + /** + * Marker for partial result. + */ + private boolean partialResult = false; + + /** + * Marker for aborted computation. + */ + private boolean computationAborted = false; + + /** + * sub repository informations + */ + @XmlElement(name = "subrepository") + private SubRepository subRepository; + + /** + * Children of this file (aka directory). + */ + private Collection children = new ArrayList<>(); + + private boolean truncated; /** * Returns the last commit message for this file. The method will return null, * if the repository provider is not able to get the last commit for the path. * - * * @return Last commit message or null, when this value has not been computed * (see {@link #isPartialResult()}). */ - public Optional getDescription() - { + public Optional getDescription() { return ofNullable(description); } @@ -149,12 +118,11 @@ public class FileObject implements LastModifiedAware, Serializable * if the repository provider is not able to get the last commit for the path * or it has not been computed. * - * * @return last commit date */ @Override public Long getLastModified() { - return this.isPartialResult()? null: this.commitDate; + return this.isPartialResult() ? null : this.commitDate; } /** @@ -162,39 +130,33 @@ public class FileObject implements LastModifiedAware, Serializable * if the repository provider is not able to get the last commit for the path or if this value has not been computed * (see {@link #isPartialResult()} and {@link #isComputationAborted()}). */ - public OptionalLong getCommitDate() - { - return commitDate == null? OptionalLong.empty(): OptionalLong.of(commitDate); + public OptionalLong getCommitDate() { + return commitDate == null ? OptionalLong.empty() : OptionalLong.of(commitDate); } /** * Returns the length of the file or {@link OptionalLong#empty()}, when this value has not been computed * (see {@link #isPartialResult()} and {@link #isComputationAborted()}). */ - public OptionalLong getLength() - { - return length == null? OptionalLong.empty(): OptionalLong.of(length); + public OptionalLong getLength() { + return length == null ? OptionalLong.empty() : OptionalLong.of(length); } /** * Returns the name of the file. * - * * @return name of file */ - public String getName() - { + public String getName() { return name; } /** * Returns the path of the file. * - * * @return path of file */ - public String getPath() - { + public String getPath() { return path; } @@ -218,22 +180,19 @@ public class FileObject implements LastModifiedAware, Serializable * Return sub repository information or null if the file is not * sub repository. * - * @since 1.10 * @return sub repository informations or null + * @since 1.10 */ - public SubRepository getSubRepository() - { + public SubRepository getSubRepository() { return subRepository; } /** * Returns true if the file is a directory. * - * * @return true if file is a directory */ - public boolean isDirectory() - { + public boolean isDirectory() { return directory; } @@ -243,7 +202,7 @@ public class FileObject implements LastModifiedAware, Serializable * @return The children of this file if it is a directory. */ public Collection getChildren() { - return children == null? null: unmodifiableCollection(children); + return children == null ? null : unmodifiableCollection(children); } /** @@ -252,9 +211,8 @@ public class FileObject implements LastModifiedAware, Serializable * will return {@link Optional#empty()} (or {@link OptionalLong#empty()} respectively), unless they are computed. * There may be an asynchronous task running, that will set these values in the future. * - * @since 2.0.0 - * * @return true, whenever some values of this object have not been computed, yet. + * @since 2.0.0 */ public boolean isPartialResult() { return partialResult; @@ -265,9 +223,8 @@ public class FileObject implements LastModifiedAware, Serializable * values (like {@link #getLength()}, {@link #getDescription()} or {@link #getCommitDate()}) * will return {@link Optional#empty()} (or {@link OptionalLong#empty()} respectively), unless they are computed. * - * @since 2.0.0 - * * @return true, whenever some values of this object finally are not computed. + * @since 2.0.0 */ public boolean isComputationAborted() { return computationAborted; @@ -282,87 +239,72 @@ public class FileObject implements LastModifiedAware, Serializable /** * Sets the description of the file. * - * * @param description description of file */ - public void setDescription(String description) - { + public void setDescription(String description) { this.description = description; } /** * Set to true to indicate that the file is a directory. * - * * @param directory true for directory */ - public void setDirectory(boolean directory) - { + public void setDirectory(boolean directory) { this.directory = directory; } /** * Sets the commit date of the file. * - * * @param commitDate commit date */ - public void setCommitDate(Long commitDate) - { + public void setCommitDate(Long commitDate) { this.commitDate = commitDate; } /** * Sets the length of the file. * - * * @param length file length */ - public void setLength(Long length) - { + public void setLength(Long length) { this.length = length; } /** * Sets the name of the file. * - * * @param name filename */ - public void setName(String name) - { + public void setName(String name) { this.name = name; } /** * Sets the path of the file. * - * * @param path file path */ - public void setPath(String path) - { + public void setPath(String path) { this.path = path; } /** * Set sub repository information for the file. * - * @since 1.10 - * * @param subRepository sub repository informations + * @since 1.10 */ - public void setSubRepository(SubRepository subRepository) - { + public void setSubRepository(SubRepository subRepository) { this.subRepository = subRepository; } /** * Set marker, that some values for this object are not computed, yet. * - * @since 2.0.0 - * * @param partialResult Set this to true, whenever some values of this object are not computed, yet. + * @since 2.0.0 */ public void setPartialResult(boolean partialResult) { this.partialResult = partialResult; @@ -371,10 +313,9 @@ public class FileObject implements LastModifiedAware, Serializable /** * Set marker, that computation of some values for this object has been aborted. * - * @since 2.0.0 - * * @param computationAborted Set this to true, whenever some values of this object are not computed and * will not be computed in the future. + * @since 2.0.0 */ public void setComputationAborted(boolean computationAborted) { this.computationAborted = computationAborted; @@ -401,39 +342,4 @@ public class FileObject implements LastModifiedAware, Serializable public void setTruncated(boolean truncated) { this.truncated = truncated; } - - //~--- fields --------------------------------------------------------------- - - /** file description */ - private String description; - - /** directory indicator */ - private boolean directory; - - /** commit date */ - private Long commitDate; - - /** file length */ - private Long length; - - /** filename */ - private String name; - - /** file path */ - private String path; - - /** Marker for partial result. */ - private boolean partialResult = false; - - /** Marker for aborted computation. */ - private boolean computationAborted = false; - - /** sub repository informations */ - @XmlElement(name = "subrepository") - private SubRepository subRepository; - - /** Children of this file (aka directory). */ - private Collection children = new ArrayList<>(); - - private boolean truncated; } diff --git a/scm-core/src/main/java/sonia/scm/repository/ImportResult.java b/scm-core/src/main/java/sonia/scm/repository/ImportResult.java index 39c102959b..d86c4b4e96 100644 --- a/scm-core/src/main/java/sonia/scm/repository/ImportResult.java +++ b/scm-core/src/main/java/sonia/scm/repository/ImportResult.java @@ -21,166 +21,74 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; import java.util.List; import static com.google.common.base.Preconditions.checkNotNull; -//~--- JDK imports ------------------------------------------------------------ - /** * Import result of the {@link AdvancedImportHandler}. * * @author Sebastian Sdorra * @since 1.43 */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "import-result") -public final class ImportResult -{ +@EqualsAndHashCode +@ToString +@Getter +public final class ImportResult { /** - * Constructs ... - * + * failed directories */ - ImportResult() {} + private List failedDirectories; /** - * Constructs a new import result. - * - * - * @param importedDirectories imported directories - * @param failedDirectories failed directories + * successfully imported directories */ + private List importedDirectories; + public ImportResult(List importedDirectories, - List failedDirectories) - { + List failedDirectories) { this.importedDirectories = checkNotNull(importedDirectories, "list of imported directories is required"); this.failedDirectories = checkNotNull(failedDirectories, "list of failed directories is required"); } - //~--- methods -------------------------------------------------------------- - - /** - * Returns a import result builder. - * - * - * @return import result builder - */ - public static Builder builder() - { + public static Builder builder() { return new Builder(); } - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - final ImportResult other = (ImportResult) obj; - - return Objects.equal(importedDirectories, other.importedDirectories) - && Objects.equal(failedDirectories, other.failedDirectories); - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() - { - return Objects.hashCode(importedDirectories, failedDirectories); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() - { - //J- - return MoreObjects.toStringHelper(this) - .add("importedDirectories", importedDirectories) - .add("failedDirectories", failedDirectories) - .toString(); - //J+ - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Returns list of failed directories. - * - * - * @return list of failed directories - */ - public List getFailedDirectories() - { - return failedDirectories; - } - - /** - * Returns list of successfully imported directories. - * - * - * @return list of successfully imported directories - */ - public List getImportedDirectories() - { - return importedDirectories; - } - - //~--- inner classes -------------------------------------------------------- - /** * Builder for {@link ImportResult}. */ - public static class Builder - { + public static class Builder { /** - * Constructs ... - * + * successfully imported directories */ - private Builder() {} + private final List importedDirectories = Lists.newArrayList(); - //~--- methods ------------------------------------------------------------ + /** + * failed directories + */ + private final List failedDirectories = Lists.newArrayList(); /** * Adds a failed directory to the import result. * - * * @param name name of the directory - * * @return {@code this} */ - public Builder addFailedDirectory(String name) - { + public Builder addFailedDirectory(String name) { this.failedDirectories.add(name); return this; @@ -189,13 +97,10 @@ public final class ImportResult /** * Adds a successfully imported directory to the import result. * - * * @param name name of the directory - * * @return {@code this} */ - public Builder addImportedDirectory(String name) - { + public Builder addImportedDirectory(String name) { this.importedDirectories.add(name); return this; @@ -204,30 +109,11 @@ public final class ImportResult /** * Builds the final import result. * - * * @return final import result */ - public ImportResult build() - { + public ImportResult build() { return new ImportResult(ImmutableList.copyOf(importedDirectories), ImmutableList.copyOf(failedDirectories)); } - - //~--- fields ------------------------------------------------------------- - - /** successfully imported directories */ - private final List importedDirectories = Lists.newArrayList(); - - /** failed directories */ - private final List failedDirectories = Lists.newArrayList(); } - - - //~--- fields --------------------------------------------------------------- - - /** failed directories */ - private List failedDirectories; - - /** successfully imported directories */ - private List importedDirectories; } diff --git a/scm-core/src/main/java/sonia/scm/repository/Modifications.java b/scm-core/src/main/java/sonia/scm/repository/Modifications.java index f2e08048ef..f1f1d673af 100644 --- a/scm-core/src/main/java/sonia/scm/repository/Modifications.java +++ b/scm-core/src/main/java/sonia/scm/repository/Modifications.java @@ -21,189 +21,69 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.Objects; import com.google.common.collect.Lists; -import sonia.scm.util.Util; +import lombok.EqualsAndHashCode; +import lombok.Setter; +import lombok.ToString; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; import java.util.List; -//~--- JDK imports ------------------------------------------------------------ +@EqualsAndHashCode +@ToString +@Setter +public class Modifications implements Serializable { -/** - * - * @author Sebastian Sdorra - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlRootElement(name = "modifications") -public class Modifications implements Serializable -{ - - /** Field description */ private static final long serialVersionUID = -8902033326668658140L; - - //~--- constructors --------------------------------------------------------- + private String revision; /** - * Constructs ... - * + * lists of changed files */ + private List added; + private List modified; + private List removed; + public Modifications() { } - /** - * Constructs ... - * - * - * @param added - */ - public Modifications(List added) - { + ; + + public Modifications(List added) { this(added, null, null); } - /** - * Constructs ... - * - * - * @param added - * @param modified - */ - public Modifications(List added, List modified) - { + public Modifications(List added, List modified) { this(added, modified, null); } - /** - * Constructs ... - * - * - * @param added - * @param modified - * @param removed - */ - public Modifications(List added, List modified, - List removed) - { + public Modifications(List added, List modified, List removed) { this.added = added; this.modified = modified; this.removed = removed; } - //~--- methods -------------------------------------------------------------- - - /** - * {@inheritDoc} - * - * - * @param obj - * - * @return - */ - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - final Modifications other = (Modifications) obj; - - return Objects.equal(added, other.added) - && Objects.equal(modified, other.modified) - && Objects.equal(removed, other.removed); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public int hashCode() - { - return Objects.hashCode(added, modified, removed); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public String toString() - { - StringBuilder out = new StringBuilder(); - - out.append("added:").append(Util.toString(added)).append("\n"); - out.append("modified:").append(Util.toString(modified)).append("\n"); - out.append("removed:").append(Util.toString(removed)).append("\n"); - - return out.toString(); - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public List getAdded() - { - if (added == null) - { + public List getAdded() { + if (added == null) { added = Lists.newArrayList(); } return added; } - /** - * Method description - * - * - * @return - */ - public List getModified() - { - if (modified == null) - { + public List getModified() { + if (modified == null) { modified = Lists.newArrayList(); } return modified; } - /** - * Method description - * - * - * @return - */ - public List getRemoved() - { - if (removed == null) - { + public List getRemoved() { + if (removed == null) { removed = Lists.newArrayList(); } @@ -213,62 +93,4 @@ public class Modifications implements Serializable public String getRevision() { return revision; } - - //~--- set methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param added - */ - public void setAdded(List added) - { - this.added = added; - } - - /** - * Method description - * - * - * @param modified - */ - public void setModified(List modified) - { - this.modified = modified; - } - - /** - * Method description - * - * - * @param removed - */ - public void setRemoved(List removed) - { - this.removed = removed; - } - - public void setRevision(String revision) { - this.revision = revision; - } - - //~--- fields --------------------------------------------------------------- - - private String revision; - - /** list of added files */ - @XmlElement(name = "added") - @XmlElementWrapper(name = "added") - private List added; - - /** list of modified files */ - @XmlElement(name = "modified") - @XmlElementWrapper(name = "modified") - private List modified; - - /** list of removed files */ - @XmlElement(name = "removed") - @XmlElementWrapper(name = "removed") - private List removed; } diff --git a/scm-core/src/main/java/sonia/scm/repository/Person.java b/scm-core/src/main/java/sonia/scm/repository/Person.java index 7068271e00..503108e076 100644 --- a/scm-core/src/main/java/sonia/scm/repository/Person.java +++ b/scm-core/src/main/java/sonia/scm/repository/Person.java @@ -21,94 +21,70 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.Objects; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; import sonia.scm.Validateable; import sonia.scm.util.Util; import sonia.scm.util.ValidationUtil; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; -//~--- JDK imports ------------------------------------------------------------ - /** * The {@link Person} (author) of a changeset. * * @person Sebastian Sdorra */ -@XmlRootElement(name = "person") -@XmlAccessorType(XmlAccessType.FIELD) -public class Person implements Validateable, Serializable -{ +@EqualsAndHashCode +@Getter +@Setter +public class Person implements Validateable, Serializable { - /** Field description */ private static final long serialVersionUID = -4675080650527063196L; - //~--- constructors --------------------------------------------------------- + /** + * mail address of the person + */ + private String mail; /** - * Constructs a new {@link Person}. - * This constructor is used by JAXB. - * + * name of the person */ - public Person() {} + private String name; - /** - * Constructs a new {@link Person}. - * - * - * @param name name of {@link Person} - */ - public Person(String name) - { + public Person() { + } + + public Person(String name) { this.name = name; } - /** - * Constructs a new {@link Person} with name and mail address. - * - * - * @param name name of the {@link Person} - * @param mail mail address of the {@link Person} - */ - public Person(String name, String mail) - { + public Person(String name, String mail) { this.name = name; this.mail = mail; } - //~--- methods -------------------------------------------------------------- - /** * Parses the given string and returns a {@link Person} object. The string * should be in the format "name >mail<". if the string contains no * "><" the whole string is handled as the name of the {@link Person}. * - * * @param value string representation of a {@link Person} object - * * @return {@link Person} object which is generated from the given string */ - public static Person toPerson(String value) - { + public static Person toPerson(String value) { Person person = null; - if (Util.isNotEmpty(value)) - { + if (Util.isNotEmpty(value)) { String name = value; String mail = null; int s = value.indexOf('<'); int e = value.indexOf('>'); - if ((s > 0) && (e > 0)) - { + if ((s > 0) && (e > 0)) { name = value.substring(0, s).trim(); mail = value.substring(s + 1, e).trim(); } @@ -119,56 +95,17 @@ public class Person implements Validateable, Serializable return person; } - /** - * {@inheritDoc} - * - * @param obj - * - * @return - */ - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - Person other = (Person) obj; - - return Objects.equal(name, other.name) && Objects.equal(mail, other.mail); - } - - /** - * {@inheritDoc} - * - * @return - */ - @Override - public int hashCode() - { - return Objects.hashCode(name, mail); - } - /** * Returns a string representation of the {@link Person} object, * in the format "name >mail<". * - * * @return string representation of {@link Person} object */ @Override - public String toString() - { + public String toString() { String out = name; - if (mail != null) - { + if (mail != null) { out = out.concat(" <").concat(mail).concat(">"); } @@ -180,71 +117,30 @@ public class Person implements Validateable, Serializable /** * Returns the mail address of the changeset author. * - * - * @return mail address of the changeset author - * * @return */ - public String getMail() - { + public String getMail() { return mail; } /** * Returns the name of the changeset author. * - * * @return name of the changeset person */ - public String getName() - { + public String getName() { return name; } + /** * Returns true if the person is valid. * - * * @return true if the person is valid */ @Override - public boolean isValid() - { + public boolean isValid() { return Util.isNotEmpty(name) - && (Util.isEmpty(mail) || ValidationUtil.isMailAddressValid(mail)); + && (Util.isEmpty(mail) || ValidationUtil.isMailAddressValid(mail)); } - - //~--- set methods ---------------------------------------------------------- - - /** - * Sets the mail address of the changeset author. - * - * - * @param mail mail address of the author - */ - public void setMail(String mail) - { - this.mail = mail; - } - - /** - * Sets the name of the changeset author. - * - * - * @param name name of the author - */ - public void setName(String name) - { - this.name = name; - } - - //~--- fields --------------------------------------------------------------- - - /** mail address of the person */ - private String mail; - - /** - * name of the person - */ - private String name; } diff --git a/scm-core/src/main/java/sonia/scm/repository/SubRepository.java b/scm-core/src/main/java/sonia/scm/repository/SubRepository.java index e9ee839e23..04eb568d71 100644 --- a/scm-core/src/main/java/sonia/scm/repository/SubRepository.java +++ b/scm-core/src/main/java/sonia/scm/repository/SubRepository.java @@ -21,221 +21,45 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -//~--- non-JDK imports -------------------------------------------------------- +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; -//~--- JDK imports ------------------------------------------------------------ +@EqualsAndHashCode +@ToString +@Getter +@Setter +public class SubRepository implements Serializable { -/** - * @since 1.10 - * @author Sebastian Sdorra - */ -@XmlRootElement(name = "subrepository") -@XmlAccessorType(XmlAccessType.FIELD) -public class SubRepository implements Serializable -{ - - /** Field description */ private static final long serialVersionUID = 6960065820378492531L; - //~--- constructors --------------------------------------------------------- - - /** - * Constructs ... - * - */ - public SubRepository() {} - - /** - * Constructs ... - * - * - * @param repositoryUrl - */ - public SubRepository(String repositoryUrl) - { - this.repositoryUrl = repositoryUrl; - } - - /** - * Constructs ... - * - * - * @param revision - * @param repositoryUrl - */ - public SubRepository(String repositoryUrl, String revision) - { - this.repositoryUrl = repositoryUrl; - this.revision = revision; - } - - /** - * Constructs ... - * - * - * @param revision - * @param repositoryUrl - * @param browserUrl - */ - public SubRepository(String repositoryUrl, String browserUrl, String revision) - { - this.repositoryUrl = repositoryUrl; - this.browserUrl = browserUrl; - this.revision = revision; - } - - //~--- methods -------------------------------------------------------------- - - /** - * {@inheritDoc} - * - * - * @param obj - * - * @return - */ - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - SubRepository other = (SubRepository) obj; - - return Objects.equal(repositoryUrl, other.repositoryUrl) - && Objects.equal(browserUrl, other.browserUrl) - && Objects.equal(revision, other.revision); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public int hashCode() - { - return Objects.hashCode(repositoryUrl, browserUrl, revision); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public String toString() - { - //J- - return MoreObjects.toStringHelper(this) - .add("repositoryUrl", repositoryUrl) - .add("browserUrl", browserUrl) - .add("revision", revision) - .toString(); - //J+ - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public String getBrowserUrl() - { - return browserUrl; - } - - /** - * Method description - * - * - * @return - */ - public String getRepositoryUrl() - { - return repositoryUrl; - } - - /** - * Method description - * - * - * @return - */ - public String getRevision() - { - return revision; - } - - //~--- set methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param browserUrl - */ - public void setBrowserUrl(String browserUrl) - { - this.browserUrl = browserUrl; - } - - /** - * Method description - * - * - * @param repositoryUrl - */ - public void setRepositoryUrl(String repositoryUrl) - { - this.repositoryUrl = repositoryUrl; - } - - /** - * Method description - * - * - * @param revision - */ - public void setRevision(String revision) - { - this.revision = revision; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - @XmlElement(name = "browser-url") private String browserUrl; - - /** Field description */ - @XmlElement(name = "repository-url") private String repositoryUrl; - - /** Field description */ private String revision; + + public SubRepository() { + } + + ; + + public SubRepository(String repositoryUrl) { + this.repositoryUrl = repositoryUrl; + } + + public SubRepository(String repositoryUrl, String revision) { + this.repositoryUrl = repositoryUrl; + this.revision = revision; + } + + public SubRepository(String repositoryUrl, String browserUrl, String revision) { + this.repositoryUrl = repositoryUrl; + this.browserUrl = browserUrl; + this.revision = revision; + } } diff --git a/scm-core/src/main/java/sonia/scm/repository/Tag.java b/scm-core/src/main/java/sonia/scm/repository/Tag.java index c66876d0c3..68048b5fc8 100644 --- a/scm-core/src/main/java/sonia/scm/repository/Tag.java +++ b/scm-core/src/main/java/sonia/scm/repository/Tag.java @@ -21,19 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; - -//~--- JDK imports ------------------------------------------------------------ +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; /** * Represents a tag in a repository. @@ -41,118 +34,25 @@ import javax.xml.bind.annotation.XmlRootElement; * @author Sebastian Sdorra * @since 1.18 */ -@XmlRootElement(name = "tag") -@XmlAccessorType(XmlAccessType.FIELD) -public final class Tag -{ +@EqualsAndHashCode +@ToString +@Getter +public final class Tag { - /** - * Constructs a new instance of tag. - * This constructor should only be called from JAXB. - * - */ - public Tag() {} + private String name; + private String revision; + + public Tag() { + } /** * Constructs a new tag. * - * - * @param name name of the tag + * @param name name of the tag * @param revision tagged revision */ - public Tag(String name, String revision) - { + public Tag(String name, String revision) { this.name = name; this.revision = revision; } - - //~--- methods -------------------------------------------------------------- - - /** - * {@inheritDoc} - * - * - * @param obj - * - * @return - */ - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - final Tag other = (Tag) obj; - - return Objects.equal(name, other.name) - && Objects.equal(revision, other.revision); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public int hashCode() - { - return Objects.hashCode(name, revision); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public String toString() - { - //J- - return MoreObjects.toStringHelper(this) - .add("name", name) - .add("revision", revision) - .toString(); - //J+ - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Returns the name of the tag. - * - * - * @return name of the tag - */ - public String getName() - { - return name; - } - - /** - * Id of the tagged revision. - * - * - * @return tagged revision id - */ - public String getRevision() - { - return revision; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private String name; - - /** Field description */ - private String revision; } diff --git a/scm-core/src/main/java/sonia/scm/repository/Tags.java b/scm-core/src/main/java/sonia/scm/repository/Tags.java index 85642eb400..6c74bfabfd 100644 --- a/scm-core/src/main/java/sonia/scm/repository/Tags.java +++ b/scm-core/src/main/java/sonia/scm/repository/Tags.java @@ -21,139 +21,55 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -//~--- non-JDK imports -------------------------------------------------------- - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; import com.google.common.collect.Lists; +import lombok.EqualsAndHashCode; +import lombok.Setter; +import lombok.ToString; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; import java.util.Iterator; import java.util.List; -//~--- JDK imports ------------------------------------------------------------ - /** * Represents all tags of a repository. * * @author Sebastian Sdorra * @since 1.18 */ -@XmlRootElement(name = "tags") -@XmlAccessorType(XmlAccessType.FIELD) -public final class Tags implements Iterable -{ +@EqualsAndHashCode +@ToString +@Setter +public final class Tags implements Iterable { - /** - * Constructs a new instance of tags. - * This constructor should only be called from JAXB. - * - */ - public Tags() {} + private List tags; - /** - * Constructs a new instance of tags. - * - * - * @param tags list of tags. - */ - public Tags(List tags) - { + public Tags() { + } + + ; + + public Tags(List tags) { this.tags = tags; } - //~--- methods -------------------------------------------------------------- - - /** - * {@inheritDoc} - * - * - * @param obj - * - * @return - */ @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - final Tags other = (Tags) obj; - - return Objects.equal(tags, other.tags); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public int hashCode() - { - return Objects.hashCode(tags); - } - - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public Iterator iterator() - { + public Iterator iterator() { return getTags().iterator(); } - /** - * {@inheritDoc} - * - * - * @return - */ - @Override - public String toString() - { - //J- - return MoreObjects.toStringHelper(this) - .add("tags", tags) - .toString(); - //J+ - } - - //~--- get methods ---------------------------------------------------------- - /** * Returns the {@link Tag} with the given name or null. * - * * @param name name of the tag - * * @return {@link Tag} with the given name or null */ - public Tag getTagByName(String name) - { + public Tag getTagByName(String name) { Tag tag = null; - for (Tag t : getTags()) - { - if (name.equals(t.getName())) - { + for (Tag t : getTags()) { + if (name.equals(t.getName())) { tag = t; break; @@ -166,19 +82,14 @@ public final class Tags implements Iterable /** * Returns the {@link Tag} with the given revision or null. * - * * @param revision revision of the tag - * * @return {@link Tag} with the given revision or null */ - public Tag getTagByRevision(String revision) - { + public Tag getTagByRevision(String revision) { Tag tag = null; - for (Tag t : getTags()) - { - if (revision.equals(t.getRevision())) - { + for (Tag t : getTags()) { + if (revision.equals(t.getRevision())) { tag = t; break; @@ -191,35 +102,13 @@ public final class Tags implements Iterable /** * Returns all tags of a repository. * - * * @return all tags */ - public List getTags() - { - if (tags == null) - { + public List getTags() { + if (tags == null) { tags = Lists.newArrayList(); } return tags; } - - //~--- set methods ---------------------------------------------------------- - - /** - * Sets all tags. - * - * - * @param tags tags - */ - public void setTags(List tags) - { - this.tags = tags; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ - @XmlElement(name = "tag") - private List tags; } diff --git a/scm-core/src/main/java/sonia/scm/repository/api/PushResponse.java b/scm-core/src/main/java/sonia/scm/repository/api/PushResponse.java index 077225b1e6..e639748cc3 100644 --- a/scm-core/src/main/java/sonia/scm/repository/api/PushResponse.java +++ b/scm-core/src/main/java/sonia/scm/repository/api/PushResponse.java @@ -21,39 +21,25 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository.api; -//~--- JDK imports ------------------------------------------------------------ - -import javax.xml.bind.annotation.XmlRootElement; - /** - * The {@link PushResponse} is the result of the + * The {@link PushResponse} is the result of the * {@link PushCommandBuilder#push(sonia.scm.repository.Repository)} method and * contains informations over the executed push command. - * + * * @author Sebastian Sdorra * @since 1.31 */ -@XmlRootElement(name = "push-response") -public final class PushResponse extends AbstractPushOrPullResponse -{ +public final class PushResponse extends AbstractPushOrPullResponse { /** * Constructs a new PushResponse. * - */ - public PushResponse() {} - - /** - * Constructs a new PushResponse. - * - * * @param changesetCount count of pushed changesets */ - public PushResponse(long changesetCount) - { + public PushResponse(long changesetCount) { super(changesetCount); } } diff --git a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgRepositoryHandler.java b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgRepositoryHandler.java index 60ec6f3242..3e8d982e41 100644 --- a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgRepositoryHandler.java +++ b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgRepositoryHandler.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; //~--- non-JDK imports -------------------------------------------------------- @@ -31,7 +31,6 @@ import com.google.inject.Provider; import com.google.inject.Singleton; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import sonia.scm.ConfigurationException; import sonia.scm.SCMContextProvider; import sonia.scm.installer.HgInstaller; import sonia.scm.installer.HgInstallerFactory; @@ -48,7 +47,6 @@ import sonia.scm.util.IOUtil; import sonia.scm.util.SystemUtil; import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -56,87 +54,47 @@ import java.io.InputStream; import java.io.OutputStream; import java.text.MessageFormat; -//~--- JDK imports ------------------------------------------------------------ - -/** - * - * @author Sebastian Sdorra - */ @Singleton @Extension public class HgRepositoryHandler - extends AbstractSimpleRepositoryHandler -{ + extends AbstractSimpleRepositoryHandler { - /** Field description */ public static final String PATH_HOOK = ".hook-1.8"; - - /** Field description */ - public static final String RESOURCE_VERSION = - "sonia/scm/version/scm-hg-plugin"; - - /** Field description */ + public static final String RESOURCE_VERSION = "sonia/scm/version/scm-hg-plugin"; public static final String TYPE_DISPLAYNAME = "Mercurial"; - - /** Field description */ public static final String TYPE_NAME = "hg"; - - /** Field description */ public static final RepositoryType TYPE = new RepositoryType(TYPE_NAME, - TYPE_DISPLAYNAME, - HgRepositoryServiceProvider.COMMANDS, - HgRepositoryServiceProvider.FEATURES); + TYPE_DISPLAYNAME, + HgRepositoryServiceProvider.COMMANDS, + HgRepositoryServiceProvider.FEATURES); - /** the logger for HgRepositoryHandler */ - private static final Logger logger = - LoggerFactory.getLogger(HgRepositoryHandler.class); + private static final Logger logger = LoggerFactory.getLogger(HgRepositoryHandler.class); - /** Field description */ - public static final String PATH_HGRC = - ".hg".concat(File.separator).concat("hgrc"); + public static final String PATH_HGRC = ".hg".concat(File.separator).concat("hgrc"); private static final String CONFIG_SECTION_SCMM = "scmm"; private static final String CONFIG_KEY_REPOSITORY_ID = "repositoryid"; - //~--- constructors --------------------------------------------------------- + private final Provider hgContextProvider; + + private final HgWorkdirFactory workdirFactory; + + private JAXBContext jaxbContext; @Inject public HgRepositoryHandler(ConfigurationStoreFactory storeFactory, Provider hgContextProvider, RepositoryLocationResolver repositoryLocationResolver, - PluginLoader pluginLoader, HgWorkdirFactory workdirFactory) - { + PluginLoader pluginLoader, HgWorkdirFactory workdirFactory) { super(storeFactory, repositoryLocationResolver, pluginLoader); this.hgContextProvider = hgContextProvider; this.workdirFactory = workdirFactory; - - try - { - this.jaxbContext = JAXBContext.newInstance(BrowserResult.class, - BlameResult.class, Changeset.class, ChangesetPagingResult.class, - HgVersion.class); - } - catch (JAXBException ex) - { - throw new ConfigurationException("could not create jaxbcontext", ex); - } } - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param autoConfig - */ - public void doAutoConfiguration(HgConfig autoConfig) - { + public void doAutoConfiguration(HgConfig autoConfig) { HgInstaller installer = HgInstallerFactory.createInstaller(); - try - { - if (logger.isDebugEnabled()) - { + try { + if (logger.isDebugEnabled()) { logger.debug("installing mercurial with {}", installer.getClass().getName()); } @@ -144,161 +102,85 @@ public class HgRepositoryHandler installer.install(baseDirectory, autoConfig); config = autoConfig; storeConfig(); - } - catch (IOException ioe) - { - if (logger.isErrorEnabled()) - { + } catch (IOException ioe) { + if (logger.isErrorEnabled()) { logger.error("Could not write Hg CGI for inital config. " + "HgWeb may not function until a new Hg config is set", ioe); } } } - /** - * Method description - * - * - * @param context - */ @Override - public void init(SCMContextProvider context) - { + public void init(SCMContextProvider context) { super.init(context); writePythonScripts(context); // fix wrong hg.bat from package installation - if (SystemUtil.isWindows()) - { + if (SystemUtil.isWindows()) { HgWindowsPackageFix.fixHgPackage(context, getConfig()); } } - /** - * Method description - * - */ @Override - public void loadConfig() - { + public void loadConfig() { super.loadConfig(); - if (config == null) - { + if (config == null) { doAutoConfiguration(new HgConfig()); } } - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public HgContext getHgContext() - { + public HgContext getHgContext() { HgContext context = hgContextProvider.get(); - if (context == null) - { + if (context == null) { context = new HgContext(); } return context; } - /** - * Method description - * - * - * @return - */ @Override - public ImportHandler getImportHandler() - { + public ImportHandler getImportHandler() { return new HgImportHandler(this); } - /** - * Method description - * - * - * @return - */ - public JAXBContext getJaxbContext() - { - return jaxbContext; - } - - /** - * Method description - * - * - * @return - */ @Override - public RepositoryType getType() - { + public RepositoryType getType() { return TYPE; } - /** - * Method description - * - * - * @return - */ @Override - public String getVersionInformation() - { + public String getVersionInformation() { String version = getStringFromResource(RESOURCE_VERSION, - DEFAULT_VERSION_INFORMATION); + DEFAULT_VERSION_INFORMATION); - try - { + try { HgVersion hgVersion = new HgVersionHandler(this, hgContextProvider.get(), - baseDirectory).getVersion(); + baseDirectory).getVersion(); - if (hgVersion != null) - { - if (logger.isDebugEnabled()) - { + if (hgVersion != null) { + if (logger.isDebugEnabled()) { logger.debug("mercurial/python informations: {}", hgVersion); } version = MessageFormat.format(version, hgVersion.getPython(), hgVersion.getMercurial()); - } - else if (logger.isWarnEnabled()) - { + } else if (logger.isWarnEnabled()) { logger.warn("could not retrieve version informations"); } - } - catch (Exception ex) - { + } catch (Exception ex) { logger.error("could not read version informations", ex); } return version; } - /** - * Method description - * - * - * @param repository - * @param directory - * - * @return - */ @Override protected ExtendedCommand buildCreateCommand(Repository repository, - File directory) - { + File directory) { ExtendedCommand cmd = new ExtendedCommand(config.getHgBinary(), "init", - directory.getAbsolutePath()); + directory.getAbsolutePath()); // copy system environment, because of the PATH variable cmd.setUseSystemEnvironment(true); @@ -315,13 +197,11 @@ public class HgRepositoryHandler * * @param repository * @param directory - * * @throws IOException */ @Override protected void postCreate(Repository repository, File directory) - throws IOException - { + throws IOException { File hgrcFile = new File(directory, PATH_HGRC); INIConfiguration hgrc = new INIConfiguration(); @@ -336,55 +216,30 @@ public class HgRepositoryHandler writer.write(hgrc, hgrcFile); } - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ @Override - protected Class getConfigClass() - { + protected Class getConfigClass() { return HgConfig.class; } - //~--- methods -------------------------------------------------------------- - - /** - * Method description - * - * - * @param context - */ - private void writePythonScripts(SCMContextProvider context) - { + private void writePythonScripts(SCMContextProvider context) { IOUtil.mkdirs(HgPythonScript.getScriptDirectory(context)); - for (HgPythonScript script : HgPythonScript.values()) - { - if (logger.isDebugEnabled()) - { + for (HgPythonScript script : HgPythonScript.values()) { + if (logger.isDebugEnabled()) { logger.debug("write python script {}", script.getName()); } InputStream content = null; OutputStream output = null; - try - { + try { content = HgRepositoryHandler.class.getResourceAsStream( script.getResourcePath()); output = new FileOutputStream(script.getFile(context)); IOUtil.copy(content, output); - } - catch (IOException ex) - { + } catch (IOException ex) { logger.error("could not write script", ex); - } - finally - { + } finally { IOUtil.close(content); IOUtil.close(output); } @@ -395,13 +250,7 @@ public class HgRepositoryHandler return workdirFactory; } - //~--- fields --------------------------------------------------------------- - - /** Field description */ - private final Provider hgContextProvider; - - /** Field description */ - private JAXBContext jaxbContext; - - private final HgWorkdirFactory workdirFactory; + public JAXBContext getJaxbContext() { + return jaxbContext; + } } diff --git a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgVersion.java b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgVersion.java index 7c35f91a28..8e80fb3f84 100644 --- a/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgVersion.java +++ b/scm-plugins/scm-hg-plugin/src/main/java/sonia/scm/repository/HgVersion.java @@ -21,138 +21,19 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.repository; -//~--- non-JDK imports -------------------------------------------------------- +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; - -//~--- JDK imports ------------------------------------------------------------ - -/** - * - * @author Sebastian Sdorra - */ -@XmlRootElement(name = "version") -@XmlAccessorType(XmlAccessType.FIELD) -public class HgVersion -{ - - /** - * Method description - * - * - * @param obj - * - * @return - */ - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) - { - return false; - } - - final HgVersion other = (HgVersion) obj; - - return Objects.equal(mercurial, other.mercurial) - && Objects.equal(python, other.python); - } - - /** - * Method description - * - * - * @return - */ - @Override - public int hashCode() - { - return Objects.hashCode(mercurial, python); - } - - /** - * Method description - * - * - * @return - */ - @Override - public String toString() - { - //J- - return MoreObjects.toStringHelper(this) - .add("mercurial", mercurial) - .add("python", python) - .toString(); - //J+ - } - - //~--- get methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @return - */ - public String getMercurial() - { - return mercurial; - } - - /** - * Method description - * - * - * @return - */ - public String getPython() - { - return python; - } - - //~--- set methods ---------------------------------------------------------- - - /** - * Method description - * - * - * @param mercurial - */ - public void setMercurial(String mercurial) - { - this.mercurial = mercurial; - } - - /** - * Method description - * - * - * @param python - */ - public void setPython(String python) - { - this.python = python; - } - - //~--- fields --------------------------------------------------------------- - - /** Field description */ +@EqualsAndHashCode +@ToString +@Getter +@Setter +public class HgVersion { private String mercurial; - - /** Field description */ private String python; } diff --git a/scm-plugins/scm-hg-plugin/src/test/java/sonia/scm/repository/spi/IncomingOutgoingTestBase.java b/scm-plugins/scm-hg-plugin/src/test/java/sonia/scm/repository/spi/IncomingOutgoingTestBase.java index fb026163ab..6162351148 100644 --- a/scm-plugins/scm-hg-plugin/src/test/java/sonia/scm/repository/spi/IncomingOutgoingTestBase.java +++ b/scm-plugins/scm-hg-plugin/src/test/java/sonia/scm/repository/spi/IncomingOutgoingTestBase.java @@ -42,7 +42,6 @@ import sonia.scm.repository.HgConfig; import sonia.scm.repository.HgContext; import sonia.scm.repository.HgRepositoryHandler; import sonia.scm.repository.HgTestUtil; -import sonia.scm.repository.RepositoryPathNotFoundException; import sonia.scm.user.User; import sonia.scm.user.UserTestData; import sonia.scm.util.MockUtil; @@ -66,11 +65,10 @@ public abstract class IncomingOutgoingTestBase extends AbstractTestBase /** * Method description * - * * @throws IOException */ @Before - public void initHgHandler() throws IOException, RepositoryPathNotFoundException { + public void initHgHandler() throws IOException { HgRepositoryHandler temp = HgTestUtil.createHandler(tempFolder.newFolder()); HgTestUtil.checkForSkip(temp);