View Javadoc
1   package org.apache.maven.plugin.cxx.utils.svn;
2   
3   /*
4    * Copyright (C) 2011-2016, Neticoa SAS France - Tous droits réservés.
5    * Author(s) : Franck Bonin, Neticoa SAS France
6    *
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   *
19   */
20   
21  import org.codehaus.plexus.util.StringUtils;
22  
23  /**
24   * svn 
25   * 
26   */
27  public class SvnExternalEntry
28  {
29      public String revision = null;
30      public String origin = null;
31      public String targetDir = null;
32      public String comment = null;
33      
34      public boolean isValide()
35      {
36          return ! StringUtils.isEmpty( comment )
37              || ( ! StringUtils.isEmpty( origin ) && ! StringUtils.isEmpty( targetDir ) );
38      }
39      
40      public String toString()
41      {
42          return "" + ( ( null != comment ) ? comment
43              : ( ( ( null != revision ) ? revision + " " : "" ) + ( ( null != origin ) ? origin : "" )
44              + " " + ( ( null != targetDir ) ? targetDir : "" ) ) );
45      }
46      
47      @Override
48      public boolean equals( Object other )
49      {
50          if ( other == null )
51          {
52              return false;
53          }
54          if ( other == this )
55          {
56              return true;
57          }
58          if ( !( other instanceof SvnExternalEntry ) )
59          {
60              return false;
61          }
62          SvnExternalEntry otherExternalEntry = (SvnExternalEntry) other;
63          // comments are unique, equals shall return false on them
64          if ( null != comment || null != otherExternalEntry.comment )
65          {
66              return false;
67          }
68          // otherwise, entries are equals if their origin or tagetDir are equals
69          return StringUtils.equals( origin, otherExternalEntry.origin )
70              || StringUtils.equals( targetDir, otherExternalEntry.targetDir );
71      }
72      
73      @Override        
74      public int hashCode()
75      {
76          return null != comment ? super.hashCode() // comments are unique, hashCode shall be different for them
77              : null != targetDir ? null != origin 
78                  ? ( origin + targetDir ).hashCode() : targetDir.hashCode()
79              : null != origin ? origin.hashCode() : 0;
80      }
81  }