|
1 | 1 | package de.rwth.idsg.steve.ocpp.ws.ocpp15; |
2 | 2 |
|
3 | | -import de.rwth.idsg.steve.ocpp.RequestType; |
4 | | -import de.rwth.idsg.steve.ocpp.ws.TypeStore; |
5 | | -import de.rwth.idsg.steve.ocpp.ws.data.ActionResponsePair; |
6 | | -import ocpp.cp._2012._06.CancelReservationResponse; |
7 | | -import ocpp.cp._2012._06.ChangeAvailabilityResponse; |
8 | | -import ocpp.cp._2012._06.ChangeConfigurationResponse; |
9 | | -import ocpp.cp._2012._06.ClearCacheResponse; |
10 | | -import ocpp.cp._2012._06.DataTransferResponse; |
11 | | -import ocpp.cp._2012._06.GetConfigurationResponse; |
12 | | -import ocpp.cp._2012._06.GetDiagnosticsResponse; |
13 | | -import ocpp.cp._2012._06.GetLocalListVersionResponse; |
14 | | -import ocpp.cp._2012._06.RemoteStartTransactionResponse; |
15 | | -import ocpp.cp._2012._06.RemoteStopTransactionResponse; |
16 | | -import ocpp.cp._2012._06.ReserveNowResponse; |
17 | | -import ocpp.cp._2012._06.ResetResponse; |
18 | | -import ocpp.cp._2012._06.SendLocalListResponse; |
19 | | -import ocpp.cp._2012._06.UnlockConnectorResponse; |
20 | | -import ocpp.cp._2012._06.UpdateFirmwareResponse; |
21 | | -import ocpp.cs._2012._06.AuthorizeRequest; |
22 | | -import ocpp.cs._2012._06.BootNotificationRequest; |
23 | | -import ocpp.cs._2012._06.DiagnosticsStatusNotificationRequest; |
24 | | -import ocpp.cs._2012._06.FirmwareStatusNotificationRequest; |
25 | | -import ocpp.cs._2012._06.HeartbeatRequest; |
26 | | -import ocpp.cs._2012._06.MeterValuesRequest; |
27 | | -import ocpp.cs._2012._06.StartTransactionRequest; |
28 | | -import ocpp.cs._2012._06.StatusNotificationRequest; |
29 | | -import ocpp.cs._2012._06.StopTransactionRequest; |
| 3 | +import de.rwth.idsg.steve.ocpp.ws.AbstractTypeStore; |
30 | 4 |
|
31 | 5 | /** |
32 | 6 | * @author Sevket Goekay <goekay@dbis.rwth-aachen.de> |
33 | 7 | * @since 15.03.2015 |
34 | 8 | */ |
35 | | -public enum Ocpp15TypeStore implements TypeStore { |
36 | | - INSTANCE; |
| 9 | +public final class Ocpp15TypeStore extends AbstractTypeStore { |
37 | 10 |
|
38 | | - @Override |
39 | | - public Class<? extends RequestType> findRequestClass(String action) { |
40 | | - switch (action) { |
41 | | - case "BootNotification": |
42 | | - return BootNotificationRequest.class; |
43 | | - case "FirmwareStatusNotification": |
44 | | - return FirmwareStatusNotificationRequest.class; |
45 | | - case "StatusNotification": |
46 | | - return StatusNotificationRequest.class; |
47 | | - case "MeterValues": |
48 | | - return MeterValuesRequest.class; |
49 | | - case "DiagnosticsStatusNotification": |
50 | | - return DiagnosticsStatusNotificationRequest.class; |
51 | | - case "StartTransaction": |
52 | | - return StartTransactionRequest.class; |
53 | | - case "StopTransaction": |
54 | | - return StopTransactionRequest.class; |
55 | | - case "Heartbeat": |
56 | | - return HeartbeatRequest.class; |
57 | | - case "Authorize": |
58 | | - return AuthorizeRequest.class; |
59 | | - case "DataTransfer": |
60 | | - return ocpp.cs._2012._06.DataTransferRequest.class; |
61 | | - default: |
62 | | - return null; |
63 | | - } |
64 | | - } |
65 | | - |
66 | | - @Override |
67 | | - public <T extends RequestType> ActionResponsePair findActionResponse(T requestPayload) { |
68 | | - switch (requestPayload.getClass().getSimpleName()) { |
69 | | - case "UnlockConnectorRequest": |
70 | | - return new ActionResponsePair("UnlockConnector", UnlockConnectorResponse.class); |
71 | | - case "ResetRequest": |
72 | | - return new ActionResponsePair("Reset", ResetResponse.class); |
73 | | - case "ChangeAvailabilityRequest": |
74 | | - return new ActionResponsePair("ChangeAvailability", ChangeAvailabilityResponse.class); |
75 | | - case "GetDiagnosticsRequest": |
76 | | - return new ActionResponsePair("GetDiagnostics", GetDiagnosticsResponse.class); |
77 | | - case "ClearCacheRequest": |
78 | | - return new ActionResponsePair("ClearCache", ClearCacheResponse.class); |
79 | | - case "UpdateFirmwareRequest": |
80 | | - return new ActionResponsePair("UpdateFirmware", UpdateFirmwareResponse.class); |
81 | | - case "ChangeConfigurationRequest": |
82 | | - return new ActionResponsePair("ChangeConfiguration", ChangeConfigurationResponse.class); |
83 | | - case "RemoteStartTransactionRequest": |
84 | | - return new ActionResponsePair("RemoteStartTransaction", RemoteStartTransactionResponse.class); |
85 | | - case "RemoteStopTransactionRequest": |
86 | | - return new ActionResponsePair("RemoteStopTransaction", RemoteStopTransactionResponse.class); |
| 11 | + public static final Ocpp15TypeStore INSTANCE = new Ocpp15TypeStore(); |
87 | 12 |
|
88 | | - // new in ocpp 1.5 |
89 | | - case "CancelReservationRequest": |
90 | | - return new ActionResponsePair("CancelReservation", CancelReservationResponse.class); |
91 | | - case "DataTransferRequest": |
92 | | - return new ActionResponsePair("DataTransfer", DataTransferResponse.class); |
93 | | - case "GetConfigurationRequest": |
94 | | - return new ActionResponsePair("GetConfiguration", GetConfigurationResponse.class); |
95 | | - case "GetLocalListVersionRequest": |
96 | | - return new ActionResponsePair("GetLocalListVersion", GetLocalListVersionResponse.class); |
97 | | - case "ReserveNowRequest": |
98 | | - return new ActionResponsePair("ReserveNow", ReserveNowResponse.class); |
99 | | - case "SendLocalListRequest": |
100 | | - return new ActionResponsePair("SendLocalList", SendLocalListResponse.class); |
101 | | - default: |
102 | | - return null; |
103 | | - } |
| 13 | + private Ocpp15TypeStore() { |
| 14 | + super("ocpp.cs._2012._06", "ocpp.cp._2012._06"); |
104 | 15 | } |
105 | 16 |
|
106 | 17 | } |
0 commit comments