Package: CecEvent
CecEvent
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CecEvent(CecEvent.EventType) |
|
|
|
|
|
||||||||||||||||||||
canEqual(Object) |
|
|
|
|
|
||||||||||||||||||||
equals(Object) |
|
|
|
|
|
||||||||||||||||||||
getEventType() |
|
|
|
|
|
||||||||||||||||||||
hashCode() |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
Coverage
1: /*
2: * *********************************************************************************************************************
3: *
4: * blueMarine II: Semantic Media Centre
5: * http://tidalwave.it/projects/bluemarine2
6: *
7: * Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/bluemarine2-src
23: * git clone https://github.com/tidalwave-it/bluemarine2-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.cec;
28:
29: import javax.annotation.Nonnull;
30: import javax.annotation.concurrent.Immutable;
31: import it.tidalwave.util.NotFoundException;
32: import it.tidalwave.cec.CecUserControlEvent.UserControlCode;
33: import lombok.EqualsAndHashCode;
34: import lombok.Getter;
35: import lombok.RequiredArgsConstructor;
36: import lombok.ToString;
37: import lombok.experimental.Delegate;
38:
39: /***********************************************************************************************************************
40: *
41: * Abstract base class for all CEC events.
42: *
43: * @see http://www.cec-o-matic.com/
44: *
45: * @author Fabrizio Giudici
46: *
47: **********************************************************************************************************************/
48:•@Immutable @Getter @RequiredArgsConstructor @EqualsAndHashCode @ToString
49: public abstract class CecEvent
50: {
51: /*******************************************************************************************************************
52: *
53: * Defines event types.
54: *
55: ******************************************************************************************************************/
56: @RequiredArgsConstructor @Getter
57: public enum EventType
58: {
59: USER_CONTROL_PRESSED(0x44, (code) -> new CecUserControlEvent(forCode(0x44), UserControlCode.forCode(code))),
60: USER_CONTROL_RELEASED(0x8b, (code) -> new CecUserControlEvent(forCode(0x8b), UserControlCode.forCode(code)));
61:
62: interface CecEventFactory
63: {
64: @Nonnull
65: public CecEvent createEvent (int code)
66: throws NotFoundException;
67: }
68:
69: private final int code;
70:
71: @Delegate @Nonnull
72: private final CecEventFactory eventFactory;
73:
74: @Nonnull
75: public static EventType forCode (final int code)
76: throws NotFoundException
77: {
78: for (final EventType eventType : values())
79: {
80: if (eventType.getCode() == code)
81: {
82: return eventType;
83: }
84: }
85:
86: throw new NotFoundException("CEC event type: " + Integer.toHexString(code));
87: }
88: }
89:
90: @Nonnull
91: private final EventType eventType;
92: }