mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
getting rid of commons-lang in equals(), hashCode() and toString()
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
<orderEntry type="module" module-name="vcs-impl" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
<orderEntry type="library" name="Velocity" level="project" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
@@ -12,15 +12,14 @@
|
||||
// limitations under the License.
|
||||
package org.zmlx.hg4idea;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import com.google.common.base.Objects;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class HgChange {
|
||||
|
||||
private HgFile beforeFile;
|
||||
private HgFile afterFile;
|
||||
private HgFileStatusEnum status;
|
||||
@NotNull private HgFile beforeFile;
|
||||
@NotNull private HgFile afterFile;
|
||||
@NotNull private HgFileStatusEnum status;
|
||||
|
||||
public HgChange(@NotNull HgFile hgFile, @NotNull HgFileStatusEnum status) {
|
||||
this.beforeFile = hgFile;
|
||||
@@ -55,29 +54,34 @@ public final class HgChange {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) {
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(object instanceof HgChange)) {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
HgChange that = (HgChange) object;
|
||||
return new EqualsBuilder()
|
||||
.append(beforeFile, that.beforeFile)
|
||||
.append(afterFile, that.afterFile)
|
||||
.append(status, that.status)
|
||||
.isEquals();
|
||||
|
||||
HgChange change = (HgChange)o;
|
||||
|
||||
if (!afterFile.equals(change.afterFile)) {
|
||||
return false;
|
||||
}
|
||||
if (!beforeFile.equals(change.beforeFile)) {
|
||||
return false;
|
||||
}
|
||||
if (status != change.status) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder()
|
||||
.append(beforeFile)
|
||||
.append(afterFile)
|
||||
.append(status)
|
||||
.toHashCode();
|
||||
return Objects.hashCode(beforeFile, afterFile, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package org.zmlx.hg4idea;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
@@ -19,8 +20,6 @@ import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.command.HgCatCommand;
|
||||
@@ -31,13 +30,13 @@ import java.io.UnsupportedEncodingException;
|
||||
public class HgContentRevision implements ContentRevision {
|
||||
|
||||
private final Project myProject;
|
||||
private final HgFile myHgFile;
|
||||
@NotNull private final HgFile myHgFile;
|
||||
@NotNull private final HgRevisionNumber myRevisionNumber;
|
||||
|
||||
private FilePath filePath;
|
||||
private String content;
|
||||
|
||||
public HgContentRevision(Project project, HgFile hgFile, @NotNull HgRevisionNumber revisionNumber) {
|
||||
public HgContentRevision(Project project, @NotNull HgFile hgFile, @NotNull HgRevisionNumber revisionNumber) {
|
||||
myProject = project;
|
||||
myHgFile = hgFile;
|
||||
myRevisionNumber = revisionNumber;
|
||||
@@ -90,26 +89,28 @@ public class HgContentRevision implements ContentRevision {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder()
|
||||
.append(myHgFile)
|
||||
.append(myRevisionNumber)
|
||||
.toHashCode();
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HgContentRevision revision = (HgContentRevision)o;
|
||||
|
||||
if (!myHgFile.equals(revision.myHgFile)) {
|
||||
return false;
|
||||
}
|
||||
if (!myRevisionNumber.equals(revision.myRevisionNumber)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(object instanceof HgContentRevision)) {
|
||||
return false;
|
||||
}
|
||||
HgContentRevision that = (HgContentRevision) object;
|
||||
return new EqualsBuilder()
|
||||
.append(myHgFile, that.myHgFile)
|
||||
.append(myRevisionNumber, that.myRevisionNumber)
|
||||
.isEquals();
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(myHgFile, myRevisionNumber);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,17 +12,15 @@
|
||||
// limitations under the License.
|
||||
package org.zmlx.hg4idea;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang.builder.ToStringStyle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -86,34 +84,37 @@ public class HgFile {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) {
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(object instanceof HgFile)) {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
HgFile that = (HgFile) object;
|
||||
return new EqualsBuilder()
|
||||
.append(vcsRoot, that.vcsRoot)
|
||||
.append(file, that.file)
|
||||
.isEquals();
|
||||
|
||||
HgFile that = (HgFile)o;
|
||||
|
||||
if (!vcsRoot.equals(that.vcsRoot)) {
|
||||
return false;
|
||||
}
|
||||
if (file != null ? !FileUtil.filesEqual(file, that.file) : that.file != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder()
|
||||
.append(vcsRoot)
|
||||
.append(file)
|
||||
.toHashCode();
|
||||
return Objects.hashCode(vcsRoot, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
|
||||
.append("repo", vcsRoot)
|
||||
.append("file", file)
|
||||
.append("relativePath", getRelativePath())
|
||||
return Objects.toStringHelper(HgFile.class)
|
||||
.add("repo", vcsRoot)
|
||||
.add("file", file)
|
||||
.add("relativePath", getRelativePath())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
// limitations under the License.
|
||||
package org.zmlx.hg4idea;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Throwable2Computable;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.impl.ContentRevisionCache;
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.zmlx.hg4idea.command.HgCatCommand;
|
||||
import org.zmlx.hg4idea.util.HgUtil;
|
||||
|
||||
@@ -33,8 +33,8 @@ import java.util.Set;
|
||||
public class HgFileRevision implements VcsFileRevision {
|
||||
|
||||
private final Project project;
|
||||
private final HgFile hgFile;
|
||||
private final HgRevisionNumber vcsRevisionNumber;
|
||||
@NotNull private final HgFile hgFile;
|
||||
@NotNull private final HgRevisionNumber vcsRevisionNumber;
|
||||
private final String branchName;
|
||||
private final Date revisionDate;
|
||||
private final String author;
|
||||
@@ -44,7 +44,7 @@ public class HgFileRevision implements VcsFileRevision {
|
||||
private final Set<String> filesDeleted;
|
||||
private Map<String,String> filesCopied;
|
||||
|
||||
public HgFileRevision(Project project, HgFile hgFile, HgRevisionNumber vcsRevisionNumber,
|
||||
public HgFileRevision(Project project, @NotNull HgFile hgFile, @NotNull HgRevisionNumber vcsRevisionNumber,
|
||||
String branchName, Date revisionDate, String author, String commitMessage,
|
||||
Set<String> filesModified, Set<String> filesAdded, Set<String> filesDeleted, Map<String, String> filesCopied) {
|
||||
this.project = project;
|
||||
@@ -119,35 +119,38 @@ public class HgFileRevision implements VcsFileRevision {
|
||||
|
||||
public byte[] getContent() throws IOException, VcsException {
|
||||
return ContentRevisionCache.getOrLoadAsBytes(project, hgFile.toFilePath(), getRevisionNumber(), HgVcs.getKey(),
|
||||
ContentRevisionCache.UniqueType.REPOSITORY_CONTENT, new Throwable2Computable<byte[], VcsException, IOException>() {
|
||||
@Override
|
||||
public byte[] compute() throws VcsException, IOException {
|
||||
return loadContent();
|
||||
}
|
||||
});
|
||||
ContentRevisionCache.UniqueType.REPOSITORY_CONTENT,
|
||||
new Throwable2Computable<byte[], VcsException, IOException>() {
|
||||
@Override
|
||||
public byte[] compute() throws VcsException, IOException {
|
||||
return loadContent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HgFileRevision revision = (HgFileRevision)o;
|
||||
|
||||
if (!hgFile.equals(revision.hgFile)) {
|
||||
return false;
|
||||
}
|
||||
if (!vcsRevisionNumber.equals(revision.vcsRevisionNumber)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder()
|
||||
.append(hgFile)
|
||||
.append(vcsRevisionNumber)
|
||||
.toHashCode();
|
||||
return Objects.hashCode(hgFile, vcsRevisionNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(object instanceof HgFileRevision)) {
|
||||
return false;
|
||||
}
|
||||
HgFileRevision that = (HgFileRevision) object;
|
||||
return new EqualsBuilder()
|
||||
.append(hgFile, that.hgFile)
|
||||
.append(vcsRevisionNumber, that.vcsRevisionNumber)
|
||||
.isEquals();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
// limitations under the License.
|
||||
package org.zmlx.hg4idea;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -136,10 +136,7 @@ public class HgRevisionNumber implements VcsRevisionNumber {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder()
|
||||
.append(revision)
|
||||
.append(changeset)
|
||||
.toHashCode();
|
||||
return Objects.hashCode(revision, changeset);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,7 +65,7 @@ abstract class HgRevisionsCommand {
|
||||
HgCommandExecutor executor, VirtualFile repo, String template, int limit, HgFile hgFile
|
||||
);
|
||||
|
||||
public final List<HgFileRevision> execute(HgFile hgFile, int limit, boolean includeFiles) {
|
||||
public final List<HgFileRevision> execute(final HgFile hgFile, int limit, boolean includeFiles) {
|
||||
if ((limit <= 0 && limit != -1) || hgFile == null || hgFile.getRepo() == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -113,7 +113,7 @@ abstract class HgRevisionsCommand {
|
||||
parents.add(HgRevisionNumber.getInstance(parentParts[0], parentParts[1]));
|
||||
}
|
||||
}
|
||||
HgRevisionNumber vcsRevisionNumber = HgRevisionNumber.getInstance(
|
||||
final HgRevisionNumber vcsRevisionNumber = HgRevisionNumber.getInstance(
|
||||
revisionString,
|
||||
changeset,
|
||||
parents
|
||||
|
||||
@@ -34,7 +34,7 @@ class HgCurrentContentRevision extends CurrentContentRevision {
|
||||
return revisionNumber;
|
||||
}
|
||||
|
||||
public static ContentRevision create(HgFile hgFile, HgRevisionNumber revision) {
|
||||
public static ContentRevision create(@NotNull HgFile hgFile, HgRevisionNumber revision) {
|
||||
VirtualFile virtualFile = VcsUtil.getVirtualFile(hgFile.getFile());
|
||||
if (virtualFile == null) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user