View Javadoc

1   /*
2    * Copyright 2007 Tim Peierls
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" BASIS,
12   * 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 org.directwebremoting.guice;
17  
18  import java.lang.annotation.Annotation;
19  
20  
21  class RemotedImpl implements Remoted 
22  {
23      public RemotedImpl() 
24      {
25          this.value = "";
26      }
27  
28      public RemotedImpl(String value) 
29      {
30          if (value == null)
31          {
32              throw new NullPointerException("@Remoted");
33          }
34          this.value = value;
35      }
36  
37      public String value() 
38      {
39          return this.value;
40      }
41  
42      public Class<? extends Annotation> annotationType() 
43      {
44          return Remoted.class;
45      }
46  
47      public boolean equals(Object t) 
48      {
49          if (!(t instanceof Remoted)) 
50          {
51              return false;
52          }
53  
54          Remoted that = (Remoted) t;
55          return this.value.equals(that.value());
56      }
57  
58      public int hashCode() 
59      {
60          // Annotation spec sez:
61          return 127 * "value".hashCode() ^ value.hashCode();
62      }
63  
64      public String toString() 
65      {
66          return "@" + Remoted.class.getName() + "(value=" + value + ")";
67      }
68  
69      private final String value;
70  }