View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 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.annotated;
20  
21  /**
22   * A representation of the methods available to call for a particular class.
23   */
24  public class EventMethods
25  {
26      private Class<?> pojoClass;
27      public EventMethod onConnect = null;
28      public EventMethod onClose = null;
29      public EventMethod onBinary = null;
30      public EventMethod onText = null;
31      public EventMethod onError = null;
32      public EventMethod onFrame = null;
33  
34      public EventMethods(Class<?> pojoClass)
35      {
36          this.pojoClass = pojoClass;
37      }
38  
39      @Override
40      public boolean equals(Object obj)
41      {
42          if (this == obj)
43          {
44              return true;
45          }
46          if (obj == null)
47          {
48              return false;
49          }
50          if (getClass() != obj.getClass())
51          {
52              return false;
53          }
54          EventMethods other = (EventMethods)obj;
55          if (pojoClass == null)
56          {
57              if (other.pojoClass != null)
58              {
59                  return false;
60              }
61          }
62          else if (!pojoClass.getName().equals(other.pojoClass.getName()))
63          {
64              return false;
65          }
66          return true;
67      }
68  
69      public Class<?> getPojoClass()
70      {
71          return pojoClass;
72      }
73  
74      @Override
75      public int hashCode()
76      {
77          final int prime = 31;
78          int result = 1;
79          result = (prime * result) + ((pojoClass == null)?0:pojoClass.getName().hashCode());
80          return result;
81      }
82  
83      @Override
84      public String toString()
85      {
86          StringBuilder builder = new StringBuilder();
87          builder.append("EventMethods [pojoClass=");
88          builder.append(pojoClass);
89          builder.append(", onConnect=");
90          builder.append(onConnect);
91          builder.append(", onClose=");
92          builder.append(onClose);
93          builder.append(", onBinary=");
94          builder.append(onBinary);
95          builder.append(", onText=");
96          builder.append(onText);
97          builder.append(", onException=");
98          builder.append(onError);
99          builder.append(", onFrame=");
100         builder.append(onFrame);
101         builder.append("]");
102         return builder.toString();
103     }
104 
105 }