1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.basepom.mojo.dvc.model;
16
17 import static com.google.common.base.Preconditions.checkNotNull;
18
19 import org.basepom.mojo.dvc.QualifiedNameMatcher;
20
21 import java.util.Objects;
22
23 import com.google.common.base.MoreObjects;
24 import com.google.common.collect.ImmutableList;
25
26
27
28
29 public final class ResolverDefinition {
30
31 private String strategy = "";
32 private ImmutableList<QualifiedNameMatcher> includes = ImmutableList.of();
33
34 public void setStrategy(final String strategy) {
35 this.strategy = checkNotNull(strategy, "strategyName is null");
36 }
37
38 @SuppressWarnings("PMD.UseVarargs")
39 public void setIncludes(final String[] includes) {
40 checkNotNull(includes, "includes is null");
41
42 ImmutableList.Builder<QualifiedNameMatcher> builder = ImmutableList.builder();
43 for (final String include : includes) {
44 builder.add(new QualifiedNameMatcher(include));
45 }
46 this.includes = builder.build();
47 }
48
49 public String getStrategy() {
50 return strategy;
51 }
52
53 public ImmutableList<QualifiedNameMatcher> getIncludes() {
54 return includes;
55 }
56
57 @Override
58 public boolean equals(final Object o) {
59 if (this == o) {
60 return true;
61 }
62 if (o == null || getClass() != o.getClass()) {
63 return false;
64 }
65 ResolverDefinition that = (ResolverDefinition) o;
66 return strategy.equals(that.strategy)
67 && includes.equals(that.includes);
68 }
69
70 @Override
71 public int hashCode() {
72 return Objects.hash(strategy, includes);
73 }
74
75 @Override
76 public String toString() {
77 return MoreObjects.toStringHelper(this)
78 .add("strategy", strategy)
79 .add("includes", includes)
80 .toString();
81 }
82 }
83
84