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 org.apache.maven.model.Dependency;
23  
24  /**
25   * Holds a dependency and packaging information.
26   *
27   * @author Stephane Nicoll
28   * @version $Id$
29   */
30  public class DependencyInfo
31  {
32  
33      private final Dependency dependency;
34  
35      private String targetFileName;
36  
37      /**
38       * Creates a new instance.
39       *
40       * @param dependency the dependency
41       */
42      public DependencyInfo( Dependency dependency )
43      {
44          this.dependency = dependency;
45      }
46  
47      /**
48       * Returns the dependency.
49       *
50       * @return the dependency
51       */
52      public Dependency getDependency()
53      {
54          return dependency;
55      }
56  
57      /**
58       * Returns the target filen ame of the dependency. If no target file name is associated, returns <tt>null</tt>.
59       *
60       * @return the target file name or <tt>null</tt>
61       */
62      public String getTargetFileName()
63      {
64          return targetFileName;
65      }
66  
67      /**
68       * Sets the target file name.
69       *
70       * @param targetFileName the target file name
71       */
72      public void setTargetFileName( String targetFileName )
73      {
74          this.targetFileName = targetFileName;
75      }
76  
77      /**
78       * {@inheritDoc}
79       */
80      public boolean equals( Object o )
81      {
82          if ( this == o )
83          {
84              return true;
85          }
86          if ( o == null || getClass() != o.getClass() )
87          {
88              return false;
89          }
90  
91          DependencyInfo that = (DependencyInfo) o;
92  
93          if ( dependency != null ? !dependency.equals( that.dependency ) : that.dependency != null )
94          {
95              return false;
96          }
97  
98          return true;
99      }
100 
101     /**
102      * {@inheritDoc}
103      */
104     public int hashCode()
105     {
106         int result;
107         result = ( dependency != null ? dependency.hashCode() : 0 );
108         result = 31 * result + ( targetFileName != null ? targetFileName.hashCode() : 0 );
109         return result;
110     }
111 }