View Javadoc

1   /*
2      Copyright 2008 Ramon Servadei
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 fulmine.rpc;
17  
18  import static fulmine.util.Utils.string;
19  import fulmine.util.reference.is;
20  
21  /**
22   * Standard implementation.
23   * 
24   * @author Ramon Servadei
25   */
26  public final class RpcMarker implements IRpcMarker
27  {
28  
29      /** The ID for the RPC marker */
30      private final int id;
31  
32      /**
33       * Construct the marker with its ID
34       * 
35       * @param id
36       *            the ID for the marker
37       */
38      public RpcMarker(int id)
39      {
40          super();
41          this.id = id;
42      }
43  
44      public int getId()
45      {
46          return this.id;
47      }
48  
49      @Override
50      public String toString()
51      {
52          return string(this, "id=" + this.id);
53      }
54  
55      @Override
56      public int hashCode()
57      {
58          final int prime = 31;
59          int result = 1;
60          result = prime * result + this.id;
61          return result;
62      }
63  
64      @Override
65      public boolean equals(Object obj)
66      {
67          if (is.same(this, obj))
68          {
69              return true;
70          }
71          if (is.differentClass(this, obj))
72          {
73              return false;
74          }
75          RpcMarker other = (RpcMarker) obj;
76          return is.eq(getId(), other.getId());
77      }
78  
79  }