1 package com.github.mikkoi.maven.plugins.enforcer.rule.charsetencoding;
2
3 import com.google.common.base.MoreObjects;
4 import com.google.common.collect.ComparisonChain;
5
6 import javax.annotation.Nonnull;
7 import java.nio.file.Path;
8 import java.util.Objects;
9
10
11
12
13 final class FileResult implements Comparable<FileResult> {
14
15 @Nonnull
16 private final Path path;
17
18 private final long lastModified;
19
20 private FileResult(@Nonnull final Builder builder) {
21 this.path = builder.path;
22 this.lastModified = builder.lastModified;
23 }
24
25 @Nonnull
26 Path getPath() {
27 return path;
28 }
29
30 long getLastModified() {
31 return lastModified;
32 }
33
34 @Override
35 public int compareTo(final FileResult that) {
36 return ComparisonChain.start()
37 .compare(this.path.toString(), that.path.toString())
38 .compare(this.lastModified, that.lastModified)
39 .result();
40 }
41
42
43
44
45 @Override
46 public String toString() {
47 return MoreObjects.toStringHelper("FileResult")
48 .add("path", path.toString())
49 .add("lastModified", lastModified)
50 .toString();
51 }
52
53 @Override
54 public int hashCode() {
55 return Objects.hash(path, lastModified);
56 }
57
58 @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
59 @Override
60 public boolean equals(final Object o) {
61 return Objects.equals(this, o);
62 }
63
64
65
66
67 static class Builder {
68 @Nonnull
69 private Path path;
70 private long lastModified = 0;
71
72 Builder(@Nonnull final Path value) {
73 this.path = value;
74 }
75
76 Builder lastModified(final long value) {
77 this.lastModified = value;
78 return this;
79 }
80
81 FileResult build() {
82 return new FileResult(this);
83 }
84 }
85 }