View Javadoc

1   package org.apache.onami.autobind.jsr330;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * 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, 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  import static java.lang.String.format;
21  
22  import java.io.Serializable;
23  import java.lang.annotation.Annotation;
24  
25  import javax.inject.Named;
26  
27  @SuppressWarnings( "all" ) // TODO didn't fine the right value to suppress the specific warning
28  class NamedImpl
29      implements Named, Serializable
30  {
31  
32      private static final long serialVersionUID = 0;
33  
34      private final String value;
35  
36      public NamedImpl( String value )
37      {
38          this.value = value;
39      }
40  
41      public String value()
42      {
43          return this.value;
44      }
45  
46      public int hashCode()
47      {
48          // This is specified in java.lang.Annotation.
49          return ( 127 * "value".hashCode() ) ^ value.hashCode();
50      }
51  
52      public boolean equals( Object o )
53      {
54          if ( !( o instanceof Named ) )
55          {
56              return false;
57          }
58  
59          Named other = (Named) o;
60          return value.equals( other.value() );
61      }
62  
63      public String toString()
64      {
65          return format( "@%s(value=%s)", Named.class.getName(), value );
66      }
67  
68      public Class<? extends Annotation> annotationType()
69      {
70          return Named.class;
71      }
72  
73  }