View Javadoc

1   /*
2    * Copyright 2007 Hippo
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" 
12   * BASIS, 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 nl.hippo.client.api.event;
17  
18  import nl.hippo.client.api.caching.SourceValidity;
19  
20  public class EventValidityImpl implements EventValidity {
21  
22      private static final long serialVersionUID = 1L;
23      private NamedEvent m_event;
24  
25      public EventValidityImpl(String name) {
26          m_event = new NamedEvent(name);
27      }
28  
29      /**
30       * Returns the specific NamedEvent this validity is based on.
31       * 
32       * @return Event
33       */
34      public NamedEvent getEvent() {
35          return m_event;
36      }
37  
38      public boolean equals(Object o) {
39          if (o instanceof EventValidity) {
40              return m_event.equals(((EventValidity) o).getEvent());
41          }
42          return false;
43      }
44  
45      public int hashCode() {
46          return m_event.hashCode();
47      }
48  
49      public String toString() {
50          return "EventValidity[" + m_event + "]";
51      }
52  
53      public int isValid() {
54          return VALID;
55      }
56  
57      public int isValid(SourceValidity newValidity) {
58          if (newValidity instanceof EventValidity) {
59              return VALID;
60          }
61          return INVALID;
62      }
63  }