View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugins.war.util;
20  
21  import java.util.Objects;
22  
23  import org.apache.maven.model.Dependency;
24  
25  /**
26   * Holds a dependency and packaging information.
27   *
28   * @author Stephane Nicoll
29   */
30  public class DependencyInfo {
31  
32      private final Dependency dependency;
33  
34      private String targetFileName;
35  
36      /**
37       * Creates a new instance.
38       *
39       * @param dependency the dependency
40       */
41      public DependencyInfo(Dependency dependency) {
42          this.dependency = dependency;
43      }
44  
45      /**
46       * Returns the dependency.
47       *
48       * @return the dependency
49       */
50      public Dependency getDependency() {
51          return dependency;
52      }
53  
54      /**
55       * Returns the target filename of the dependency. If no target file name is associated, returns {@code null}.
56       *
57       * @return the target file name or {@code null}
58       */
59      public String getTargetFileName() {
60          return targetFileName;
61      }
62  
63      /**
64       * Sets the target file name.
65       *
66       * @param targetFileName the target file name
67       */
68      public void setTargetFileName(String targetFileName) {
69          this.targetFileName = targetFileName;
70      }
71  
72      @Override
73      public boolean equals(Object o) {
74          if (this == o) {
75              return true;
76          }
77          if (o == null || getClass() != o.getClass()) {
78              return false;
79          }
80  
81          DependencyInfo that = (DependencyInfo) o;
82  
83          return Objects.equals(dependency, that.dependency);
84      }
85  
86      @Override
87      public int hashCode() {
88          int result;
89          result = (dependency != null ? dependency.hashCode() : 0);
90          result = 31 * result + (targetFileName != null ? targetFileName.hashCode() : 0);
91          return result;
92      }
93  }