View Javadoc

1   /*
2    * Copyright 2007 Hippo
3    *
4    * Licensed under the Apache License, Version 2.0 (the  "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" 
12   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License.
15   */
16  package nl.hippo.client.webdav.binding.facets;
17  
18  import nl.hippo.client.api.content.FacetValue;
19  
20  import org.apache.commons.lang.builder.EqualsBuilder;
21  import org.apache.commons.lang.builder.HashCodeBuilder;
22  import org.apache.commons.lang.builder.ToStringBuilder;
23  import org.apache.commons.lang.builder.ToStringStyle;
24  
25  public class FacetValueImpl implements FacetValue {
26  
27      private String value;
28      private int hits;
29  
30      private FacetValueImpl() {
31      }
32  
33      public String getValue() {
34          return value;
35      }
36  
37      public int getHits() {
38          return hits;
39      }
40  
41      public String toString() {
42          ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("Value", value)
43                  .append("Hits", hits);
44          return builder.toString();
45      }
46  
47      public boolean equals(Object obj) {
48          if (obj instanceof FacetValueImpl == false) {
49              return false;
50          }
51          if (this == obj) {
52              return true;
53          }
54          FacetValueImpl rhs = (FacetValueImpl) obj;
55          return new EqualsBuilder().append(value, rhs.value).append(hits, rhs.hits).isEquals();
56      }
57  
58      public int hashCode() {
59          return new HashCodeBuilder(83, 7).append(value).append(hits).toHashCode();
60      }
61  
62  }