View Javadoc

1   package org.apache.archiva.rest.api.model;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  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,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  import javax.xml.bind.annotation.XmlRootElement;
22  import java.io.Serializable;
23  
24  /**
25   * @author Olivier Lamy
26   * @since 1.4-M3
27   */
28  @XmlRootElement( name = "browseResultEntry" )
29  public class BrowseResultEntry
30      implements Comparable<BrowseResultEntry>, Serializable
31  {
32  
33      private String name;
34  
35      private boolean project;
36  
37      public BrowseResultEntry()
38      {
39          // no op
40      }
41  
42      public BrowseResultEntry( String name, boolean project )
43      {
44          this.name = name;
45          this.project = project;
46      }
47  
48      public String getName()
49      {
50          return name;
51      }
52  
53      public void setName( String name )
54      {
55          this.name = name;
56      }
57  
58      public boolean isProject()
59      {
60          return project;
61      }
62  
63      public void setProject( boolean project )
64      {
65          this.project = project;
66      }
67  
68      public int compareTo( BrowseResultEntry browseGroupResultEntry )
69      {
70          return this.name.compareTo( browseGroupResultEntry.name );
71      }
72  
73      @Override
74      public String toString()
75      {
76          final StringBuilder sb = new StringBuilder();
77          sb.append( "BrowseResultEntry" );
78          sb.append( "{name='" ).append( name ).append( '\'' );
79          sb.append( ", project=" ).append( project );
80          sb.append( '}' );
81          return sb.toString();
82      }
83  
84      @Override
85      public boolean equals( Object o )
86      {
87          if ( this == o )
88          {
89              return true;
90          }
91          if ( !( o instanceof BrowseResultEntry ) )
92          {
93              return false;
94          }
95  
96          BrowseResultEntry that = (BrowseResultEntry) o;
97  
98          if ( project != that.project )
99          {
100             return false;
101         }
102         if ( !name.equals( that.name ) )
103         {
104             return false;
105         }
106 
107         return true;
108     }
109 
110     @Override
111     public int hashCode()
112     {
113         int result = name.hashCode();
114         result = 31 * result + ( project ? 1 : 0 );
115         return result;
116     }
117 }