View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.websocket.common.events;
20  
21  /**
22   * A representation of the methods available to call for a particular class.
23   * <p>
24   * This class used to cache the method lookups via the {@link EventMethodsCache}
25   */
26  public class EventMethods
27  {
28      private Class<?> pojoClass;
29      public EventMethod onConnect = null;
30      public EventMethod onClose = null;
31      public EventMethod onBinary = null;
32      public EventMethod onText = null;
33      public EventMethod onError = null;
34      public EventMethod onFrame = null;
35  
36      public EventMethods(Class<?> pojoClass)
37      {
38          this.pojoClass = pojoClass;
39      }
40  
41      @Override
42      public boolean equals(Object obj)
43      {
44          if (this == obj)
45          {
46              return true;
47          }
48          if (obj == null)
49          {
50              return false;
51          }
52          if (getClass() != obj.getClass())
53          {
54              return false;
55          }
56          EventMethods other = (EventMethods)obj;
57          if (pojoClass == null)
58          {
59              if (other.pojoClass != null)
60              {
61                  return false;
62              }
63          }
64          else if (!pojoClass.getName().equals(other.pojoClass.getName()))
65          {
66              return false;
67          }
68          return true;
69      }
70  
71      public Class<?> getPojoClass()
72      {
73          return pojoClass;
74      }
75  
76      @Override
77      public int hashCode()
78      {
79          final int prime = 31;
80          int result = 1;
81          result = (prime * result) + ((pojoClass == null)?0:pojoClass.getName().hashCode());
82          return result;
83      }
84  
85      @Override
86      public String toString()
87      {
88          StringBuilder builder = new StringBuilder();
89          builder.append("EventMethods [pojoClass=");
90          builder.append(pojoClass);
91          builder.append(", onConnect=");
92          builder.append(onConnect);
93          builder.append(", onClose=");
94          builder.append(onClose);
95          builder.append(", onBinary=");
96          builder.append(onBinary);
97          builder.append(", onText=");
98          builder.append(onText);
99          builder.append(", onException=");
100         builder.append(onError);
101         builder.append(", onFrame=");
102         builder.append(onFrame);
103         builder.append("]");
104         return builder.toString();
105     }
106 
107 }