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