001/* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014 015package org.basepom.mojo.dvc.model; 016 017import static com.google.common.base.Preconditions.checkNotNull; 018 019import org.basepom.mojo.dvc.QualifiedNameMatcher; 020 021import java.util.Objects; 022 023import com.google.common.base.MoreObjects; 024import com.google.common.collect.ImmutableList; 025 026/** 027 * Represents a "resolver" element in the configuration section. 028 */ 029public final class ResolverDefinition { 030 031 private String strategy = ""; 032 private ImmutableList<QualifiedNameMatcher> includes = ImmutableList.of(); 033 034 public void setStrategy(final String strategy) { 035 this.strategy = checkNotNull(strategy, "strategyName is null"); 036 } 037 038 @SuppressWarnings("PMD.UseVarargs") // called by maven, don't use varargs 039 public void setIncludes(final String[] includes) { 040 checkNotNull(includes, "includes is null"); 041 042 ImmutableList.Builder<QualifiedNameMatcher> builder = ImmutableList.builder(); 043 for (final String include : includes) { 044 builder.add(new QualifiedNameMatcher(include)); 045 } 046 this.includes = builder.build(); 047 } 048 049 public String getStrategy() { 050 return strategy; 051 } 052 053 public ImmutableList<QualifiedNameMatcher> getIncludes() { 054 return includes; 055 } 056 057 @Override 058 public boolean equals(final Object o) { 059 if (this == o) { 060 return true; 061 } 062 if (o == null || getClass() != o.getClass()) { 063 return false; 064 } 065 ResolverDefinition that = (ResolverDefinition) o; 066 return strategy.equals(that.strategy) 067 && includes.equals(that.includes); 068 } 069 070 @Override 071 public int hashCode() { 072 return Objects.hash(strategy, includes); 073 } 074 075 @Override 076 public String toString() { 077 return MoreObjects.toStringHelper(this) 078 .add("strategy", strategy) 079 .add("includes", includes) 080 .toString(); 081 } 082} 083 084