diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..f358def67 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "maven" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 77bc9afde..ad803fd1c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -38,11 +38,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -53,7 +53,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v3 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -67,4 +67,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 5eaa3ba54..cce3526a3 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -3,11 +3,7 @@ name: Java CI with Maven -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] +on: [push, pull_request] jobs: build: @@ -15,13 +11,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: - # TODO: Revert to '11'. - # See https://github.com/ChargeTimeEU/Java-OCA-OCPP/pull/223#issuecomment-1328048028 - java-version: '11.0.16+8' + java-version: '11' distribution: 'temurin' cache: maven - name: Build with Maven diff --git a/OCPP-J/build.gradle b/OCPP-J/build.gradle index c96ef980f..c2fcadd21 100644 --- a/OCPP-J/build.gradle +++ b/OCPP-J/build.gradle @@ -4,10 +4,10 @@ dependencies { compile project(':common') - compile 'com.google.code.gson:gson:2.8.0' + compile 'com.google.code.gson:gson:2.8.9' compile 'org.java-websocket:Java-WebSocket:1.5.3' - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' testCompile 'org.hamcrest:hamcrest-core:1.3' } diff --git a/OCPP-J/pom.xml b/OCPP-J/pom.xml index 3cbc07841..872916fb1 100644 --- a/OCPP-J/pom.xml +++ b/OCPP-J/pom.xml @@ -6,7 +6,7 @@ eu.chargetime.ocpp OCPP-J - 1.0.2 + 1.2.0 jar Java-OCA-OCPP OCPP-J @@ -50,41 +50,41 @@ eu.chargetime.ocpp common - 1.0.2 + 1.2.0 com.google.code.gson gson - 2.8.9 + 2.10.1 compile org.java-websocket Java-WebSocket - 1.5.3 + 1.5.4 junit junit - 4.13.1 + 4.13.2 test org.mockito mockito-core - 1.10.19 + 4.11.0 test org.hamcrest hamcrest-core - 1.3 + 2.2 test ch.qos.logback logback-classic - 1.2.3 + 1.4.13 test @@ -98,12 +98,12 @@ 1.8 1.8 - 3.5.1 + 3.11.0 org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.3.0 attach-sources @@ -117,7 +117,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.6.3 attach-javadocs @@ -130,7 +130,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.5 + 3.1.0 sign-artifacts @@ -144,7 +144,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.6.13 true ossrh diff --git a/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java b/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java index 20f150d49..15e937d06 100644 --- a/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java +++ b/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONCommunicator.java @@ -4,9 +4,8 @@ import eu.chargetime.ocpp.model.CallErrorMessage; import eu.chargetime.ocpp.model.CallMessage; import eu.chargetime.ocpp.model.CallResultMessage; -import eu.chargetime.ocpp.model.Message; import eu.chargetime.ocpp.model.Exclude; - +import eu.chargetime.ocpp.model.Message; import java.lang.reflect.Type; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -79,6 +78,16 @@ public JSONCommunicator(Radio radio) { super(radio); } + /** + * Handle required injections. + * + * @param radio instance of the {@link Radio}. + * @param enableTransactionQueue true if transaction queue should be enabled. + */ + public JSONCommunicator(Radio radio, boolean enableTransactionQueue) { + super(radio, enableTransactionQueue); + } + private static class ZonedDateTimeSerializer implements JsonSerializer, JsonDeserializer { @@ -101,17 +110,18 @@ public ZonedDateTime deserialize( static { GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()); - builder.addSerializationExclusionStrategy(new ExclusionStrategy() { - @Override - public boolean shouldSkipClass(Class clazz) { - return false; - } - - @Override - public boolean shouldSkipField(FieldAttributes field) { - return field.getAnnotation(Exclude.class) != null; - } - }); + builder.addSerializationExclusionStrategy( + new ExclusionStrategy() { + @Override + public boolean shouldSkipClass(Class clazz) { + return false; + } + + @Override + public boolean shouldSkipField(FieldAttributes field) { + return field.getAnnotation(Exclude.class) != null; + } + }); gson = builder.disableHtmlEscaping().create(); } @@ -147,26 +157,35 @@ protected Message parse(Object json) { Message message; JsonParser parser = new JsonParser(); JsonArray array = parser.parse(json.toString()).getAsJsonArray(); - - if (array.get(INDEX_MESSAGEID).getAsInt() == TYPENUMBER_CALL) { - message = new CallMessage(); - message.setAction(array.get(INDEX_CALL_ACTION).getAsString()); - message.setPayload(array.get(INDEX_CALL_PAYLOAD).toString()); - } else if (array.get(INDEX_MESSAGEID).getAsInt() == TYPENUMBER_CALLRESULT) { - message = new CallResultMessage(); - message.setPayload(array.get(INDEX_CALLRESULT_PAYLOAD).toString()); - } else if (array.get(INDEX_MESSAGEID).getAsInt() == TYPENUMBER_CALLERROR) { - message = new CallErrorMessage(); - ((CallErrorMessage) message).setErrorCode(array.get(INDEX_CALLERROR_ERRORCODE).getAsString()); - ((CallErrorMessage) message) - .setErrorDescription(array.get(INDEX_CALLERROR_DESCRIPTION).getAsString()); - ((CallErrorMessage) message).setRawPayload(array.get(INDEX_CALLERROR_PAYLOAD).toString()); - } else { - logger.error("Unknown message type of message: {}", json.toString()); - throw new IllegalArgumentException("Unknown message type"); + String messageId = "-1"; + + try { + messageId = array.get(INDEX_UNIQUEID).getAsString(); + if (array.get(INDEX_MESSAGEID).getAsInt() == TYPENUMBER_CALL) { + message = new CallMessage(); + message.setAction(array.get(INDEX_CALL_ACTION).getAsString()); + message.setPayload(array.get(INDEX_CALL_PAYLOAD).toString()); + } else if (array.get(INDEX_MESSAGEID).getAsInt() == TYPENUMBER_CALLRESULT) { + message = new CallResultMessage(); + message.setPayload(array.get(INDEX_CALLRESULT_PAYLOAD).toString()); + } else if (array.get(INDEX_MESSAGEID).getAsInt() == TYPENUMBER_CALLERROR) { + message = new CallErrorMessage(); + ((CallErrorMessage) message).setErrorCode(array.get(INDEX_CALLERROR_ERRORCODE).getAsString()); + ((CallErrorMessage) message) + .setErrorDescription(array.get(INDEX_CALLERROR_DESCRIPTION).getAsString()); + ((CallErrorMessage) message).setRawPayload(array.get(INDEX_CALLERROR_PAYLOAD).toString()); + } else { + logger.error("Unknown message type of message: {}", json.toString()); + sendCallError(messageId, null, "MessageTypeNotSupported", null); + return null; + } + } catch (Exception e) { + logger.error("Exception while parsing message: {}", json.toString()); + sendCallError(messageId, null, "RpcFrameworkError", e.getMessage()); + return null; } - message.setId(array.get(INDEX_UNIQUEID).getAsString()); + message.setId(messageId); return message; } diff --git a/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONConfiguration.java b/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONConfiguration.java index fed44d60a..782550433 100644 --- a/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONConfiguration.java +++ b/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONConfiguration.java @@ -36,8 +36,14 @@ public class JSONConfiguration { public static final String PING_INTERVAL_PARAMETER = "PING_INTERVAL"; public static final String USERNAME_PARAMETER = "USERNAME"; public static final String PASSWORD_PARAMETER = "PASSWORD"; + public static final String CONNECT_NON_BLOCKING_PARAMETER = "CONNECT_NON_BLOCKING"; public static final String CONNECT_TIMEOUT_IN_MS_PARAMETER = "CONNECT_TIMEOUT_IN_MS"; public static final String WEBSOCKET_WORKER_COUNT = "WEBSOCKET_WORKER_COUNT"; + public static final String HTTP_HEALTH_CHECK_ENABLED = "HTTP_HEALTH_CHECK_ENABLED"; + public static final String OCPPJ_CP_MIN_PASSWORD_LENGTH = "OCPPJ_CP_MIN_PASSWORD_LENGTH"; + public static final String OCPPJ_CP_MAX_PASSWORD_LENGTH = "OCPPJ_CP_MAX_PASSWORD_LENGTH"; + public static final String OCPP2J_CP_MIN_PASSWORD_LENGTH = "OCPP2J_CP_MIN_PASSWORD_LENGTH"; + public static final String OCPP2J_CP_MAX_PASSWORD_LENGTH = "OCPP2J_CP_MAX_PASSWORD_LENGTH"; private final HashMap parameters = new HashMap<>(); diff --git a/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java b/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java index 464cc86f0..5eb06e667 100644 --- a/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java +++ b/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketListener.java @@ -166,8 +166,8 @@ public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer( } } if (password == null - || password.length < OCPPJ_CP_MIN_PASSWORD_LENGTH - || password.length > OCPPJ_CP_MAX_PASSWORD_LENGTH) + || password.length < configuration.getParameter(JSONConfiguration.OCPPJ_CP_MIN_PASSWORD_LENGTH, OCPPJ_CP_MIN_PASSWORD_LENGTH) + || password.length > configuration.getParameter(JSONConfiguration.OCPPJ_CP_MAX_PASSWORD_LENGTH, OCPPJ_CP_MAX_PASSWORD_LENGTH)) throw new InvalidDataException(401, "Invalid password length"); } diff --git a/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketTransmitter.java b/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketTransmitter.java index 7ad33c645..d162b7507 100644 --- a/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketTransmitter.java +++ b/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketTransmitter.java @@ -134,13 +134,24 @@ public void onError(Exception ex) { configure(); - logger.debug("Trying to connect to: {}", resource); + boolean isNonBlocking = isNonBlockingParameterSet(); - try { - client.connectBlocking(); - closed = false; - } catch (Exception ex) { - logger.warn("client.connectBlocking() failed", ex); + logger.debug("Trying to connect to: {}{}", resource, isNonBlocking ? "" : " [blocking]"); + + if (isNonBlocking) { + try { + client.connect(); + closed = false; + } catch (Exception ex) { + logger.warn("client.connect() failed", ex); + } + } else { + try { + client.connectBlocking(); + closed = false; + } catch (Exception ex) { + logger.warn("client.connectBlocking() failed", ex); + } } } @@ -175,16 +186,37 @@ public void disconnect() { if (client == null) { return; } - try { - client.closeBlocking(); - } catch (Exception ex) { - logger.info("client.closeBlocking() failed", ex); - } finally { - client = null; - closed = true; + + boolean isNonBlocking = isNonBlockingParameterSet(); + + logger.debug("Disconnecting{}", isNonBlocking ? "" : " [blocking]"); + + if (isNonBlocking) { + try { + client.close(); + } catch (Exception ex) { + logger.info("client.close() failed", ex); + } finally { + client = null; + closed = true; + } + } else { + try { + client.closeBlocking(); + } catch (Exception ex) { + logger.info("client.closeBlocking() failed", ex); + } finally { + client = null; + closed = true; + } } } + private boolean isNonBlockingParameterSet() { + Object rawParam = configuration.getParameter(JSONConfiguration.CONNECT_NON_BLOCKING_PARAMETER); + return rawParam instanceof Boolean ? (Boolean) rawParam : false; + } + @Override public void send(Object request) throws NotConnectedException { if (client == null) { diff --git a/OCPP-J/src/test/java/eu/chargetime/ocpp/wss/test/BaseWssSocketBuilderTest.java b/OCPP-J/src/test/java/eu/chargetime/ocpp/wss/test/BaseWssSocketBuilderTest.java index 6ca62c104..517af993b 100644 --- a/OCPP-J/src/test/java/eu/chargetime/ocpp/wss/test/BaseWssSocketBuilderTest.java +++ b/OCPP-J/src/test/java/eu/chargetime/ocpp/wss/test/BaseWssSocketBuilderTest.java @@ -2,7 +2,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.*; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; import eu.chargetime.ocpp.wss.BaseWssFactoryBuilder; diff --git a/README.md b/README.md index a4e191a0f..a5abddc93 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,14 @@ Java-OCA-OCPP ============= -A client and server library of Open Charge-Point Protocol from openchargealliance.org - -With this library, you can easily get started with the Open Charge-Point Protocol. -The design is driven by test, which will ensure premium software that is easy to adapt and modify to your needs. +A library for the Open Charge-Point Protocol from openchargealliance.org +This library is made to support anyone who wants to implement a Central System or Charge Point that follows the Open Charge-Point Protocol. Please note, this is a library and not an application, so there is no main method. -Currently we support 1.6 SOAP or Web socket. +The design is driven by test, which will ensure premium software that is easy to adapt and modify to your needs. + +The library supports version 2.0.1 and 1.6 SOAP and web sockets. Incoming request events are split into feature profiles as described in the OCPP specification. I recommend that you download and read the specification from openchargealliance.org @@ -20,30 +20,11 @@ I recommend that you download and read the specification from openchargealliance See the project plan here: https://tree.taiga.io/project/tvolden-java-oca-ocpp/ -!! If you have an implementation for 0.4 or earlier, please read: -https://github.com/ChargeTimeEU/Java-OCA-OCPP/wiki/External-interface-change-from-version-0.4-to-0.5 - Maven ===== Find the maven repo here: https://mvnrepository.com/artifact/eu.chargetime.ocpp -Dependencies -============ - -Java-OCA-OCPP uses the following libraries: - -* [Groovy-2.4](http://www.groovy-lang.org/) -* [JUnit4](http://junit.org/junit4/) -* [org.hamcrest:hamcrest-all:1.3](http://hamcrest.org) -* [org.mockito:mockito-core:1.10.19](http://mockito.org) -* [spock-core-0.7-groovy-2.0](http://spockframework.org) - -To use version 1.6 you need the following libraries: - -* [com.google.code.gson](https://github.com/google/gson) -* [org.java_websocket](https://github.com/TooTallNate/Java-WebSocket) - License ======= diff --git a/build.gradle b/build.gradle index ce0935ff9..9309117cf 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ buildscript { allprojects { group = 'eu.chargetime.ocpp' - version = '1.1' + version = '1.2' } subprojects { diff --git a/ocpp-common/build.gradle b/ocpp-common/build.gradle index 18b6757ca..88c6566f7 100644 --- a/ocpp-common/build.gradle +++ b/ocpp-common/build.gradle @@ -5,8 +5,8 @@ dependencies { compile group: 'javax.xml.soap', name: 'javax.xml.soap-api', version: '1.4.0' compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.1' - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' testCompile 'org.hamcrest:hamcrest-all:1.3' } diff --git a/ocpp-common/pom.xml b/ocpp-common/pom.xml index 0ec3f58ae..057b6a672 100644 --- a/ocpp-common/pom.xml +++ b/ocpp-common/pom.xml @@ -6,7 +6,7 @@ eu.chargetime.ocpp common - 1.0.2 + 1.2.0 Java-OCA-OCPP common Implementation of Open Charge-Point Protocol common library. @@ -49,7 +49,7 @@ javax.xml.bind jaxb-api - 2.1 + 2.3.1 javax.xml.soap @@ -61,12 +61,12 @@ org.slf4j slf4j-api - 1.7.25 + 2.0.9 ch.qos.logback logback-classic - 1.2.3 + 1.4.13 test @@ -74,13 +74,13 @@ junit junit - 4.13.1 + 4.13.2 test org.mockito mockito-core - 1.10.19 + 4.11.0 test @@ -99,12 +99,12 @@ 1.8 1.8 - 3.5.1 + 3.11.0 org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.3.0 attach-sources @@ -118,7 +118,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.6.3 attach-javadocs @@ -131,7 +131,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.5 + 3.1.0 sign-artifacts @@ -145,7 +145,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.6.13 true ossrh diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java index 4d389fbde..f0b50941f 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Client.java @@ -44,22 +44,20 @@ of this software and associated documentation files (the "Software"), to deal public class Client { private static final Logger logger = LoggerFactory.getLogger(Client.class); - private ISession session; - private final IFeatureRepository featureRepository; + private final ISession session; private final IPromiseRepository promiseRepository; /** * Handle required injections. * * @param session Inject session object + * @param promiseRepository Inject promise repository * @see Session */ public Client( ISession session, - IFeatureRepository featureRepository, IPromiseRepository promiseRepository) { this.session = session; - this.featureRepository = featureRepository; this.promiseRepository = promiseRepository; } @@ -88,7 +86,7 @@ public void handleConfirmation(String uniqueId, Confirmation confirmation) { @Override public Confirmation handleRequest(Request request) throws UnsupportedFeatureException { - Optional featureOptional = featureRepository.findFeature(request); + Optional featureOptional = session.getFeatureRepository().findFeature(request); if (featureOptional.isPresent()) { return featureOptional.get().handleRequest(getSessionId(), request); } else { @@ -149,7 +147,7 @@ public void disconnect() { */ public CompletableFuture send(Request request) throws UnsupportedFeatureException, OccurenceConstraintException { - Optional featureOptional = featureRepository.findFeature(request); + Optional featureOptional = session.getFeatureRepository().findFeature(request); if (!featureOptional.isPresent()) { logger.error("Can't send request: unsupported feature. Payload: {}", request); throw new UnsupportedFeatureException(); diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Communicator.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Communicator.java index e679e24bb..3422f5769 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Communicator.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Communicator.java @@ -115,9 +115,20 @@ protected abstract Object makeCallError( * @param transmitter Injected {@link Transmitter} */ public Communicator(Radio transmitter) { + this(transmitter, true); + } + + /** + * Handle required injections. + * + * @param transmitter Injected {@link Transmitter} + * @param enableTransactionQueue flag to enable/disable the transaction queue and associated + * processing + */ + public Communicator(Radio transmitter, boolean enableTransactionQueue) { this.radio = transmitter; - this.transactionQueue = new ArrayDeque<>(); - this.retryRunner = new RetryRunner(); + this.transactionQueue = enableTransactionQueue ? new ArrayDeque<>() : null; + this.retryRunner = enableTransactionQueue ? new RetryRunner() : null; this.failedFlag = false; } @@ -164,7 +175,7 @@ public synchronized void sendCall(String uniqueId, String action, Request reques try { if (radio.isClosed()) { - if (request.transactionRelated()) { + if (request.transactionRelated() && transactionQueue != null) { logger.warn("Not connected: storing request to queue: {}", request); transactionQueue.add(call); } else { @@ -175,7 +186,9 @@ public synchronized void sendCall(String uniqueId, String action, Request reques "The request can't be sent due to the lack of connection", request); } - } else if (request.transactionRelated() && transactionQueue.size() > 0) { + } else if (request.transactionRelated() + && transactionQueue != null + && transactionQueue.size() > 0) { transactionQueue.add(call); processTransactionQueue(); } else { @@ -183,7 +196,7 @@ public synchronized void sendCall(String uniqueId, String action, Request reques } } catch (NotConnectedException ex) { logger.warn("sendCall() failed: not connected"); - if (request.transactionRelated()) { + if (request.transactionRelated() && transactionQueue != null) { transactionQueue.add(call); } else { events.onError( @@ -211,7 +224,11 @@ public void sendCallResult(String uniqueId, String action, Confirmation confirma try { completedHandler.onConfirmationCompleted(); } catch (Throwable e) { - events.onError(uniqueId, "ConfirmationCompletedHandlerFailed", "The confirmation completed callback handler failed with exception " + e.toString(), confirmation); + events.onError( + uniqueId, + "ConfirmationCompletedHandlerFailed", + "The confirmation completed callback handler failed with exception " + e.toString(), + confirmation); } } } catch (NotConnectedException ex) { @@ -257,7 +274,7 @@ public void disconnect() { } private synchronized void processTransactionQueue() { - if (!retryRunner.isAlive()) { + if (retryRunner != null && !retryRunner.isAlive()) { if (retryRunner.getState() != Thread.State.NEW) { retryRunner = new RetryRunner(); } @@ -315,7 +332,7 @@ public void disconnected() { */ private Object getRetryMessage() { Object result = null; - if (!transactionQueue.isEmpty()) result = transactionQueue.peek(); + if (transactionQueue != null && !transactionQueue.isEmpty()) result = transactionQueue.peek(); return result; } @@ -329,7 +346,7 @@ private boolean hasFailed() { } private void popRetryMessage() { - if (!transactionQueue.isEmpty()) transactionQueue.pop(); + if (transactionQueue != null && !transactionQueue.isEmpty()) transactionQueue.pop(); } /** Will resend transaction related requests. */ diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/FeatureRepository.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/FeatureRepository.java index ad893ecb4..c83667d7e 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/FeatureRepository.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/FeatureRepository.java @@ -36,9 +36,23 @@ of this software and associated documentation files (the "Software"), to deal public class FeatureRepository implements IFeatureRepository { + private final ProtocolVersion protocolVersion; private final Map actionMap = new HashMap<>(); private final Map, Feature> classMap = new HashMap<>(); + public FeatureRepository() { + this(ProtocolVersion.OCPP1_6); + } + + public FeatureRepository(ProtocolVersion protocolVersion) { + this.protocolVersion = protocolVersion; + } + + @Override + public ProtocolVersion getProtocolVersion() { + return protocolVersion; + } + /** * Add {@link Profile} to support a group of features. * @@ -89,6 +103,7 @@ public Optional findFeature(Object needle) { @Override public String toString() { return MoreObjects.toStringHelper("FeatureRepository") + .add("protocolVersion", protocolVersion) .add("actionMap", actionMap) .add("classMap", classMap) .toString(); diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/IFeatureRepository.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/IFeatureRepository.java index a174dab52..05ca47e5f 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/IFeatureRepository.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/IFeatureRepository.java @@ -29,5 +29,7 @@ of this software and associated documentation files (the "Software"), to deal import java.util.Optional; public interface IFeatureRepository { + ProtocolVersion getProtocolVersion(); + Optional findFeature(Object needle); } diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java index 398c263cb..18ea99383 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/ISession.java @@ -30,6 +30,8 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ public interface ISession { + IFeatureRepository getFeatureRepository(); + UUID getSessionId(); void open(String uri, SessionEvents eventHandler); diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/ProtocolVersion.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/ProtocolVersion.java new file mode 100644 index 000000000..5ec693c65 --- /dev/null +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/ProtocolVersion.java @@ -0,0 +1,58 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2023 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp; + +import java.util.HashMap; +import java.util.Map; + +/** enum of protocol versions along with their registered WebSocket sub-protocol names */ +public enum ProtocolVersion { + OCPP1_6("ocpp1.6"), + OCPP2_0_1("ocpp2.0.1"); + + private static final Map MAP = new HashMap<>(); + + static { + for (ProtocolVersion protocolVersion : ProtocolVersion.values()) { + MAP.put(protocolVersion.subProtocolName, protocolVersion); + } + } + + private final String subProtocolName; + + ProtocolVersion(String subProtocolName) { + this.subProtocolName = subProtocolName; + } + + public static ProtocolVersion fromSubProtocolName(String subProtocolName) { + return MAP.get(subProtocolName); + } + + public String getSubProtocolName() { + return subProtocolName; + } +} diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/SecurityErrorException.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/SecurityErrorException.java new file mode 100644 index 000000000..e7450b0a2 --- /dev/null +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/SecurityErrorException.java @@ -0,0 +1,35 @@ +package eu.chargetime.ocpp; + +/* +ChargeTime.eu - Java-OCA-OCPP +Copyright (C) 2024 Robert Schlabbach + +MIT License + +Copyright (C) 2024 Robert Schlabbach + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +/** A security issue occurred */ +public class SecurityErrorException extends IllegalStateException { + public SecurityErrorException(String s) { + super(s); + } +} diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java index db0c16e24..d62abe934 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Server.java @@ -47,22 +47,20 @@ public class Server { public static final int INITIAL_SESSIONS_NUMBER = 1000; - private Map sessions; - private Listener listener; - private final IFeatureRepository featureRepository; + private final Map sessions; + private final Listener listener; private final IPromiseRepository promiseRepository; /** * Constructor. Handles the required injections. * * @param listener injected listener. + * @param promiseRepository injected promise repository. */ public Server( Listener listener, - IFeatureRepository featureRepository, IPromiseRepository promiseRepository) { this.listener = listener; - this.featureRepository = featureRepository; this.promiseRepository = promiseRepository; this.sessions = new ConcurrentHashMap<>(INITIAL_SESSIONS_NUMBER); } @@ -108,7 +106,7 @@ public void handleConfirmation(String uniqueId, Confirmation confirmation) { @Override public Confirmation handleRequest(Request request) throws UnsupportedFeatureException { - Optional featureOptional = featureRepository.findFeature(request); + Optional featureOptional = session.getFeatureRepository().findFeature(request); if (featureOptional.isPresent()) { Optional sessionIdOptional = getSessionID(session); if (sessionIdOptional.isPresent()) { @@ -200,15 +198,6 @@ public void close() { */ public CompletableFuture send(UUID sessionIndex, Request request) throws UnsupportedFeatureException, OccurenceConstraintException, NotConnectedException { - Optional featureOptional = featureRepository.findFeature(request); - if (!featureOptional.isPresent()) { - throw new UnsupportedFeatureException(); - } - - if (!request.validate()) { - throw new OccurenceConstraintException(); - } - ISession session = sessions.get(sessionIndex); if (session == null) { @@ -218,6 +207,15 @@ public CompletableFuture send(UUID sessionIndex, Request request) throw new NotConnectedException(); } + Optional featureOptional = session.getFeatureRepository().findFeature(request); + if (!featureOptional.isPresent()) { + throw new UnsupportedFeatureException(); + } + + if (!request.validate()) { + throw new OccurenceConstraintException(); + } + String id = session.storeRequest(request); CompletableFuture promise = promiseRepository.createPromise(id); session.sendRequest(featureOptional.get().getAction(), request, id); diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java index 5565b3b00..41a1a6472 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/Session.java @@ -26,6 +26,8 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ +import static eu.chargetime.ocpp.ProtocolVersion.OCPP1_6; + import eu.chargetime.ocpp.feature.Feature; import eu.chargetime.ocpp.model.Confirmation; import eu.chargetime.ocpp.model.Request; @@ -72,6 +74,16 @@ public Session( this.featureRepository = featureRepository; } + /** + * Get the {@link FeatureRepository} used in this session + * + * @return the {@link FeatureRepository} used in this session + */ + @Override + public IFeatureRepository getFeatureRepository() { + return featureRepository; + } + /** * Get a unique session {@link UUID} identifier. * @@ -156,8 +168,8 @@ public void accept(SessionEvents eventHandler) { } private class CommunicatorEventHandler implements CommunicatorEvents { - private static final String OCCURENCE_CONSTRAINT_VIOLATION = - "Payload for Action is syntactically correct but at least one of the fields violates occurence constraints"; + private static final String OCCURRENCE_CONSTRAINT_VIOLATION = + "Payload for Action is syntactically correct but at least one of the fields violates occurrence constraints"; private static final String INTERNAL_ERROR = "An internal error occurred and the receiver was not able to process the requested Action successfully"; private static final String UNABLE_TO_PROCESS = "Unable to process action"; @@ -173,8 +185,8 @@ public void onCallResult(String id, String action, Object payload) { if (confirmation.validate()) { events.handleConfirmation(id, confirmation); } else { - communicator.sendCallError( - id, action, "OccurenceConstraintViolation", OCCURENCE_CONSTRAINT_VIOLATION); + communicator.sendCallError(id, action, isLegacyRPC() ? "OccurenceConstraintViolation" : + "OccurrenceConstraintViolation", OCCURRENCE_CONSTRAINT_VIOLATION); } } else { logger.warn(INTERNAL_ERROR); @@ -188,7 +200,8 @@ public void onCallResult(String id, String action, Object payload) { communicator.sendCallError(id, action, "InternalError", INTERNAL_ERROR); } catch (Exception ex) { logger.warn(UNABLE_TO_PROCESS, ex); - communicator.sendCallError(id, action, "FormationViolation", UNABLE_TO_PROCESS); + communicator.sendCallError(id, action, isLegacyRPC() ? "FormationViolation" : + "FormatViolation", UNABLE_TO_PROCESS); } } @@ -209,15 +222,19 @@ public synchronized void onCall(String id, String action, Object payload) { addPendingPromise(id, action, promise); dispatcher.handleRequest(promise, request); } else { - communicator.sendCallError( - id, action, "OccurenceConstraintViolation", OCCURENCE_CONSTRAINT_VIOLATION); + communicator.sendCallError(id, action, isLegacyRPC() ? "OccurenceConstraintViolation" : + "OccurrenceConstraintViolation", OCCURRENCE_CONSTRAINT_VIOLATION); } } catch (PropertyConstraintException ex) { logger.warn(ex.getMessage(), ex); communicator.sendCallError(id, action, "TypeConstraintViolation", ex.getMessage()); + } catch (SecurityErrorException ex) { + logger.warn(ex.getMessage(), ex); + communicator.sendCallError(id, action, "SecurityError", ex.getMessage()); } catch (Exception ex) { logger.warn(UNABLE_TO_PROCESS, ex); - communicator.sendCallError(id, action, "FormationViolation", UNABLE_TO_PROCESS); + communicator.sendCallError(id, action, isLegacyRPC() ? "FormationViolation" : + "FormatViolation", UNABLE_TO_PROCESS); } } } @@ -236,6 +253,11 @@ public void onDisconnected() { public void onConnected() { events.handleConnectionOpened(); } + + private boolean isLegacyRPC() { + ProtocolVersion protocolVersion = featureRepository.getProtocolVersion(); + return protocolVersion == null || protocolVersion.equals(OCPP1_6); + } } private void addPendingPromise(String id, String action, CompletableFuture promise) { diff --git a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/SessionInformation.java b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/SessionInformation.java index b5ba9a35c..0d7feb3bb 100644 --- a/ocpp-common/src/main/java/eu/chargetime/ocpp/model/SessionInformation.java +++ b/ocpp-common/src/main/java/eu/chargetime/ocpp/model/SessionInformation.java @@ -1,29 +1,32 @@ -package eu.chargetime.ocpp.model; /* - ChargeTime.eu - Java-OCA-OCPP +/* + ChargeTime.eu - Java-OCA-OCPP - MIT License + MIT License - Copyright (C) 2016-2018 Thomas Volden + Copyright (C) 2016-2018 Thomas Volden - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - */ + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +package eu.chargetime.ocpp.model; + +import eu.chargetime.ocpp.ProtocolVersion; import java.net.InetSocketAddress; public class SessionInformation { @@ -32,6 +35,7 @@ public class SessionInformation { private InetSocketAddress address; private String SOAPtoURL; private String proxiedAddress; + private ProtocolVersion protocolVersion; public String getIdentifier() { return identifier; @@ -49,12 +53,17 @@ public String getProxiedAddress() { return proxiedAddress; } + public ProtocolVersion getProtocolVersion() { + return protocolVersion; + } + public static class Builder { private String identifier; private InetSocketAddress address; private String SOAPtoURL; private String proxiedAddress; + private ProtocolVersion protocolVersion = ProtocolVersion.OCPP1_6; public Builder Identifier(String identifier) { this.identifier = identifier; @@ -71,12 +80,18 @@ public Builder ProxiedAddress(String proxiedAddress) { return this; } + public Builder ProtocolVersion(ProtocolVersion protocolVersion) { + this.protocolVersion = protocolVersion; + return this; + } + public SessionInformation build() { SessionInformation sessionInformation = new SessionInformation(); sessionInformation.identifier = this.identifier; sessionInformation.address = this.address; sessionInformation.SOAPtoURL = this.SOAPtoURL; sessionInformation.proxiedAddress = this.proxiedAddress; + sessionInformation.protocolVersion = protocolVersion; return sessionInformation; } diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java index 7ad11ae3b..4c6aebd08 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ClientTest.java @@ -41,7 +41,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ClientTest { @@ -59,12 +59,13 @@ public class ClientTest { @Before public void setup() { when(request.validate()).thenReturn(true); - doAnswer(invocation -> eventHandler = invocation.getArgumentAt(1, SessionEvents.class)) + doAnswer(invocation -> eventHandler = invocation.getArgument(1, SessionEvents.class)) .when(session) .open(any(), any()); - client = new Client(session, featureRepository, promiseRepository); when(featureRepository.findFeature(any())).thenReturn(Optional.of(feature)); + when(session.getFeatureRepository()).thenReturn(featureRepository); + client = new Client(session, promiseRepository); } @Test @@ -76,7 +77,7 @@ public void connect_connects() { client.connect(someUrl, events); // Then - verify(session, times(1)).open(eq(someUrl), anyObject()); + verify(session, times(1)).open(eq(someUrl), any()); } @Test @@ -111,14 +112,15 @@ public void send_aMessage_isCommunicated() throws Exception { client.send(request); // Then - verify(session, times(1)).sendRequest(anyString(), eq(request), anyString()); + // TODO action and uuid should not be nullable + verify(session, times(1)).sendRequest(nullable(String.class), eq(request), nullable(String.class)); } @Test public void responseReceived_aMessageWasSend_PromiseIsCompleted() throws Exception { // Given String someUniqueId = "Some id"; - when(session.storeRequest(any())).thenReturn(someUniqueId); + lenient().when(session.storeRequest(any())).thenReturn(someUniqueId); when(promiseRepository.getPromise(any())).thenReturn(Optional.of(completableFuture)); // When diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java index edf91df41..b506f608e 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/CommunicatorTest.java @@ -1,6 +1,6 @@ package eu.chargetime.ocpp.test; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; import eu.chargetime.ocpp.*; @@ -12,7 +12,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -57,12 +57,15 @@ public void setup() throws Exception { when(transactionRelatedRequest.transactionRelated()).thenReturn(true); when(normalRequest.transactionRelated()).thenReturn(false); - doAnswer(invocation -> eventHandler = invocation.getArgumentAt(0, RadioEvents.class)) + doAnswer(invocation -> eventHandler = invocation.getArgument(0, RadioEvents.class)) .when(receiver) .accept(any()); + setupCommunicator(true); + } + private void setupCommunicator(boolean enableTransactionQueue) throws Exception { communicator = - new Communicator(receiver) { + new Communicator(receiver, enableTransactionQueue) { @Override public T unpackPayload(Object payload, Class type) throws Exception { return null; @@ -94,7 +97,6 @@ protected Message parse(Object message) { return null; } }; - communicator.accept(events); } @@ -202,12 +204,13 @@ public void connected_failedOnceBefore_sameRequestIsRetried() throws Exception { @Test public void confirmationCallback_Handler() { // Given - Confirmation conf = new Confirmation() { - @Override - public boolean validate() { - return true; - } - }; + Confirmation conf = + new Confirmation() { + @Override + public boolean validate() { + return true; + } + }; ConfirmationCompletedHandler handler = mock(ConfirmationCompletedHandler.class); conf.setCompletedHandler(handler); @@ -226,15 +229,35 @@ public boolean validate() { public void confirmationCallback_noHandler() { // Make sure it's not crashing because it has no handler set - Confirmation conf = new Confirmation() { - @Override - public boolean validate() { - return true; - } - }; + Confirmation conf = + new Confirmation() { + @Override + public boolean validate() { + return true; + } + }; String uniqueId = "some id"; String action = "some action"; communicator.sendCallResult(uniqueId, action, conf); } + + @Test + public void + connected_transactionRelatedRequestsQueued_sendIsNotCalled_whenTransactionQueueIsDisabled() + throws Exception { + // Given + setupCommunicator(false); + doThrow(new NotConnectedException()).when(receiver).send(anyString()); + String uniqueId = "some id"; + String action = "some action"; + communicator.sendCall(uniqueId, action, transactionRelatedRequest); + + // When + reset(receiver); + eventHandler.connected(); + Thread.sleep(100); + + verifyNoMoreInteractions(receiver); + } } diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java index 72d0073e7..1fedbe141 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/ServerTest.java @@ -12,7 +12,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -65,18 +65,19 @@ public void setup() { UUID sessionId = UUID.randomUUID(); when(request.validate()).thenReturn(true); when(session.getSessionId()).thenReturn(sessionId); - doAnswer(invocation -> listenerEvents = invocation.getArgumentAt(2, ListenerEvents.class)) + doAnswer(invocation -> listenerEvents = invocation.getArgument(2, ListenerEvents.class)) .when(listener) .open(anyString(), anyInt(), any()); - doAnswer(invocation -> sessionEvents = invocation.getArgumentAt(0, SessionEvents.class)) + doAnswer(invocation -> sessionEvents = invocation.getArgument(0, SessionEvents.class)) .when(session) .accept(any()); - doAnswer(invocation -> sessionIndex = invocation.getArgumentAt(0, UUID.class)) + doAnswer(invocation -> sessionIndex = invocation.getArgument(0, UUID.class)) .when(serverEvents) .newSession(any(), any()); when(featureRepository.findFeature(any())).thenReturn(Optional.of(feature)); - server = new Server(listener, featureRepository, promiseRepository); + when(session.getFeatureRepository()).thenReturn(featureRepository); + server = new Server(listener, promiseRepository); } @Test @@ -113,7 +114,8 @@ public void send_aMessage_isCommunicated() throws Exception { server.send(sessionIndex, request); // Then - verify(session, times(1)).sendRequest(anyString(), eq(request), anyString()); + // TODO action and uuid should not be nullable + verify(session, times(1)).sendRequest(nullable(String.class), eq(request), nullable(String.class)); } @Test diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java index ef55cdfd8..24e92ec7d 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SessionTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -63,7 +63,7 @@ public class SessionTest { public void setup() throws Exception { when(featureRepository.findFeature(any())).thenReturn(Optional.of(feature)); session = new Session(communicator, queue, fulfiller, featureRepository); - doAnswer(invocation -> eventHandler = invocation.getArgumentAt(1, CommunicatorEvents.class)) + doAnswer(invocation -> eventHandler = invocation.getArgument(1, CommunicatorEvents.class)) .when(communicator) .connect(any(), any()); session.open(null, sessionEvents); @@ -103,7 +103,8 @@ public boolean validate() { session.sendRequest(someAction, someRequest, null); // Then - verify(communicator, times(1)).sendCall(anyString(), eq(someAction), eq(someRequest)); + // TODO uniqueid should not be nullable + verify(communicator, times(1)).sendCall(nullable(String.class), eq(someAction), eq(someRequest)); } @Test @@ -115,7 +116,8 @@ public void sendRequest_someUniqueId_sendsUniqueIdToCommunicator() { session.sendRequest(null, null, someUniqueId); // Then - verify(communicator, times(1)).sendCall(eq(someUniqueId), anyString(), any()); + // TODO uuid and request should not be nullable + verify(communicator, times(1)).sendCall(eq(someUniqueId), nullable(String.class), nullable(Request.class)); } @Test @@ -153,7 +155,7 @@ public void open_connectsViaCommunicator() { public void onCall_unhandledCallback_callSendCallError() throws Exception { // Given String someId = "Some id"; - doAnswer(invocation -> invocation.getArgumentAt(0, CompletableFuture.class).complete(null)) + doAnswer(invocation -> invocation.getArgument(0, CompletableFuture.class).complete(null)) .when(fulfiller) .fulfill(any(), any(), any()); when(communicator.unpackPayload(any(), any())).thenReturn(new TestRequest()); @@ -162,7 +164,8 @@ public void onCall_unhandledCallback_callSendCallError() throws Exception { eventHandler.onCall(someId, null, null); // then - verify(communicator, times(1)).sendCallError(eq(someId), anyString(), anyString(), anyString()); + // TODO action should not be nullable + verify(communicator, times(1)).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } @Test @@ -178,7 +181,7 @@ public boolean validate() { doAnswer( invocation -> - invocation.getArgumentAt(0, CompletableFuture.class).complete(aConfirmation)) + invocation.getArgument(0, CompletableFuture.class).complete(aConfirmation)) .when(fulfiller) .fulfill(any(), any(), any()); when(communicator.unpackPayload(any(), any())).thenReturn(new TestRequest()); @@ -187,7 +190,8 @@ public boolean validate() { eventHandler.onCall(someId, null, null); // then - verify(communicator, times(1)).sendCallResult(anyString(), anyString(), eq(aConfirmation)); + // TODO action should not be nullable + verify(communicator, times(1)).sendCallResult(anyString(), nullable(String.class), eq(aConfirmation)); } @Test @@ -197,7 +201,7 @@ public void onCall_callbackThrowsException_callSendCallResult() throws Exception doAnswer( invocation -> invocation - .getArgumentAt(0, CompletableFuture.class) + .getArgument(0, CompletableFuture.class) .completeExceptionally(new Exception())) .when(fulfiller) .fulfill(any(), any(), any()); @@ -207,7 +211,8 @@ public void onCall_callbackThrowsException_callSendCallResult() throws Exception eventHandler.onCall(someId, null, null); // then - verify(communicator, times(1)).sendCallError(eq(someId), anyString(), anyString(), anyString()); + // TODO uniqueid should not be nullable + verify(communicator, times(1)).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } @Test @@ -229,6 +234,7 @@ public void onCall_unknownAction_callSendCallError() { eventHandler.onCall(someId, null, null); // Then - verify(communicator, times(1)).sendCallError(eq(someId), anyString(), anyString(), anyString()); + // TODO uniqueid should not be nullable + verify(communicator, times(1)).sendCallError(eq(someId), nullable(String.class), anyString(), anyString()); } } diff --git a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java index 511cafad1..030808ab9 100644 --- a/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java +++ b/ocpp-common/src/test/java/eu/chargetime/ocpp/test/SimpleRequestDispatcherTest.java @@ -27,7 +27,7 @@ of this software and associated documentation files (the "Software"), to deal import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import eu.chargetime.ocpp.SessionEvents; @@ -38,7 +38,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SimpleRequestDispatcherTest { diff --git a/ocpp-v1_6-example/json-client-implementation/pom.xml b/ocpp-v1_6-example/json-client-implementation/pom.xml index d2c664f94..c4b9e15b5 100644 --- a/ocpp-v1_6-example/json-client-implementation/pom.xml +++ b/ocpp-v1_6-example/json-client-implementation/pom.xml @@ -46,7 +46,7 @@ eu.chargetime.ocpp v1_6 - 1.0.1 + 1.2.0 junit diff --git a/ocpp-v1_6-example/json_server_example/pom.xml b/ocpp-v1_6-example/json_server_example/pom.xml index fc73a1f7b..1d3c6ec93 100644 --- a/ocpp-v1_6-example/json_server_example/pom.xml +++ b/ocpp-v1_6-example/json_server_example/pom.xml @@ -46,7 +46,7 @@ eu.chargetime.ocpp v1_6 - 1.0.1 + 1.2.0 junit diff --git a/ocpp-v1_6-test/pom.xml b/ocpp-v1_6-test/pom.xml index bb850f97b..70365e5af 100644 --- a/ocpp-v1_6-test/pom.xml +++ b/ocpp-v1_6-test/pom.xml @@ -6,7 +6,7 @@ eu.chargetime.ocpp v1_6-test - 1.1.0 + 1.2.0 Java-OCA-OCPP v1.6 - Integration test Integration test of OCA OCPP version 1.6 @@ -49,47 +49,47 @@ eu.chargetime.ocpp common - 1.0.2 + 1.2.0 eu.chargetime.ocpp v1_6 - 1.1.0 + 1.2.0 junit junit - 4.13.1 + 4.13.2 test org.spockframework spock-core - 1.0-groovy-2.4 + 2.3-groovy-4.0 test org.hamcrest hamcrest-core - 1.3 + 2.2 test ch.qos.logback logback-core - 1.2.9 + 1.4.14 test ch.qos.logback logback-classic - 1.2.0 + 1.4.13 test org.slf4j jul-to-slf4j - 1.7.10 + 2.0.12 test @@ -99,7 +99,7 @@ org.codehaus.gmavenplus gmavenplus-plugin - 1.13.1 + 3.0.2 @@ -112,7 +112,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.5.1 + 3.11.0 1.8 1.8 @@ -121,7 +121,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.2.5 true diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java index 75ae81a07..0ec7e8509 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/DummyHandlers.java @@ -226,7 +226,7 @@ public BiConsumer generateWhenCompleteHandler() { return (confirmation, throwable) -> receivedConfirmation = confirmation; } - private T failurePoint(T confirmation) { + T failurePoint(T confirmation) { if (riggedToFail) { riggedToFail = false; throw new RuntimeException(); diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java index 7030e9941..54be7033e 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/FakeChargePoint.java @@ -50,18 +50,18 @@ of this software and associated documentation files (the "Software"), to deal import java.time.ZonedDateTime; public class FakeChargePoint { - private final ClientCoreProfile core; - private final ClientSmartChargingProfile smartCharging; - private final ClientRemoteTriggerProfile remoteTrigger; - private final ClientFirmwareManagementProfile firmware; - private final ClientLocalAuthListProfile localAuthList; - private final ClientReservationProfile reservation; - private final ClientSecurityExtProfile securityExt; - private IClientAPI client; - private Confirmation receivedConfirmation; - private Request receivedRequest; - private Throwable receivedException; - private String url; + final ClientCoreProfile core; + final ClientSmartChargingProfile smartCharging; + final ClientRemoteTriggerProfile remoteTrigger; + final ClientFirmwareManagementProfile firmware; + final ClientLocalAuthListProfile localAuthList; + final ClientReservationProfile reservation; + final ClientSecurityExtProfile securityExt; + IClientAPI client; + Confirmation receivedConfirmation; + Request receivedRequest; + Throwable receivedException; + String url; public FakeChargePoint() throws MalformedURLException { this(clientType.JSON); diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestClient.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestClient.java index 4ecfd98ee..0c9716faa 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestClient.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestClient.java @@ -57,7 +57,7 @@ public JSONTestClient(ClientCoreProfile coreProfile) { JSONCommunicator communicator = new JSONCommunicator(transmitter); featureRepository = new FeatureRepository(); ISession session = new TestSessionFactory(featureRepository).createSession(communicator); - client = new Client(session, featureRepository, new PromiseRepository()); + client = new Client(session, new PromiseRepository()); featureRepository.addFeatureProfile(coreProfile); } diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestServer.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestServer.java index 6cc599e10..615bc11cd 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestServer.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/JSONTestServer.java @@ -60,7 +60,7 @@ public JSONTestServer(ServerCoreProfile coreProfile, JSONConfiguration configura draftOcppOnly = new Draft_6455(Collections.emptyList(), Collections.singletonList(new Protocol("ocpp1.6"))); this.listener = new WebSocketListener(sessionFactory, configuration, draftOcppOnly); - server = new Server(this.listener, featureRepository, new PromiseRepository()); + server = new Server(this.listener, new PromiseRepository()); featureRepository.addFeatureProfile(coreProfile); } diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestClient.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestClient.java index f2c39e635..41fda3ceb 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestClient.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestClient.java @@ -72,7 +72,7 @@ public SOAPTestClient(URL callback, ClientCoreProfile coreProfile) { this.communicator = new SOAPCommunicator(hostInfo, transmitter); featureRepository = new FeatureRepository(); ISession session = new TestSessionFactory(featureRepository).createSession(communicator); - this.client = new Client(session, featureRepository, new PromiseRepository()); + this.client = new Client(session, new PromiseRepository()); featureRepository.addFeatureProfile(coreProfile); } diff --git a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestServer.java b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestServer.java index afc86e6d8..bdf27e210 100644 --- a/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestServer.java +++ b/ocpp-v1_6-test/src/main/java/eu/chargetime/ocpp/test/SOAPTestServer.java @@ -43,7 +43,7 @@ public SOAPTestServer(ServerCoreProfile coreProfile) { featureRepository = new FeatureRepository(); ISessionFactory sessionFactory = new TestSessionFactory(featureRepository); this.listener = new WebServiceListener(sessionFactory); - server = new Server(this.listener, featureRepository, new PromiseRepository()); + server = new Server(this.listener, new PromiseRepository()); featureRepository.addFeatureProfile(coreProfile); } diff --git a/ocpp-v1_6/build.gradle b/ocpp-v1_6/build.gradle index a324cfb3d..6d7b823e4 100644 --- a/ocpp-v1_6/build.gradle +++ b/ocpp-v1_6/build.gradle @@ -7,9 +7,9 @@ dependencies { compile project(':OCPP-J') compile 'org.java-websocket:Java-WebSocket:1.5.3' compile group: 'javax.xml.soap', name: 'javax.xml.soap-api', version: '1.4.0' - - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' testCompile 'org.hamcrest:hamcrest-core:1.3' } diff --git a/ocpp-v1_6/pom.xml b/ocpp-v1_6/pom.xml index 015f21ea6..95c7babc3 100644 --- a/ocpp-v1_6/pom.xml +++ b/ocpp-v1_6/pom.xml @@ -6,7 +6,7 @@ eu.chargetime.ocpp v1_6 - 1.1.0 + 1.2.0 jar Java-OCA-OCPP v1.6 @@ -50,40 +50,40 @@ eu.chargetime.ocpp common - 1.0.2 + 1.2.0 eu.chargetime.ocpp OCPP-J - 1.0.2 + 1.2.0 org.java-websocket Java-WebSocket - 1.5.3 + 1.5.4 junit junit - 4.13.1 + 4.13.2 test org.mockito mockito-core - 1.10.19 + 4.11.0 test org.hamcrest hamcrest-core - 1.3 + 2.2 test ch.qos.logback logback-classic - 1.2.3 + 1.4.13 test @@ -97,12 +97,12 @@ 1.8 1.8 - 3.5.1 + 3.11.0 org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.3.0 attach-sources @@ -116,7 +116,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.6.3 attach-javadocs @@ -129,7 +129,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.5 + 3.1.0 sign-artifacts @@ -143,7 +143,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.6.13 true ossrh diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONClient.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONClient.java index 9dc51f6ed..8615954ba 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONClient.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONClient.java @@ -75,7 +75,7 @@ public JSONClient( JSONCommunicator communicator = new JSONCommunicator(transmitter); featureRepository = new FeatureRepository(); ISession session = new SessionFactory(featureRepository).createSession(communicator); - client = new Client(session, featureRepository, new PromiseRepository()); + client = new Client(session, new PromiseRepository()); featureRepository.addFeatureProfile(coreProfile); } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONServer.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONServer.java index 7ee40af23..b0cc81e42 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONServer.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/JSONServer.java @@ -69,13 +69,13 @@ public JSONServer(ServerCoreProfile coreProfile, JSONConfiguration configuration protocols.add(new Protocol("")); draftOcppOnly = new Draft_6455(Collections.emptyList(), protocols); - if(configuration.getParameter("HTTP_HEALTH_CHECK_ENABLED", true)) { + if(configuration.getParameter(JSONConfiguration.HTTP_HEALTH_CHECK_ENABLED, true)) { logger.info("JSONServer 1.6 with HttpHealthCheckDraft"); this.listener = new WebSocketListener(sessionFactory, configuration, draftOcppOnly, new Draft_HttpHealthCheck()); } else { this.listener = new WebSocketListener(sessionFactory, configuration, draftOcppOnly); } - server = new Server(this.listener, featureRepository, new PromiseRepository()); + server = new Server(this.listener, new PromiseRepository()); featureRepository.addFeatureProfile(coreProfile); } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPClient.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPClient.java index 80965d14a..f0a34c832 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPClient.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPClient.java @@ -79,7 +79,7 @@ public SOAPClient(String chargeBoxIdentity, URL callback, ClientCoreProfile core this.communicator = new SOAPCommunicator(hostInfo, transmitter); featureRepository = new FeatureRepository(); ISession session = new SessionFactory(featureRepository).createSession(communicator); - this.client = new Client(session, featureRepository, new PromiseRepository()); + this.client = new Client(session, new PromiseRepository()); featureRepository.addFeatureProfile(coreProfile); } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPServer.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPServer.java index 98c6fc763..a9c0ab966 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPServer.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/SOAPServer.java @@ -43,7 +43,7 @@ public SOAPServer(ServerCoreProfile coreProfile) { featureRepository = new FeatureRepository(); SessionFactory sessionFactory = new SessionFactory(featureRepository); this.listener = new WebServiceListener(sessionFactory); - server = new Server(this.listener, featureRepository, new PromiseRepository()); + server = new Server(this.listener, new PromiseRepository()); featureRepository.addFeatureProfile(coreProfile); } diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java index ee60263d6..bc27444b0 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/TimeoutSessionDecorator.java @@ -60,6 +60,11 @@ private void startTimer() { if (timeoutTimer != null) timeoutTimer.begin(); } + @Override + public IFeatureRepository getFeatureRepository() { + return session.getFeatureRepository(); + } + @Override public UUID getSessionId() { return session.getSessionId(); diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValue.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValue.java index d8e59f5ca..2fc671123 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValue.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValue.java @@ -67,7 +67,7 @@ public MeterValue(ZonedDateTime timestamp, SampledValue[] sampledValue) { @Override public boolean validate() { - boolean valid = timestamp != null && sampledValue != null; + boolean valid = timestamp != null && sampledValue != null && sampledValue.length > 0; if (valid) { for (SampledValue value : sampledValue) { diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValuesRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValuesRequest.java index c28e5da2c..fd4a35d4f 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValuesRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/MeterValuesRequest.java @@ -64,7 +64,7 @@ public MeterValuesRequest(Integer connectorId) { @Override public boolean validate() { - boolean valid = this.connectorId != null && this.connectorId >= 0 && this.meterValue != null; + boolean valid = this.connectorId != null && this.connectorId >= 0 && this.meterValue != null && meterValue.length > 0; if (valid) { for (MeterValue current : this.meterValue) { diff --git a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/StopTransactionRequest.java b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/StopTransactionRequest.java index 1f46b0c62..58f707a37 100644 --- a/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/StopTransactionRequest.java +++ b/ocpp-v1_6/src/main/java/eu/chargetime/ocpp/model/core/StopTransactionRequest.java @@ -103,7 +103,7 @@ public String getIdTag() { */ @XmlElement public void setIdTag(String idTag) { - if (!ModelUtil.validate(idTag, 20)) { + if (idTag != null && !ModelUtil.validate(idTag, 20)) { throw new PropertyConstraintException(idTag.length(), "Exceeded limit of 20 chars"); } diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java index 997d96537..d0c73ae61 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientCoreProfileTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java index 07442192b..dc18611e1 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientFirmwareManagementProfileTest.java @@ -29,7 +29,7 @@ of this software and associated documentation files (the "Software"), to deal import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -43,7 +43,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ClientFirmwareManagementProfileTest extends ProfileTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java index e4286b89e..2c6837a40 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientLocalAuthListProfileTest.java @@ -28,7 +28,7 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -45,7 +45,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ClientLocalAuthListProfileTest extends ProfileTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java index f8b4d1800..b5055d5fd 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientRemoteTriggerProfileTest.java @@ -16,7 +16,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java index 4edc50d6e..dcc33dd97 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientReservationProfileTest.java @@ -30,7 +30,7 @@ of this software and associated documentation files (the "Software"), to deal import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -47,7 +47,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ClientReservationProfileTest extends ProfileTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java index 47e74d51d..31378f1f8 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ClientSmartChargingProfileTest.java @@ -14,7 +14,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java index 9e8c6370c..576847456 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerCoreProfileTest.java @@ -3,7 +3,7 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -17,7 +17,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java index b937ad829..7ce1e3b73 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerFirmwareManagementProfileTest.java @@ -28,7 +28,7 @@ of this software and associated documentation files (the "Software"), to deal import static org.hamcrest.CoreMatchers.instanceOf; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -45,7 +45,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ServerFirmwareManagementProfileTest extends ProfileTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerLocalAuthListProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerLocalAuthListProfileTest.java index 71576d009..be68e20a1 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerLocalAuthListProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerLocalAuthListProfileTest.java @@ -37,7 +37,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ServerLocalAuthListProfileTest extends ProfileTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerRemoteTriggerProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerRemoteTriggerProfileTest.java index 777eb98b3..f9fcc9f86 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerRemoteTriggerProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerRemoteTriggerProfileTest.java @@ -12,7 +12,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerReservationProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerReservationProfileTest.java index eec5a27bb..47bbcae17 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerReservationProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerReservationProfileTest.java @@ -36,7 +36,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class ServerReservationProfileTest extends ProfileTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerSmartChargingProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerSmartChargingProfileTest.java index 8ab9297b8..582972935 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerSmartChargingProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/ServerSmartChargingProfileTest.java @@ -14,7 +14,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ClientSecurityExtProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ClientSecurityExtProfileTest.java index 95c98fe0d..3378c66f8 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ClientSecurityExtProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ClientSecurityExtProfileTest.java @@ -40,8 +40,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - +import org.mockito.junit.MockitoJUnitRunner; import java.time.ZonedDateTime; import java.util.UUID; diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ServerSecurityExtProfileTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ServerSecurityExtProfileTest.java index 85e74f702..7aa325283 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ServerSecurityExtProfileTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/feature/profile/test/securityext/ServerSecurityExtProfileTest.java @@ -41,8 +41,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - +import org.mockito.junit.MockitoJUnitRunner; import java.util.UUID; import static org.junit.Assert.assertEquals; diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/core/MeterValuesRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/core/MeterValuesRequestTest.java new file mode 100644 index 000000000..cc3d341cb --- /dev/null +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/core/MeterValuesRequestTest.java @@ -0,0 +1,32 @@ +package eu.chargetime.ocpp.model.core; + +import junit.framework.TestCase; + +import java.time.ZonedDateTime; + +public class MeterValuesRequestTest extends TestCase { + + public void testEmptyMeterValuesArray_FailsValidation() { + MeterValuesRequest request = new MeterValuesRequest(1); + request.setTransactionId(2); + request.setMeterValue(new MeterValue[]{}); + assertFalse(request.validate()); + } + + public void testEmptySampledValuesArray_failsValidation() { + MeterValuesRequest request = new MeterValuesRequest(1); + MeterValue measured = new MeterValue(ZonedDateTime.now(), new SampledValue[]{}); + request.setTransactionId(2); + request.setMeterValue(new MeterValue[]{measured}); + assertFalse(request.validate()); + } + + public void testMeterValuesWithAtLeastOneMeasurementPassesValidation() { + MeterValuesRequest request = new MeterValuesRequest(1); + SampledValue sample = new SampledValue("5"); + MeterValue measured = new MeterValue(ZonedDateTime.now(), new SampledValue[]{sample}); + request.setTransactionId(2); + request.setMeterValue(new MeterValue[]{measured}); + assertTrue(request.validate()); + } +} \ No newline at end of file diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionConfirmationTest.java index db8bace37..326a1d132 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionConfirmationTest.java @@ -11,7 +11,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class GetLocalListVersionConfirmationTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionRequestTest.java index c1a6eb086..1e0541d67 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/GetLocalListVersionRequestTest.java @@ -8,7 +8,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class GetLocalListVersionRequestTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListConfirmationTest.java index aba577136..c106aa1dc 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListConfirmationTest.java @@ -12,7 +12,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SendLocalListConfirmationTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java index b46545cd2..371a961ab 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/localauthlist/test/SendLocalListRequestTest.java @@ -20,7 +20,7 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class SendLocalListRequestTest { diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java index 5d798c3d2..9f3e63967 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/AuthorizeConfirmationTest.java @@ -11,7 +11,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetCompositeScheduleRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetCompositeScheduleRequestTest.java index 1baeaad2b..3d6d4b717 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetCompositeScheduleRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/GetCompositeScheduleRequestTest.java @@ -11,7 +11,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java index f5643ad0b..d45c19fa1 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValueTest.java @@ -13,7 +13,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP @@ -107,7 +107,7 @@ public void validate_missingTimestamp_returnFalse() { // Given meterValue.setSampledValue(aList(sampledValueMock)); - when(sampledValueMock.validate()).thenReturn(true); + lenient().when(sampledValueMock.validate()).thenReturn(true); // When boolean isValid = meterValue.validate(); diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java index bcb50c849..35578a927 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/MeterValuesRequestTest.java @@ -14,7 +14,7 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* * ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java index 2f2734ad1..559ff95fb 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/model/test/StopTransactionRequestTest.java @@ -75,6 +75,20 @@ public void setIdTag_moreThan20Chars_throwsPropertyConstraintException() { request.setIdTag(aString(42)); } + @Test + public void setIdTag_nullGiven_doesNotRaiseException() { + request.setIdTag(null); + Assert.assertNull(request.getIdTag()); + } + @Test + public void setIdTag_nullGiven_passesValidation() { + request.setMeterStop(2); + request.setTransactionId(5); + request.setTimestamp(ZonedDateTime.now()); + request.setIdTag(null); + Assert.assertTrue(request.validate()); + } + @Test public void setMeterStop_anInteger_meterStopIsSet() { // Given diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java index 20aba0130..0436cf22a 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/JSONCommunicatorTest.java @@ -19,7 +19,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/SOAPCommunicatorTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/SOAPCommunicatorTest.java index 848974b3c..05e2b3e5a 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/SOAPCommunicatorTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/SOAPCommunicatorTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.w3c.dom.Document; import org.xml.sax.InputSource; diff --git a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java index 9f33fe77d..e1d1f2d22 100644 --- a/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java +++ b/ocpp-v1_6/src/test/java/eu/chargetime/ocpp/test/TimeoutSessionTest.java @@ -1,6 +1,6 @@ package eu.chargetime.ocpp.test; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; import eu.chargetime.ocpp.ISession; @@ -11,7 +11,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; /* ChargeTime.eu - Java-OCA-OCPP @@ -50,10 +50,10 @@ public class TimeoutSessionTest { @Before public void setup() throws Exception { session = new TimeoutSessionDecorator(timeoutTimer, sessionMock); - doAnswer(invocation -> sessionEvents = invocation.getArgumentAt(0, SessionEvents.class)) + doAnswer(invocation -> sessionEvents = invocation.getArgument(0, SessionEvents.class)) .when(sessionMock) .accept(any()); - doAnswer(invocation -> sessionEvents = invocation.getArgumentAt(1, SessionEvents.class)) + doAnswer(invocation -> sessionEvents = invocation.getArgument(1, SessionEvents.class)) .when(sessionMock) .open(any(), any()); } diff --git a/ocpp-v2-test/build.gradle b/ocpp-v2-test/build.gradle new file mode 100644 index 000000000..3ebd002dc --- /dev/null +++ b/ocpp-v2-test/build.gradle @@ -0,0 +1,16 @@ +/* + * This file was generated by the Gradle 'init' task. + */ + +dependencies { + compile project(':common') + compile project(':v1_6') + compile project(':v1_6-test') + compile project(':ocpp-v2') + compile 'com.google.code.findbugs:jsr305:3.0.1' + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' + testCompile 'org.hamcrest:hamcrest-core:1.3' +} + +description = 'Java-OCA-OCPP v2 - Integration test' diff --git a/ocpp-v2-test/pom.xml b/ocpp-v2-test/pom.xml new file mode 100644 index 000000000..afded2e53 --- /dev/null +++ b/ocpp-v2-test/pom.xml @@ -0,0 +1,175 @@ + + + 4.0.0 + + eu.chargetime.ocpp + ocpp-v2-test + 1.2.0 + + Java-OCA-OCPP v2 - Integration test + Integration test of OCA OCPP version 2.x + https://github.com/ChargeTimeEU/Java-OCA-OCPP + + + + MIT License + http://www.opensource.org/licenses/mit-license.php + + + + + + Thomas Volden + tv@chargetime.eu + chargetime.eu + http://www.chargetime.eu + + + + + scm:git:git://github.com/ChargeTimeEU/Java-OCA-OCPP.git + scm:git:ssh://github.com:ChargeTimeEU/Java-OCA-OCPP.git + https://github.com/ChargeTimeEU/Java-OCA-OCPP.git + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2 + + + + + + eu.chargetime.ocpp + common + 1.2.0 + + + eu.chargetime.ocpp + OCPP-J + 1.2.0 + + + eu.chargetime.ocpp + v1_6 + 1.2.0 + + + eu.chargetime.ocpp + v1_6-test + 1.2.0 + + + eu.chargetime.ocpp + ocpp-v2 + 1.2.0 + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + junit + junit + 4.13.2 + test + + + org.mockito + mockito-core + 4.11.0 + test + + + org.spockframework + spock-core + 2.3-groovy-4.0 + test + + + org.hamcrest + hamcrest-core + 2.2 + test + + + ch.qos.logback + logback-core + 1.4.14 + test + + + ch.qos.logback + logback-classic + 1.4.13 + test + + + org.slf4j + jul-to-slf4j + 2.0.12 + test + + + + + + + org.codehaus.gmavenplus + gmavenplus-plugin + 3.0.2 + + + + addTestSources + compileTests + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + true + + **/*Test.java + + + + + integration-test + + test + + integration-test + + + **/*Spec.java + + + + + + + + + diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeCSMS.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeCSMS.java new file mode 100644 index 000000000..e824ca3ee --- /dev/null +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeCSMS.java @@ -0,0 +1,36 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2023 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp.test; + +/** fake charging station management system interface */ +public interface FakeCSMS { + void startServer(); + + int getPort(); + + void stopServer(); +} diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeChargingStation.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeChargingStation.java new file mode 100644 index 000000000..353a842f5 --- /dev/null +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/FakeChargingStation.java @@ -0,0 +1,42 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2023 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp.test; + +import eu.chargetime.ocpp.ProtocolVersion; +import javax.annotation.Nullable; + +/** fake charging station interface */ +public interface FakeChargingStation { + void connect(int port); + + void disconnect(); + + @Nullable + ProtocolVersion getProtocolVersion(); + + void sendBootNotification(String vendor, String model); +} diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolDummyHandlers.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolDummyHandlers.java new file mode 100644 index 000000000..0cdffa80a --- /dev/null +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolDummyHandlers.java @@ -0,0 +1,71 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2023 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp.test; + +import eu.chargetime.ocpp.v201.feature.function.ServerProvisioningEventHandler; +import eu.chargetime.ocpp.v201.model.messages.BootNotificationRequest; +import eu.chargetime.ocpp.v201.model.messages.BootNotificationResponse; +import eu.chargetime.ocpp.v201.model.messages.HeartbeatRequest; +import eu.chargetime.ocpp.v201.model.messages.HeartbeatResponse; +import eu.chargetime.ocpp.v201.model.messages.NotifyReportRequest; +import eu.chargetime.ocpp.v201.model.messages.NotifyReportResponse; +import eu.chargetime.ocpp.v201.model.types.RegistrationStatusEnum; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.UUID; + +/** Dummy handlers for multiple protocol server functions up to OCPP 2.0.1 */ +public class OCPP201MultiProtocolDummyHandlers extends DummyHandlers { + + /* OCPP 2.0.1 Provisioning function handlers */ + + public ServerProvisioningEventHandler createServerProvisioningEventHandler() { + return new ServerProvisioningEventHandler() { + @Override + public BootNotificationResponse handleBootNotificationRequest( + UUID sessionIndex, BootNotificationRequest request) { + BootNotificationResponse response = + new BootNotificationResponse( + ZonedDateTime.now(ZoneOffset.UTC), 20100, RegistrationStatusEnum.Accepted); + return failurePoint(response); + } + + @Override + public HeartbeatResponse handleHeartbeatRequest(UUID sessionIndex, HeartbeatRequest request) { + HeartbeatResponse response = new HeartbeatResponse(ZonedDateTime.now(ZoneOffset.UTC)); + return failurePoint(response); + } + + @Override + public NotifyReportResponse handleNotifyReportRequest( + UUID sessionIndex, NotifyReportRequest request) { + NotifyReportResponse response = new NotifyReportResponse(); + return failurePoint(response); + } + }; + } +} diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeCSMS.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeCSMS.java new file mode 100644 index 000000000..4c13ba23e --- /dev/null +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeCSMS.java @@ -0,0 +1,80 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2023 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp.test; + +import eu.chargetime.ocpp.MultiProtocolJSONServer; +import eu.chargetime.ocpp.ProtocolVersion; +import eu.chargetime.ocpp.feature.profile.ServerCoreProfile; +import eu.chargetime.ocpp.v201.feature.function.ServerProvisioningFunction; +import java.util.List; + +/** Multiple protocol capable fake CSMS supporting up to OCPP 2.0.1 */ +public class OCPP201MultiProtocolFakeCSMS implements FakeCSMS { + + private final MultiProtocolJSONServer server; + private final OCPP201MultiProtocolDummyHandlers dummyHandlers; + + /** + * Constructs the fake Charging Station Management System + * + * @param protocolVersions the {@link ProtocolVersion}s to support, ordered by preference + */ + public OCPP201MultiProtocolFakeCSMS(List protocolVersions) { + server = new MultiProtocolJSONServer(protocolVersions); + dummyHandlers = new OCPP201MultiProtocolDummyHandlers(); + if (protocolVersions.contains(ProtocolVersion.OCPP1_6)) { + server.addFeatureProfile(new ServerCoreProfile(dummyHandlers.createServerCoreEventHandler())); + } + if (protocolVersions.contains(ProtocolVersion.OCPP2_0_1)) { + server.addFunction( + ProtocolVersion.OCPP2_0_1, + new ServerProvisioningFunction(dummyHandlers.createServerProvisioningEventHandler())); + } + } + + /** Starts the fake CSMS server on the local host, using an available port */ + @Override + public void startServer() { + server.open("localhost", 0, dummyHandlers.generateServerEventsHandler()); + } + + /** + * Gets the port number the fake CSMS server is listening on + * + * @return the port number the fake CSMS server is listening on + */ + @Override + public int getPort() { + return server.getPort(); + } + + /** Stops the fake CSMS server */ + @Override + public void stopServer() { + server.close(); + } +} diff --git a/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeChargingStation.java b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeChargingStation.java new file mode 100644 index 000000000..1322ec943 --- /dev/null +++ b/ocpp-v2-test/src/main/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolFakeChargingStation.java @@ -0,0 +1,212 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2023 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp.test; + +import static eu.chargetime.ocpp.ProtocolVersion.OCPP1_6; +import static eu.chargetime.ocpp.ProtocolVersion.OCPP2_0_1; + +import eu.chargetime.ocpp.MultiProtocolJSONClient; +import eu.chargetime.ocpp.OccurenceConstraintException; +import eu.chargetime.ocpp.ProtocolVersion; +import eu.chargetime.ocpp.UnsupportedFeatureException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.model.core.BootNotificationConfirmation; +import eu.chargetime.ocpp.v201.feature.function.ClientProvisioningEventHandler; +import eu.chargetime.ocpp.v201.feature.function.ClientProvisioningFunction; +import eu.chargetime.ocpp.v201.model.messages.BootNotificationResponse; +import eu.chargetime.ocpp.v201.model.messages.GetBaseReportRequest; +import eu.chargetime.ocpp.v201.model.messages.GetBaseReportResponse; +import eu.chargetime.ocpp.v201.model.messages.GetReportRequest; +import eu.chargetime.ocpp.v201.model.messages.GetReportResponse; +import eu.chargetime.ocpp.v201.model.messages.GetVariablesRequest; +import eu.chargetime.ocpp.v201.model.messages.GetVariablesResponse; +import eu.chargetime.ocpp.v201.model.messages.ResetRequest; +import eu.chargetime.ocpp.v201.model.messages.ResetResponse; +import eu.chargetime.ocpp.v201.model.messages.SetNetworkProfileRequest; +import eu.chargetime.ocpp.v201.model.messages.SetNetworkProfileResponse; +import eu.chargetime.ocpp.v201.model.messages.SetVariablesRequest; +import eu.chargetime.ocpp.v201.model.messages.SetVariablesResponse; +import eu.chargetime.ocpp.v201.model.types.BootReasonEnum; +import eu.chargetime.ocpp.v201.model.types.ChargingStation; +import eu.chargetime.ocpp.v201.model.types.GenericDeviceModelStatusEnum; +import eu.chargetime.ocpp.v201.model.types.GetVariableResult; +import eu.chargetime.ocpp.v201.model.types.Modem; +import eu.chargetime.ocpp.v201.model.types.ResetStatusEnum; +import eu.chargetime.ocpp.v201.model.types.SetNetworkProfileStatusEnum; +import eu.chargetime.ocpp.v201.model.types.SetVariableResult; +import java.net.MalformedURLException; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.CompletableFuture; +import java.util.function.BiConsumer; +import javax.annotation.Nullable; + +/** Multiple protocol capable fake charging station supporting up to OCPP 2.0.1 */ +public class OCPP201MultiProtocolFakeChargingStation extends FakeChargePoint + implements FakeChargingStation { + final ClientProvisioningFunction provisioning; + + MultiProtocolJSONClient multiProtocolJSONClient; + + public OCPP201MultiProtocolFakeChargingStation(List protocolVersions) + throws MalformedURLException { + super(); + + provisioning = + new ClientProvisioningFunction( + new ClientProvisioningEventHandler() { + @Override + public GetBaseReportResponse handleGetBaseReportRequest( + GetBaseReportRequest request) { + receivedRequest = request; + return new GetBaseReportResponse(GenericDeviceModelStatusEnum.Accepted); + } + + @Override + public GetReportResponse handleGetReportRequest(GetReportRequest request) { + receivedRequest = request; + return new GetReportResponse(GenericDeviceModelStatusEnum.Accepted); + } + + @Override + public GetVariablesResponse handleGetVariablesRequest(GetVariablesRequest request) { + receivedRequest = request; + return new GetVariablesResponse(new GetVariableResult[] {}); + } + + @Override + public ResetResponse handleResetRequest(ResetRequest request) { + receivedRequest = request; + return new ResetResponse(ResetStatusEnum.Accepted); + } + + @Override + public SetNetworkProfileResponse handleSetNetworkProfileRequest( + SetNetworkProfileRequest request) { + receivedRequest = request; + return new SetNetworkProfileResponse(SetNetworkProfileStatusEnum.Accepted); + } + + @Override + public SetVariablesResponse handleSetVariablesRequest(SetVariablesRequest request) { + receivedRequest = request; + return new SetVariablesResponse(new SetVariableResult[] {}); + } + }); + + multiProtocolJSONClient = new MultiProtocolJSONClient(protocolVersions); + + // overwrite super client instance with multiple protocol capable object instance + client = multiProtocolJSONClient; + + if (protocolVersions.contains(OCPP1_6)) { + client.addFeatureProfile(core); + client.addFeatureProfile(firmware); + client.addFeatureProfile(localAuthList); + client.addFeatureProfile(reservation); + client.addFeatureProfile(smartCharging); + client.addFeatureProfile(remoteTrigger); + client.addFeatureProfile(securityExt); + } + + if (protocolVersions.contains(OCPP2_0_1)) { + multiProtocolJSONClient.addFunction(OCPP2_0_1, provisioning); + } + } + + @Override + public void connect(int port) { + url = "ws://localhost:" + port; + super.connect(); + } + + @Override + @Nullable + public ProtocolVersion getProtocolVersion() { + return multiProtocolJSONClient.getProtocolVersion(); + } + + @Override + public void sendBootNotification(String vendor, String model) { + Request request; + Class responseClass; + switch (Objects.requireNonNull(getProtocolVersion())) { + case OCPP1_6: + request = core.createBootNotificationRequest(vendor, model); + responseClass = BootNotificationConfirmation.class; + break; + case OCPP2_0_1: + request = + provisioning.createBootNotificationRequest( + new ChargingStation(model, vendor) + .withSerialNumber("123456789") + .withFirmwareVersion("0.0.1") + .withModem(new Modem().withImsi("1851").withIccid("16610")), + BootReasonEnum.Unknown); + responseClass = BootNotificationResponse.class; + break; + default: + throw new UnsupportedOperationException( + "Connected with unsupported protocol version " + getProtocolVersion()); + } + sendRequestAndWaitForResponse(request, responseClass); + } + + void sendRequestAndWaitForResponse(Request request, Class responseClass) { + try { + CompletableFuture future = client.send(request).toCompletableFuture(); + BiConsumer action = + (confirmation, throwable) -> { + if (confirmation != null) { + receivedConfirmation = confirmation; + receivedException = null; + } else if (throwable != null) { + receivedConfirmation = null; + receivedException = throwable; + } else { + receivedConfirmation = null; + receivedException = null; + } + }; + future.whenComplete(action); + future.join(); + } catch (OccurenceConstraintException | UnsupportedFeatureException e) { + throw new RuntimeException(e); + } + if (receivedException != null) { + throw new RuntimeException("Received exception in response to request", receivedException); + } + if (receivedConfirmation != null) { + if (!responseClass.isInstance(receivedConfirmation)) { + throw new IllegalArgumentException("Received confirmation is not of expected class"); + } + } else { + throw new IllegalStateException("Received neither a confirmation nor a throwable"); + } + } +} diff --git a/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolIntegrationTest.java b/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolIntegrationTest.java new file mode 100644 index 000000000..e2a2f0635 --- /dev/null +++ b/ocpp-v2-test/src/test/java/eu/chargetime/ocpp/test/OCPP201MultiProtocolIntegrationTest.java @@ -0,0 +1,132 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2023 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp.test; + +import static eu.chargetime.ocpp.ProtocolVersion.OCPP1_6; +import static eu.chargetime.ocpp.ProtocolVersion.OCPP2_0_1; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNot.not; + +import eu.chargetime.ocpp.ProtocolVersion; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; + +/** multiple protocol capable client and server integration test up to OCPP 2.0.1 */ +@RunWith(MockitoJUnitRunner.class) +public class OCPP201MultiProtocolIntegrationTest { + + private static final List OCPP1_6_ONLY = Collections.singletonList(OCPP1_6); + private static final List OCPP2_0_1_ONLY = Collections.singletonList(OCPP2_0_1); + private static final List OCPP1_6_FIRST = Arrays.asList(OCPP1_6, OCPP2_0_1); + private static final List OCPP2_0_1_FIRST = Arrays.asList(OCPP2_0_1, OCPP1_6); + + private List csmsList; + + @Before + public void setup() { + csmsList = new ArrayList<>(); + } + + @After + public void teardown() { + for (FakeCSMS csms : csmsList) { + csms.stopServer(); + } + } + + private FakeCSMS setupAndStartCSMS(List protocolVersions) { + FakeCSMS csms = new OCPP201MultiProtocolFakeCSMS(protocolVersions); + csmsList.add(csms); + csms.startServer(); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + assertThat(csms.getPort(), not(0)); + return csms; + } + + private FakeChargingStation buildAndConnectChargingStation( + List protocolVersions, FakeCSMS csms) { + FakeChargingStation cs; + try { + cs = new OCPP201MultiProtocolFakeChargingStation(protocolVersions); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + cs.connect(csms.getPort()); + return cs; + } + + private void reconnectChargingStation(FakeChargingStation cs, FakeCSMS csms) { + cs.disconnect(); + cs.connect(csms.getPort()); + } + + @Test + public void testMultiProtocolChargingStationReconnectingWithDifferentProtocolVersions() { + FakeCSMS ocpp16OnlyCSMS = setupAndStartCSMS(OCPP1_6_ONLY); + FakeChargingStation cs = buildAndConnectChargingStation(OCPP2_0_1_FIRST, ocpp16OnlyCSMS); + assertThat(cs.getProtocolVersion(), is(OCPP1_6)); + cs.sendBootNotification("vendor", "model"); + + FakeCSMS ocpp201OnlyCSMS = setupAndStartCSMS(OCPP2_0_1_ONLY); + reconnectChargingStation(cs, ocpp201OnlyCSMS); + assertThat(cs.getProtocolVersion(), is(OCPP2_0_1)); + cs.sendBootNotification("vendor", "model"); + + reconnectChargingStation(cs, ocpp16OnlyCSMS); + assertThat(cs.getProtocolVersion(), is(OCPP1_6)); + cs.sendBootNotification("vendor", "model"); + } + + @Test + public void testMultiProtocolCsmsRunningParallelSessionsWithDifferentProtocolVersions() { + FakeCSMS csms = setupAndStartCSMS(OCPP2_0_1_FIRST); + + FakeChargingStation cs16 = buildAndConnectChargingStation(OCPP1_6_ONLY, csms); + cs16.sendBootNotification("vendor", "model"); + + FakeChargingStation cs201 = buildAndConnectChargingStation(OCPP2_0_1_ONLY, csms); + cs201.sendBootNotification("vendor", "model"); + + reconnectChargingStation(cs16, csms); + cs16.sendBootNotification("vendor", "model"); + + cs201.sendBootNotification("vendor", "model"); + } +} diff --git a/ocpp-v2/build.gradle b/ocpp-v2/build.gradle new file mode 100644 index 000000000..666c85463 --- /dev/null +++ b/ocpp-v2/build.gradle @@ -0,0 +1,22 @@ +/* + * This file was generated by the Gradle 'init' task. + */ + +dependencies { + compile project(':common') + compile project(':OCPP-J') + compile project(':v1_6') + compile 'com.google.code.findbugs:jsr305:3.0.1' + compile 'org.java-websocket:Java-WebSocket:1.5.3' + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' + testCompile 'org.hamcrest:hamcrest-core:1.3' +} + +task javadocJar(type: Jar) { + classifier = 'javadoc' + from(javadoc.destinationDir) +} + +description = 'Java-OCA-OCPP v2' +publishing.publications.maven.artifact(javadocJar) diff --git a/ocpp-v2/pom.xml b/ocpp-v2/pom.xml new file mode 100644 index 000000000..ec80d1290 --- /dev/null +++ b/ocpp-v2/pom.xml @@ -0,0 +1,167 @@ + + + 4.0.0 + + eu.chargetime.ocpp + ocpp-v2 + 1.2.0 + jar + + Java-OCA-OCPP v2 + Implementation of Open Charge-Point Protocol version 2.x. + https://github.com/ChargeTimeEU/Java-OCA-OCPP + + + + MIT License + http://www.opensource.org/licenses/mit-license.php + + + + + + Thomas Volden + tv@chargetime.eu + chargetime.eu + http://www.chargetime.eu + + + + + scm:git:git://github.com/ChargeTimeEU/Java-OCA-OCPP.git + scm:git:ssh://github.com:ChargeTimeEU/Java-OCA-OCPP.git + https://github.com/ChargeTimeEU/Java-OCA-OCPP.git + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2 + + + + + + eu.chargetime.ocpp + common + 1.2.0 + + + eu.chargetime.ocpp + OCPP-J + 1.2.0 + + + eu.chargetime.ocpp + v1_6 + 1.2.0 + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + org.java-websocket + Java-WebSocket + 1.5.4 + + + junit + junit + 4.13.2 + test + + + org.mockito + mockito-core + 4.11.0 + test + + + org.hamcrest + hamcrest-core + 2.2 + test + + + ch.qos.logback + logback-classic + 1.4.13 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + 3.11.0 + + + org.apache.maven.plugins + maven-source-plugin + 3.3.0 + + + attach-sources + verify + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.6.3 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.1.0 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://oss.sonatype.org/ + true + + + + + + diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/IMultiProtocolClientAPI.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/IMultiProtocolClientAPI.java new file mode 100644 index 000000000..af2c5b76d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/IMultiProtocolClientAPI.java @@ -0,0 +1,55 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * MIT License + * + * Copyright (C) 2023 Robert Schlabbach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp; + +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.feature.profile.Profile; + +public interface IMultiProtocolClientAPI extends IClientAPI { + /** + * Adds an OCPP 1.x profile implementation for a given protocol version + * + * @param protocolVersion the {@link ProtocolVersion} + * @param profile the {@link Profile} implementation to add + */ + void addFeatureProfile(ProtocolVersion protocolVersion, Profile profile); + + /** + * Adds an OCPP 2.x function implementation for a given protocol version + * + * @param protocolVersion the {@link ProtocolVersion} + * @param function the {@link Function} implementation to add + */ + void addFunction(ProtocolVersion protocolVersion, Function function); + + /** + * Returns the protocol version selected by the server + * + * @return the {@link ProtocolVersion} selected by the server, or {@code null} if not connected + */ + ProtocolVersion getProtocolVersion(); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/IMultiProtocolServerAPI.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/IMultiProtocolServerAPI.java new file mode 100644 index 000000000..44b3f5841 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/IMultiProtocolServerAPI.java @@ -0,0 +1,55 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * MIT License + * + * Copyright (C) 2023 Robert Schlabbach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp; + +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.feature.profile.Profile; + +public interface IMultiProtocolServerAPI extends IServerAPI { + /** + * Adds an OCPP 1.x profile implementation for a given protocol version + * + * @param protocolVersion the {@link ProtocolVersion} + * @param profile the {@link Profile} implementation to add + */ + void addFeatureProfile(ProtocolVersion protocolVersion, Profile profile); + + /** + * Adds an OCPP 2.x function implementation for a given protocol version + * + * @param protocolVersion the {@link ProtocolVersion} + * @param function the {@link Function} implementation to add + */ + void addFunction(ProtocolVersion protocolVersion, Function function); + + /** + * Returns the port number the server is listening on + * + * @return the port number the server is listening on, or 0 if the server is not running + */ + int getPort(); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolFeatureRepository.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolFeatureRepository.java new file mode 100644 index 000000000..916508e64 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolFeatureRepository.java @@ -0,0 +1,102 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2023 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp; + +import eu.chargetime.ocpp.feature.Feature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.feature.profile.Profile; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import javax.annotation.Nullable; + +/** Feature repository managing the feature repositories for multiple protocol versions */ +public class MultiProtocolFeatureRepository implements IFeatureRepository { + + private final Map featureRepositories; + + private IFeatureRepository selectedFeatureRepository; + + public MultiProtocolFeatureRepository(List protocolVersions) { + featureRepositories = new HashMap<>(); + for (ProtocolVersion protocolVersion : protocolVersions) { + featureRepositories.put(protocolVersion, new FeatureRepository(protocolVersion)); + } + selectedFeatureRepository = null; + } + + /* methods used by both client and server */ + + public void addFeatureProfile(ProtocolVersion protocolVersion, Profile profile) { + getFeatureRepository(protocolVersion).addFeatureProfile(profile); + } + + public void addFeatureFunction(ProtocolVersion protocolVersion, Function function) { + FeatureRepository featureRepository = getFeatureRepository(protocolVersion); + for (Feature feature : function.getFeatureList()) { + featureRepository.addFeature(feature); + } + } + + /* methods used by the server */ + + public FeatureRepository getFeatureRepository(ProtocolVersion protocolVersion) { + FeatureRepository featureRepository = featureRepositories.get(protocolVersion); + if (featureRepository == null) { + throw new IllegalArgumentException("No feature repository for protocol " + protocolVersion); + } + return featureRepository; + } + + /* methods used by the client */ + + public void selectProtocolVersion(@Nullable ProtocolVersion protocolVersion) { + selectedFeatureRepository = featureRepositories.get(protocolVersion); + } + + @Nullable + public ProtocolVersion getProtocolVersion() { + IFeatureRepository featureRepository = selectedFeatureRepository; + return featureRepository != null ? featureRepository.getProtocolVersion() : null; + } + + @Override + public Optional findFeature(Object needle) { + IFeatureRepository featureRepository = selectedFeatureRepository; + return featureRepository != null ? featureRepository.findFeature(needle) : Optional.empty(); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("featureRepositories", featureRepositories) + .add("selectedFeatureRepository", selectedFeatureRepository) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolJSONClient.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolJSONClient.java new file mode 100644 index 000000000..5a18100ff --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolJSONClient.java @@ -0,0 +1,222 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * MIT License + * + * Copyright (C) 2016-2018 Thomas Volden + * Copyright (C) 2023 Robert Schlabbach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp; + +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.feature.profile.Profile; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.wss.BaseWssSocketBuilder; +import eu.chargetime.ocpp.wss.WssSocketBuilder; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.CompletionStage; +import javax.annotation.Nullable; +import javax.net.ssl.SSLContext; +import org.java_websocket.drafts.Draft; +import org.java_websocket.drafts.Draft_6455; +import org.java_websocket.protocols.IProtocol; +import org.java_websocket.protocols.Protocol; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** multiple protocol versions capable JSON Web Socket implementation of the client. */ +public class MultiProtocolJSONClient implements IMultiProtocolClientAPI { + + private static final Logger logger = LoggerFactory.getLogger(MultiProtocolJSONClient.class); + + private final String identity; + private final MultiProtocolFeatureRepository featureRepository; + private final MultiProtocolWebSocketTransmitter transmitter; + private final Client client; + + /** + * Application composite root for a json client. + * + * @param protocolVersions list of protocol versions to offer. + */ + public MultiProtocolJSONClient(List protocolVersions) { + this(protocolVersions, null); + } + + /** + * Application composite root for a json client. + * + * @param protocolVersions list of protocol versions to offer. + * @param identity identity if set, will append identity to url. + */ + public MultiProtocolJSONClient(List protocolVersions, String identity) { + this(protocolVersions, identity, JSONConfiguration.get()); + } + + /** + * Application composite root for a json client. + * + * @param protocolVersions list of protocol versions to offer. + * @param identity if set, will append identity to url. + * @param configuration network configuration for a json client. + */ + public MultiProtocolJSONClient( + List protocolVersions, String identity, JSONConfiguration configuration) { + this.identity = identity; + featureRepository = new MultiProtocolFeatureRepository(protocolVersions); + List inputProtocols = new ArrayList<>(protocolVersions.size()); + for (ProtocolVersion protocolVersion : protocolVersions) { + inputProtocols.add(new Protocol(protocolVersion.getSubProtocolName())); + } + Draft draft = new Draft_6455(Collections.emptyList(), inputProtocols); + transmitter = new MultiProtocolWebSocketTransmitter(featureRepository, configuration, draft); + JSONCommunicator communicator = new JSONCommunicator(transmitter, false); + ISessionFactory sessionFactory = new MultiProtocolSessionFactory(featureRepository); + ISession session = sessionFactory.createSession(communicator); + client = new Client(session, new PromiseRepository()); + } + + /** + * Application composite root for a json client. + * + * @param protocolVersions list of protocol versions to offer. + * @param identity if set, will append identity to url. + * @param wssSocketBuilder to build {@link java.net.Socket} to support wss://. + */ + public MultiProtocolJSONClient( + List protocolVersions, String identity, WssSocketBuilder wssSocketBuilder) { + this(protocolVersions, identity, wssSocketBuilder, JSONConfiguration.get()); + } + + /** + * Application composite root for a json client. + * + * @param protocolVersions list of protocol versions to offer. + * @param identity if set, will append identity to url. + * @param wssSocketBuilder to build {@link java.net.Socket} to support wss://. + * @param configuration network configuration for a json client. + */ + public MultiProtocolJSONClient( + List protocolVersions, + String identity, + WssSocketBuilder wssSocketBuilder, + JSONConfiguration configuration) { + this(protocolVersions, identity, configuration); + enableWSS(wssSocketBuilder); + } + + // To ensure the exposed API is backward compatible + public void enableWSS(SSLContext sslContext) throws IOException { + WssSocketBuilder wssSocketBuilder = + BaseWssSocketBuilder.builder().sslSocketFactory(sslContext.getSocketFactory()); + enableWSS(wssSocketBuilder); + } + + /** + * Enables WSS connection to the endpoint. The {@code wssSocketBuilder} must be initialized at + * that step (as required parameters set might vary depending on implementation the {@link + * WssSocketBuilder#verify()} is used to ensure initialization). + * + * @param wssSocketBuilder builder to provide SSL socket + * @return instance of {@link MultiProtocolJSONClient} + * @throws IllegalStateException in case if the client is already connected + * @throws IllegalStateException in case {@code wssSocketBuilder} not initialized properly + */ + public MultiProtocolJSONClient enableWSS(WssSocketBuilder wssSocketBuilder) { + wssSocketBuilder.verify(); + transmitter.enableWSS(wssSocketBuilder); + return this; + } + + /** + * Applies JSONConfiguration changes when already connected. Specifically, the WebSocket ping + * interval can be changed without reconnecting by calling this method. + */ + public void reconfigure() { + transmitter.configure(); + } + + @Override + public void addFeatureProfile(Profile profile) { + addFeatureProfile(ProtocolVersion.OCPP1_6, profile); + } + + @Override + public void addFeatureProfile(ProtocolVersion protocolVersion, Profile profile) { + featureRepository.addFeatureProfile(protocolVersion, profile); + } + + @Override + public void addFunction(ProtocolVersion protocolVersion, Function function) { + featureRepository.addFeatureFunction(protocolVersion, function); + } + + @Override + public void connect(String url, ClientEvents clientEvents) { + logger.debug("Feature repository: {}", featureRepository); + + String identityUrl = (identity != null) ? String.format("%s/%s", url, identity) : url; + client.connect(identityUrl, clientEvents); + } + + @Override + @Nullable + public ProtocolVersion getProtocolVersion() { + return featureRepository.getProtocolVersion(); + } + + @Override + public CompletionStage send(Request request) + throws OccurenceConstraintException, UnsupportedFeatureException { + return client.send(request); + } + + @Override + public boolean asyncCompleteRequest(String uniqueId, Confirmation confirmation) + throws UnsupportedFeatureException, OccurenceConstraintException { + return client.asyncCompleteRequest(uniqueId, confirmation); + } + + @Override + public void disconnect() { + client.disconnect(); + } + + public Exception getLastError() { + return transmitter.getLastError(); + } + + @Override + public boolean isClosed() { + return transmitter.isClosed(); + } + + @Override + public UUID getSessionId() { + return client.getSessionId(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolJSONServer.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolJSONServer.java new file mode 100644 index 000000000..282a6e12d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolJSONServer.java @@ -0,0 +1,203 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Copyright (C) 2016-2018 Thomas Volden + * Copyright (C) 2023 Robert Schlabbach + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp; + +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.feature.profile.Profile; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.wss.BaseWssFactoryBuilder; +import eu.chargetime.ocpp.wss.WssFactoryBuilder; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.CompletionStage; +import javax.net.ssl.SSLContext; +import org.java_websocket.drafts.Draft; +import org.java_websocket.drafts.Draft_6455; +import org.java_websocket.protocols.IProtocol; +import org.java_websocket.protocols.Protocol; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** multiple protocol versions capable JSON Web Socket implementation of the server. */ +public class MultiProtocolJSONServer implements IMultiProtocolServerAPI { + + private static final Logger logger = LoggerFactory.getLogger(MultiProtocolJSONServer.class); + + private final MultiProtocolWebSocketListener listener; + private final Server server; + private final MultiProtocolFeatureRepository featureRepository; + + /** + * The constructor creates WS-ready server. + * + * @param protocolVersions list of protocol versions to accept. + * @param configuration network configuration for a json server. + */ + public MultiProtocolJSONServer( + List protocolVersions, JSONConfiguration configuration) { + featureRepository = new MultiProtocolFeatureRepository(protocolVersions); + MultiProtocolSessionFactory sessionFactory = new MultiProtocolSessionFactory(featureRepository); + + List protocols = new ArrayList<>(protocolVersions.size()); + for (ProtocolVersion protocolVersion : protocolVersions) { + protocols.add(new Protocol(protocolVersion.getSubProtocolName())); + } + Draft draft = new Draft_6455(Collections.emptyList(), protocols); + + if (configuration.getParameter(JSONConfiguration.HTTP_HEALTH_CHECK_ENABLED, true)) { + logger.info("JSONServer with HttpHealthCheckDraft"); + listener = + new MultiProtocolWebSocketListener( + sessionFactory, configuration, draft, new Draft_HttpHealthCheck()); + } else { + listener = new MultiProtocolWebSocketListener(sessionFactory, configuration, draft); + } + server = new Server(listener, new PromiseRepository()); + } + + /** + * The constructor creates WS-ready server. + * + * @param protocolVersions list of protocol versions to accept. + */ + public MultiProtocolJSONServer(List protocolVersions) { + this(protocolVersions, JSONConfiguration.get()); + } + + /** + * The constructor creates WSS-ready server. + * + * @param protocolVersions list of protocol versions to accept. + * @param wssFactoryBuilder to build {@link org.java_websocket.WebSocketServerFactory} to support + * wss://. + * @param configuration network configuration for a json server. + */ + public MultiProtocolJSONServer( + List protocolVersions, + WssFactoryBuilder wssFactoryBuilder, + JSONConfiguration configuration) { + this(protocolVersions, configuration); + enableWSS(wssFactoryBuilder); + } + + /** + * The constructor creates WSS-ready server. + * + * @param protocolVersions list of protocol versions to accept. + * @param wssFactoryBuilder to build {@link org.java_websocket.WebSocketServerFactory} to support + * wss://. + */ + public MultiProtocolJSONServer( + List protocolVersions, WssFactoryBuilder wssFactoryBuilder) { + this(protocolVersions, wssFactoryBuilder, JSONConfiguration.get()); + } + + // To ensure the exposed API is backward compatible + public void enableWSS(SSLContext sslContext) throws IOException { + WssFactoryBuilder builder = BaseWssFactoryBuilder.builder().sslContext(sslContext); + enableWSS(builder); + } + + /** + * Enables server to accept WSS connections. The {@code wssFactoryBuilder} must be initialized at + * that step (as required parameters set might vary depending on implementation the {@link + * WssFactoryBuilder#verify()} is used to ensure initialization). + * + * @param wssFactoryBuilder builder to provide WebSocketServerFactory + * @return instance of {@link MultiProtocolJSONServer} + * @throws IllegalStateException in case if the server is already connected + * @throws IllegalStateException in case {@code wssFactoryBuilder} not initialized properly + */ + public MultiProtocolJSONServer enableWSS(WssFactoryBuilder wssFactoryBuilder) { + wssFactoryBuilder.verify(); + listener.enableWSS(wssFactoryBuilder); + return this; + } + + @Override + public void addFeatureProfile(Profile profile) { + addFeatureProfile(ProtocolVersion.OCPP1_6, profile); + } + + @Override + public void addFeatureProfile(ProtocolVersion protocolVersion, Profile profile) { + featureRepository.addFeatureProfile(protocolVersion, profile); + } + + @Override + public void addFunction(ProtocolVersion protocolVersion, Function function) { + featureRepository.addFeatureFunction(protocolVersion, function); + } + + @Override + public int getPort() { + return listener.getPort(); + } + + @Override + public boolean isSessionOpen(UUID session) { + return server.isSessionOpen(session); + } + + @Override + public void closeSession(UUID session) { + server.closeSession(session); + } + + @Override + public void open(String host, int port, ServerEvents serverEvents) { + logger.info("Feature repository: {}", featureRepository); + server.open(host, port, serverEvents); + } + + @Override + public void close() { + server.close(); + } + + @Override + public boolean isClosed() { + return listener.isClosed(); + } + + @Override + public CompletionStage send(UUID session, Request request) + throws OccurenceConstraintException, UnsupportedFeatureException, NotConnectedException { + return server.send(session, request); + } + + @Override + public boolean asyncCompleteRequest(UUID sessionIndex, String uniqueId, Confirmation confirmation) + throws NotConnectedException, UnsupportedFeatureException, OccurenceConstraintException { + return server.asyncCompleteRequest(sessionIndex, uniqueId, confirmation); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolSessionFactory.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolSessionFactory.java new file mode 100644 index 000000000..3da41fae3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolSessionFactory.java @@ -0,0 +1,72 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Copyright (C) 2016-2018 Thomas Volden + Copyright (C) 2023 Robert Schlabbach + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp; + +public class MultiProtocolSessionFactory implements ISessionFactory { + + private final MultiProtocolFeatureRepository multiProtocolFeatureRepository; + + public MultiProtocolSessionFactory( + MultiProtocolFeatureRepository multiProtocolFeatureRepository) { + this.multiProtocolFeatureRepository = multiProtocolFeatureRepository; + } + + /** + * Creates a client session + * + *

The session will use the feature repository from the {@link MultiProtocolFeatureRepository} + * selected using {@link MultiProtocolFeatureRepository#selectProtocolVersion(ProtocolVersion)} + * when the negotiated {@link ProtocolVersion} is known (after the WebSocket handshake). + * + * @param communicator the {@link Communicator} to use for the client session + * @return the client {@link Session} + */ + @Override + public ISession createSession(Communicator communicator) { + AsyncPromiseFulfillerDecorator promiseFulfiller = + new AsyncPromiseFulfillerDecorator(new SimplePromiseFulfiller()); + return new Session(communicator, new Queue(), promiseFulfiller, multiProtocolFeatureRepository); + } + + /** + * Creates a server session + * + *

The session will use the feature repository for the given {@link ProtocolVersion}. + * + * @param communicator the {@link Communicator} to use for the server session + * @param protocolVersion the {@link ProtocolVersion} to use for the server session + * @return the server {@link Session} + */ + public ISession createSession(Communicator communicator, ProtocolVersion protocolVersion) { + IFeatureRepository featureRepository = + multiProtocolFeatureRepository.getFeatureRepository(protocolVersion); + AsyncPromiseFulfillerDecorator promiseFulfiller = + new AsyncPromiseFulfillerDecorator(new SimplePromiseFulfiller()); + return new Session(communicator, new Queue(), promiseFulfiller, featureRepository); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolWebSocketListener.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolWebSocketListener.java new file mode 100644 index 000000000..47c37fe45 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolWebSocketListener.java @@ -0,0 +1,319 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Copyright (C) 2016-2018 Thomas Volden + Copyright (C) 2023 Robert Schlabbach + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp; + +import eu.chargetime.ocpp.model.SessionInformation; +import eu.chargetime.ocpp.wss.WssFactoryBuilder; +import java.net.ConnectException; +import java.net.InetSocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Base64; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import org.java_websocket.WebSocket; +import org.java_websocket.drafts.Draft; +import org.java_websocket.drafts.Draft_6455; +import org.java_websocket.exceptions.InvalidDataException; +import org.java_websocket.handshake.ClientHandshake; +import org.java_websocket.handshake.ServerHandshakeBuilder; +import org.java_websocket.server.WebSocketServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MultiProtocolWebSocketListener implements Listener { + private static final Logger logger = + LoggerFactory.getLogger(MultiProtocolWebSocketListener.class); + + private static final int DEFAULT_WEBSOCKET_WORKER_COUNT = 4; + private static final int TIMEOUT_IN_MILLIS = 10000; + + private static final int OCPPJ_CP_MIN_PASSWORD_LENGTH = 16; + private static final int OCPPJ_CP_MAX_PASSWORD_LENGTH = 20; + + private static final int OCPP2J_CP_MIN_PASSWORD_LENGTH = 16; + private static final int OCPP2J_CP_MAX_PASSWORD_LENGTH = 40; + + private static final String HTTP_HEADER_PROXIED_ADDRESS = "X-Forwarded-For"; + + private final MultiProtocolSessionFactory sessionFactory; + private final List drafts; + + private final JSONConfiguration configuration; + private final Map sockets; + private volatile WebSocketServer server; + private WssFactoryBuilder wssFactoryBuilder; + private volatile boolean closed = true; + private boolean handleRequestAsync; + + public MultiProtocolWebSocketListener( + MultiProtocolSessionFactory sessionFactory, + JSONConfiguration configuration, + Draft... drafts) { + this.sessionFactory = sessionFactory; + this.configuration = configuration; + this.drafts = Arrays.asList(drafts); + this.sockets = new ConcurrentHashMap<>(); + } + + @Override + public void open(String hostname, int port, ListenerEvents handler) { + server = + new WebSocketServer( + new InetSocketAddress(hostname, port), + configuration.getParameter( + JSONConfiguration.WEBSOCKET_WORKER_COUNT, DEFAULT_WEBSOCKET_WORKER_COUNT), + drafts) { + @Override + public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) { + if (Draft_HttpHealthCheck.isHttp(clientHandshake)) { + logger.debug("On HTTP Request, for health check"); + webSocket.close(Draft_HttpHealthCheck.HTTP_HEALTH_CHECK_CLOSE_CODE); + return; + } + String protocol = webSocket.getProtocol().toString(); + logger.debug( + "On connection open (resource descriptor: {}, protocol: {})", + clientHandshake.getResourceDescriptor(), + protocol); + + WebSocketReceiver receiver = + new WebSocketReceiver( + new WebSocketReceiverEvents() { + @Override + public boolean isClosed() { + return closed; + } + + @Override + public void close() { + webSocket.close(); + } + + @Override + public void relay(String message) { + webSocket.send(message); + } + }); + + sockets.put(webSocket, receiver); + + ProtocolVersion protocolVersion = ProtocolVersion.fromSubProtocolName(protocol); + String proxiedAddress = clientHandshake.getFieldValue(HTTP_HEADER_PROXIED_ADDRESS); + + logger.debug( + "New web-socket connection opened from address: {} proxied for: {}", + webSocket.getRemoteSocketAddress(), + proxiedAddress); + + SessionInformation information = + new SessionInformation.Builder() + .Identifier(clientHandshake.getResourceDescriptor()) + .InternetAddress(webSocket.getRemoteSocketAddress()) + .ProtocolVersion(protocolVersion) + .ProxiedAddress(proxiedAddress) + .build(); + + handler.newSession( + sessionFactory.createSession(new JSONCommunicator(receiver), protocolVersion), + information); + } + + @Override + public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer( + WebSocket webSocket, Draft draft, ClientHandshake clientHandshake) + throws InvalidDataException { + ProtocolVersion protocolVersion; + if (draft instanceof Draft_6455) { + String protocol = ((Draft_6455) draft).getProtocol().toString(); + protocolVersion = ProtocolVersion.fromSubProtocolName(protocol); + } else { + protocolVersion = null; + } + + SessionInformation information = + new SessionInformation.Builder() + .Identifier(clientHandshake.getResourceDescriptor()) + .InternetAddress(webSocket.getRemoteSocketAddress()) + .ProtocolVersion(protocolVersion) + .build(); + + String username = null; + byte[] password = null; + if (clientHandshake.hasFieldValue("Authorization")) { + String authorization = clientHandshake.getFieldValue("Authorization"); + if (authorization != null && authorization.toLowerCase().startsWith("basic")) { + // Authorization: Basic base64credentials + String base64Credentials = authorization.substring("Basic".length()).trim(); + byte[] credDecoded = Base64.getDecoder().decode(base64Credentials); + // split credentials on username and password + for (int i = 0; i < credDecoded.length; i++) { + if (credDecoded[i] == ':') { + username = + new String(Arrays.copyOfRange(credDecoded, 0, i), StandardCharsets.UTF_8); + if (i + 1 < credDecoded.length) { + password = Arrays.copyOfRange(credDecoded, i + 1, credDecoded.length); + } + break; + } + } + } + if (protocolVersion == null || protocolVersion == ProtocolVersion.OCPP1_6) { + if (password == null + || password.length < configuration.getParameter(JSONConfiguration.OCPPJ_CP_MIN_PASSWORD_LENGTH, OCPPJ_CP_MIN_PASSWORD_LENGTH) + || password.length > configuration.getParameter(JSONConfiguration.OCPPJ_CP_MAX_PASSWORD_LENGTH, OCPPJ_CP_MAX_PASSWORD_LENGTH)) + throw new InvalidDataException(401, "Invalid password length"); + } else { + if (password == null + || password.length < configuration.getParameter(JSONConfiguration.OCPP2J_CP_MIN_PASSWORD_LENGTH, OCPP2J_CP_MIN_PASSWORD_LENGTH) + || password.length > configuration.getParameter(JSONConfiguration.OCPP2J_CP_MAX_PASSWORD_LENGTH, OCPP2J_CP_MAX_PASSWORD_LENGTH)) + throw new InvalidDataException(401, "Invalid password length"); + } + } + + try { + handler.authenticateSession(information, username, password); + } catch (AuthenticationException e) { + throw new InvalidDataException(e.getErrorCode(), e.getMessage()); + } catch (Exception e) { + throw new InvalidDataException(401, e.getMessage()); + } + return super.onWebsocketHandshakeReceivedAsServer(webSocket, draft, clientHandshake); + } + + @Override + public void onClose(WebSocket webSocket, int code, String reason, boolean remote) { + logger.debug( + "On connection close (resource descriptor: {}, code: {}, reason: {}, remote: {})", + webSocket.getResourceDescriptor(), + code, + reason, + remote); + + if (code == Draft_HttpHealthCheck.HTTP_HEALTH_CHECK_CLOSE_CODE) return; + + WebSocketReceiver receiver = sockets.get(webSocket); + if (receiver != null) { + receiver.disconnect(); + sockets.remove(webSocket); + } else { + logger.debug("Receiver for socket not found: {}", webSocket); + } + } + + @Override + public void onMessage(WebSocket webSocket, String message) { + sockets.get(webSocket).relay(message); + } + + @Override + public void onError(WebSocket webSocket, Exception ex) { + String resourceDescriptor = + (webSocket != null) + ? webSocket.getResourceDescriptor() + : "not defined (webSocket is null)"; + + if (ex instanceof ConnectException) { + logger.error( + "On error (resource descriptor: " + resourceDescriptor + ") triggered caused by:", + ex); + } else { + logger.error( + "On error (resource descriptor: " + resourceDescriptor + ") triggered:", ex); + } + } + + @Override + public void onStart() { + logger.debug("Server socket bound"); + } + }; + + if (wssFactoryBuilder != null) { + server.setWebSocketFactory(wssFactoryBuilder.build()); + } + + configure(); + server.start(); + closed = false; + } + + void configure() { + server.setReuseAddr(configuration.getParameter(JSONConfiguration.REUSE_ADDR_PARAMETER, true)); + server.setTcpNoDelay( + configuration.getParameter(JSONConfiguration.TCP_NO_DELAY_PARAMETER, false)); + server.setConnectionLostTimeout( + configuration.getParameter(JSONConfiguration.PING_INTERVAL_PARAMETER, 60)); + } + + void enableWSS(WssFactoryBuilder wssFactoryBuilder) { + if (server != null) { + throw new IllegalStateException("Cannot enable WSS on already running server"); + } + + this.wssFactoryBuilder = wssFactoryBuilder; + } + + int getPort() { + return server.getPort(); + } + + @Override + public void close() { + + if (server == null) { + return; + } + + try { + server.stop(TIMEOUT_IN_MILLIS); + sockets.clear(); + } catch (InterruptedException e) { + // Do second try + try { + server.stop(); + } catch (InterruptedException ex) { + logger.error("Failed to close listener", ex); + } + } finally { + closed = true; + server = null; + } + } + + @Override + public boolean isClosed() { + return closed; + } + + @Override + public void setAsyncRequestHandler(boolean async) { + this.handleRequestAsync = async; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolWebSocketTransmitter.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolWebSocketTransmitter.java new file mode 100644 index 000000000..1b4dface7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/MultiProtocolWebSocketTransmitter.java @@ -0,0 +1,274 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + Copyright (C) 2015-2016 Thomas Volden + + MIT License + + Copyright (C) 2016-2018 Thomas Volden + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp; + +import eu.chargetime.ocpp.wss.WssSocketBuilder; +import java.io.IOException; +import java.net.*; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; +import javax.net.SocketFactory; +import org.java_websocket.client.WebSocketClient; +import org.java_websocket.drafts.Draft; +import org.java_websocket.exceptions.WebsocketNotConnectedException; +import org.java_websocket.handshake.ServerHandshake; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** Web Socket implementation of the Transmitter. */ +public class MultiProtocolWebSocketTransmitter implements Transmitter { + + public static final String WSS_SCHEME = "wss"; + + private static final Logger logger = + LoggerFactory.getLogger(MultiProtocolWebSocketTransmitter.class); + + private final MultiProtocolFeatureRepository featureRepository; + private final JSONConfiguration configuration; + private final Draft draft; + + private volatile Exception lastError = null; + private volatile boolean closed = true; + private volatile WebSocketClient client; + private WssSocketBuilder wssSocketBuilder; + + public MultiProtocolWebSocketTransmitter( + MultiProtocolFeatureRepository featureRepository, + JSONConfiguration configuration, + Draft draft) { + this.featureRepository = featureRepository; + this.configuration = configuration; + this.draft = draft; + } + + @Override + public void connect(String uri, RadioEvents events) { + final URI resource = URI.create(uri); + + lastError = null; + Map httpHeaders = new HashMap<>(); + String username = configuration.getParameter(JSONConfiguration.USERNAME_PARAMETER); + Object password = configuration.getParameter(JSONConfiguration.PASSWORD_PARAMETER); + byte[] credentials = null; + if (username != null && password != null) { + if (password instanceof String) { + credentials = (username + ":" + password).getBytes(StandardCharsets.UTF_8); + } else if (password instanceof byte[]) { + credentials = + joinByteArrays((username + ":").getBytes(StandardCharsets.UTF_8), (byte[]) password); + } + } + if (credentials != null) { + byte[] base64Credentials = Base64.getEncoder().encode(credentials); + httpHeaders.put("Authorization", "Basic " + new String(base64Credentials)); + } + + int connectTimeout = + this.configuration.getParameter(JSONConfiguration.CONNECT_TIMEOUT_IN_MS_PARAMETER, 0); + + client = + new WebSocketClient(resource, draft, httpHeaders, connectTimeout) { + @Override + public void onOpen(ServerHandshake serverHandshake) { + String protocol = client.getProtocol().toString(); + logger.debug( + "On connection open (HTTP status: {}, protocol: {})", + serverHandshake.getHttpStatus(), + protocol); + ProtocolVersion protocolVersion = ProtocolVersion.fromSubProtocolName(protocol); + featureRepository.selectProtocolVersion(protocolVersion); + events.connected(); + } + + @Override + public void onMessage(String message) { + events.receivedMessage(message); + } + + @Override + public void onClose(int code, String reason, boolean remote) { + logger.debug( + "On connection close (code: {}, reason: {}, remote: {})", code, reason, remote); + featureRepository.selectProtocolVersion(null); + events.disconnected(); + } + + @Override + public void onError(Exception ex) { + lastError = ex; + if (ex instanceof ConnectException) { + logger.error("On error triggered caused by:", ex); + } else { + logger.error("On error triggered:", ex); + } + } + }; + + if (WSS_SCHEME.equals(resource.getScheme())) { + + if (wssSocketBuilder == null) { + throw new IllegalStateException( + "wssSocketBuilder must be set to support " + WSS_SCHEME + " scheme"); + } + + SocketFactory socketFactory = + new SocketFactory() { + public Socket createSocket() throws IOException { + return wssSocketBuilder.uri(resource).build(); + } + + public Socket createSocket(String host, int port) { + throw new UnsupportedOperationException(); + } + + public Socket createSocket( + String host, int port, InetAddress clientAddress, int clientPort) { + throw new UnsupportedOperationException(); + } + + public Socket createSocket(InetAddress address, int port) { + throw new UnsupportedOperationException(); + } + + public Socket createSocket( + InetAddress address, int port, InetAddress clientAddress, int clientPort) { + throw new UnsupportedOperationException(); + } + }; + + client.setSocketFactory(socketFactory); + } + + configure(); + + boolean isNonBlocking = isNonBlockingParameterSet(); + + logger.debug("Trying to connect to: {}{}", resource, isNonBlocking ? "" : " [blocking]"); + + if (isNonBlocking) { + try { + client.connect(); + closed = false; + } catch (Exception ex) { + logger.warn("client.connect() failed", ex); + } + } else { + try { + client.connectBlocking(); + closed = false; + } catch (Exception ex) { + logger.warn("client.connectBlocking() failed", ex); + } + } + } + + byte[] joinByteArrays(byte[] a, byte[] b) { + byte[] result = new byte[a.length + b.length]; + System.arraycopy(a, 0, result, 0, a.length); + System.arraycopy(b, 0, result, a.length, b.length); + return result; + } + + void configure() { + if (client == null) { + return; + } + client.setReuseAddr(configuration.getParameter(JSONConfiguration.REUSE_ADDR_PARAMETER, false)); + client.setTcpNoDelay( + configuration.getParameter(JSONConfiguration.TCP_NO_DELAY_PARAMETER, false)); + client.setConnectionLostTimeout( + configuration.getParameter(JSONConfiguration.PING_INTERVAL_PARAMETER, 60)); + client.setProxy(configuration.getParameter(JSONConfiguration.PROXY_PARAMETER, Proxy.NO_PROXY)); + } + + void enableWSS(WssSocketBuilder wssSocketBuilder) { + if (client != null) { + throw new IllegalStateException("Cannot enable WSS on already connected client"); + } + this.wssSocketBuilder = wssSocketBuilder; + } + + @Override + public void disconnect() { + if (client == null) { + return; + } + + boolean isNonBlocking = isNonBlockingParameterSet(); + + logger.debug("Disconnecting{}", isNonBlocking ? "" : " [blocking]"); + + if (isNonBlocking) { + try { + client.close(); + } catch (Exception ex) { + logger.info("client.close() failed", ex); + } finally { + client = null; + closed = true; + } + } else { + try { + client.closeBlocking(); + } catch (Exception ex) { + logger.info("client.closeBlocking() failed", ex); + } finally { + client = null; + closed = true; + } + } + } + + private boolean isNonBlockingParameterSet() { + Object rawParam = configuration.getParameter(JSONConfiguration.CONNECT_NON_BLOCKING_PARAMETER); + return rawParam instanceof Boolean ? (Boolean) rawParam : false; + } + + @Override + public void send(Object request) throws NotConnectedException { + if (client == null) { + throw new NotConnectedException(); + } + + try { + client.send(request.toString()); + } catch (WebsocketNotConnectedException ex) { + throw new NotConnectedException(); + } + } + + public Exception getLastError() { + return lastError; + } + + public boolean isClosed() { + return closed; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/FunctionFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/FunctionFeature.java new file mode 100644 index 000000000..40ea55265 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/FunctionFeature.java @@ -0,0 +1,57 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Copyright (C) 2018 Thomas Volden + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.feature; + +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import java.util.UUID; + +public abstract class FunctionFeature implements Feature { + + private final Function function; + + /** + * Creates link back to the {@link Function}. + * + * @param ownerFunction the {@link Function} that owns the function. + */ + public FunctionFeature(Function ownerFunction) { + function = ownerFunction; + } + + /** + * Calls {@link Function} to handle a {@link Request}. + * + * @param sessionIndex source of the request. + * @param request the {@link Request} to be handled. + * @return the {@link Confirmation} to be send back. + */ + public Confirmation handleRequest(UUID sessionIndex, Request request) { + return function.handleRequest(sessionIndex, request); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/function/Function.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/function/Function.java new file mode 100644 index 000000000..252e6cbf4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/feature/function/Function.java @@ -0,0 +1,54 @@ +/* +ChargeTime.eu - Java-OCA-OCPP +Copyright (C) 2015-2016 Thomas Volden + +MIT License + +Copyright (C) 2016-2018 Thomas Volden + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +package eu.chargetime.ocpp.feature.function; + +import eu.chargetime.ocpp.feature.Feature; +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import java.util.UUID; + +/** Interface used for Feature Profiles. */ +public interface Function { + + /** + * Get a list of supported Features for this Function. + * + * @return supported {@link Feature}s + */ + FunctionFeature[] getFeatureList(); + + /** + * Handle {@link Request} + * + * @param sessionIndex source of the request. + * @param request the {@link Request} to be handled. + * @return the {@link Confirmation} to be send. + */ + Confirmation handleRequest(UUID sessionIndex, Request request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/AuthorizeFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/AuthorizeFeature.java new file mode 100644 index 000000000..7eff592fb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/AuthorizeFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.AuthorizeRequest; +import eu.chargetime.ocpp.v201.model.messages.AuthorizeResponse; + +public class AuthorizeFeature extends FunctionFeature { + + public AuthorizeFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return AuthorizeRequest.class; + } + + @Override + public Class getConfirmationType() { + return AuthorizeResponse.class; + } + + @Override + public String getAction() { + return "Authorize"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/BootNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/BootNotificationFeature.java new file mode 100644 index 000000000..501bcf2b4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/BootNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.BootNotificationRequest; +import eu.chargetime.ocpp.v201.model.messages.BootNotificationResponse; + +public class BootNotificationFeature extends FunctionFeature { + + public BootNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return BootNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return BootNotificationResponse.class; + } + + @Override + public String getAction() { + return "BootNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CancelReservationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CancelReservationFeature.java new file mode 100644 index 000000000..0b4c5042f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CancelReservationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.CancelReservationRequest; +import eu.chargetime.ocpp.v201.model.messages.CancelReservationResponse; + +public class CancelReservationFeature extends FunctionFeature { + + public CancelReservationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return CancelReservationRequest.class; + } + + @Override + public Class getConfirmationType() { + return CancelReservationResponse.class; + } + + @Override + public String getAction() { + return "CancelReservation"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CertificateSignedFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CertificateSignedFeature.java new file mode 100644 index 000000000..a326b8cdf --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CertificateSignedFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.CertificateSignedRequest; +import eu.chargetime.ocpp.v201.model.messages.CertificateSignedResponse; + +public class CertificateSignedFeature extends FunctionFeature { + + public CertificateSignedFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return CertificateSignedRequest.class; + } + + @Override + public Class getConfirmationType() { + return CertificateSignedResponse.class; + } + + @Override + public String getAction() { + return "CertificateSigned"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ChangeAvailabilityFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ChangeAvailabilityFeature.java new file mode 100644 index 000000000..88247b110 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ChangeAvailabilityFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.ChangeAvailabilityRequest; +import eu.chargetime.ocpp.v201.model.messages.ChangeAvailabilityResponse; + +public class ChangeAvailabilityFeature extends FunctionFeature { + + public ChangeAvailabilityFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ChangeAvailabilityRequest.class; + } + + @Override + public Class getConfirmationType() { + return ChangeAvailabilityResponse.class; + } + + @Override + public String getAction() { + return "ChangeAvailability"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearCacheFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearCacheFeature.java new file mode 100644 index 000000000..73eb0fe03 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearCacheFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.ClearCacheRequest; +import eu.chargetime.ocpp.v201.model.messages.ClearCacheResponse; + +public class ClearCacheFeature extends FunctionFeature { + + public ClearCacheFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearCacheRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearCacheResponse.class; + } + + @Override + public String getAction() { + return "ClearCache"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearChargingProfileFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearChargingProfileFeature.java new file mode 100644 index 000000000..e37131b26 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearChargingProfileFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.ClearChargingProfileRequest; +import eu.chargetime.ocpp.v201.model.messages.ClearChargingProfileResponse; + +public class ClearChargingProfileFeature extends FunctionFeature { + + public ClearChargingProfileFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearChargingProfileRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearChargingProfileResponse.class; + } + + @Override + public String getAction() { + return "ClearChargingProfile"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearDisplayMessageFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearDisplayMessageFeature.java new file mode 100644 index 000000000..a97d0951f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearDisplayMessageFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.ClearDisplayMessageRequest; +import eu.chargetime.ocpp.v201.model.messages.ClearDisplayMessageResponse; + +public class ClearDisplayMessageFeature extends FunctionFeature { + + public ClearDisplayMessageFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearDisplayMessageRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearDisplayMessageResponse.class; + } + + @Override + public String getAction() { + return "ClearDisplayMessage"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearVariableMonitoringFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearVariableMonitoringFeature.java new file mode 100644 index 000000000..f4d7a89c7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearVariableMonitoringFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.ClearVariableMonitoringRequest; +import eu.chargetime.ocpp.v201.model.messages.ClearVariableMonitoringResponse; + +public class ClearVariableMonitoringFeature extends FunctionFeature { + + public ClearVariableMonitoringFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearVariableMonitoringRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearVariableMonitoringResponse.class; + } + + @Override + public String getAction() { + return "ClearVariableMonitoring"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearedChargingLimitFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearedChargingLimitFeature.java new file mode 100644 index 000000000..71d6d53da --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ClearedChargingLimitFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.ClearedChargingLimitRequest; +import eu.chargetime.ocpp.v201.model.messages.ClearedChargingLimitResponse; + +public class ClearedChargingLimitFeature extends FunctionFeature { + + public ClearedChargingLimitFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ClearedChargingLimitRequest.class; + } + + @Override + public Class getConfirmationType() { + return ClearedChargingLimitResponse.class; + } + + @Override + public String getAction() { + return "ClearedChargingLimit"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CostUpdatedFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CostUpdatedFeature.java new file mode 100644 index 000000000..222e17415 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CostUpdatedFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.CostUpdatedRequest; +import eu.chargetime.ocpp.v201.model.messages.CostUpdatedResponse; + +public class CostUpdatedFeature extends FunctionFeature { + + public CostUpdatedFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return CostUpdatedRequest.class; + } + + @Override + public Class getConfirmationType() { + return CostUpdatedResponse.class; + } + + @Override + public String getAction() { + return "CostUpdated"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CustomerInformationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CustomerInformationFeature.java new file mode 100644 index 000000000..b8a0a9865 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/CustomerInformationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.CustomerInformationRequest; +import eu.chargetime.ocpp.v201.model.messages.CustomerInformationResponse; + +public class CustomerInformationFeature extends FunctionFeature { + + public CustomerInformationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return CustomerInformationRequest.class; + } + + @Override + public Class getConfirmationType() { + return CustomerInformationResponse.class; + } + + @Override + public String getAction() { + return "CustomerInformation"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/DataTransferFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/DataTransferFeature.java new file mode 100644 index 000000000..9be7e11a5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/DataTransferFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.DataTransferRequest; +import eu.chargetime.ocpp.v201.model.messages.DataTransferResponse; + +public class DataTransferFeature extends FunctionFeature { + + public DataTransferFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return DataTransferRequest.class; + } + + @Override + public Class getConfirmationType() { + return DataTransferResponse.class; + } + + @Override + public String getAction() { + return "DataTransfer"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/DeleteCertificateFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/DeleteCertificateFeature.java new file mode 100644 index 000000000..232ae5b2f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/DeleteCertificateFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.DeleteCertificateRequest; +import eu.chargetime.ocpp.v201.model.messages.DeleteCertificateResponse; + +public class DeleteCertificateFeature extends FunctionFeature { + + public DeleteCertificateFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return DeleteCertificateRequest.class; + } + + @Override + public Class getConfirmationType() { + return DeleteCertificateResponse.class; + } + + @Override + public String getAction() { + return "DeleteCertificate"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/FirmwareStatusNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/FirmwareStatusNotificationFeature.java new file mode 100644 index 000000000..d2a918ade --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/FirmwareStatusNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.FirmwareStatusNotificationRequest; +import eu.chargetime.ocpp.v201.model.messages.FirmwareStatusNotificationResponse; + +public class FirmwareStatusNotificationFeature extends FunctionFeature { + + public FirmwareStatusNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return FirmwareStatusNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return FirmwareStatusNotificationResponse.class; + } + + @Override + public String getAction() { + return "FirmwareStatusNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/Get15118EVCertificateFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/Get15118EVCertificateFeature.java new file mode 100644 index 000000000..f1ee48bfc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/Get15118EVCertificateFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.Get15118EVCertificateRequest; +import eu.chargetime.ocpp.v201.model.messages.Get15118EVCertificateResponse; + +public class Get15118EVCertificateFeature extends FunctionFeature { + + public Get15118EVCertificateFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return Get15118EVCertificateRequest.class; + } + + @Override + public Class getConfirmationType() { + return Get15118EVCertificateResponse.class; + } + + @Override + public String getAction() { + return "Get15118EVCertificate"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetBaseReportFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetBaseReportFeature.java new file mode 100644 index 000000000..a8d2c6f1b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetBaseReportFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetBaseReportRequest; +import eu.chargetime.ocpp.v201.model.messages.GetBaseReportResponse; + +public class GetBaseReportFeature extends FunctionFeature { + + public GetBaseReportFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetBaseReportRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetBaseReportResponse.class; + } + + @Override + public String getAction() { + return "GetBaseReport"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetCertificateStatusFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetCertificateStatusFeature.java new file mode 100644 index 000000000..db96bbf12 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetCertificateStatusFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetCertificateStatusRequest; +import eu.chargetime.ocpp.v201.model.messages.GetCertificateStatusResponse; + +public class GetCertificateStatusFeature extends FunctionFeature { + + public GetCertificateStatusFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetCertificateStatusRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetCertificateStatusResponse.class; + } + + @Override + public String getAction() { + return "GetCertificateStatus"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetChargingProfilesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetChargingProfilesFeature.java new file mode 100644 index 000000000..89c1d6edc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetChargingProfilesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetChargingProfilesRequest; +import eu.chargetime.ocpp.v201.model.messages.GetChargingProfilesResponse; + +public class GetChargingProfilesFeature extends FunctionFeature { + + public GetChargingProfilesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetChargingProfilesRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetChargingProfilesResponse.class; + } + + @Override + public String getAction() { + return "GetChargingProfiles"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetCompositeScheduleFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetCompositeScheduleFeature.java new file mode 100644 index 000000000..6c7fab126 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetCompositeScheduleFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetCompositeScheduleRequest; +import eu.chargetime.ocpp.v201.model.messages.GetCompositeScheduleResponse; + +public class GetCompositeScheduleFeature extends FunctionFeature { + + public GetCompositeScheduleFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetCompositeScheduleRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetCompositeScheduleResponse.class; + } + + @Override + public String getAction() { + return "GetCompositeSchedule"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetDisplayMessagesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetDisplayMessagesFeature.java new file mode 100644 index 000000000..43bcd6744 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetDisplayMessagesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetDisplayMessagesRequest; +import eu.chargetime.ocpp.v201.model.messages.GetDisplayMessagesResponse; + +public class GetDisplayMessagesFeature extends FunctionFeature { + + public GetDisplayMessagesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetDisplayMessagesRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetDisplayMessagesResponse.class; + } + + @Override + public String getAction() { + return "GetDisplayMessages"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetInstalledCertificateIdsFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetInstalledCertificateIdsFeature.java new file mode 100644 index 000000000..2ba213572 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetInstalledCertificateIdsFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetInstalledCertificateIdsRequest; +import eu.chargetime.ocpp.v201.model.messages.GetInstalledCertificateIdsResponse; + +public class GetInstalledCertificateIdsFeature extends FunctionFeature { + + public GetInstalledCertificateIdsFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetInstalledCertificateIdsRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetInstalledCertificateIdsResponse.class; + } + + @Override + public String getAction() { + return "GetInstalledCertificateIds"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetLocalListVersionFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetLocalListVersionFeature.java new file mode 100644 index 000000000..6160954be --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetLocalListVersionFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetLocalListVersionRequest; +import eu.chargetime.ocpp.v201.model.messages.GetLocalListVersionResponse; + +public class GetLocalListVersionFeature extends FunctionFeature { + + public GetLocalListVersionFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetLocalListVersionRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetLocalListVersionResponse.class; + } + + @Override + public String getAction() { + return "GetLocalListVersion"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetLogFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetLogFeature.java new file mode 100644 index 000000000..d70093503 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetLogFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetLogRequest; +import eu.chargetime.ocpp.v201.model.messages.GetLogResponse; + +public class GetLogFeature extends FunctionFeature { + + public GetLogFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetLogRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetLogResponse.class; + } + + @Override + public String getAction() { + return "GetLog"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetMonitoringReportFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetMonitoringReportFeature.java new file mode 100644 index 000000000..5b6d89b03 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetMonitoringReportFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetMonitoringReportRequest; +import eu.chargetime.ocpp.v201.model.messages.GetMonitoringReportResponse; + +public class GetMonitoringReportFeature extends FunctionFeature { + + public GetMonitoringReportFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetMonitoringReportRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetMonitoringReportResponse.class; + } + + @Override + public String getAction() { + return "GetMonitoringReport"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetReportFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetReportFeature.java new file mode 100644 index 000000000..4e03f5509 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetReportFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetReportRequest; +import eu.chargetime.ocpp.v201.model.messages.GetReportResponse; + +public class GetReportFeature extends FunctionFeature { + + public GetReportFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetReportRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetReportResponse.class; + } + + @Override + public String getAction() { + return "GetReport"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetTransactionStatusFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetTransactionStatusFeature.java new file mode 100644 index 000000000..678ba11d4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetTransactionStatusFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetTransactionStatusRequest; +import eu.chargetime.ocpp.v201.model.messages.GetTransactionStatusResponse; + +public class GetTransactionStatusFeature extends FunctionFeature { + + public GetTransactionStatusFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetTransactionStatusRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetTransactionStatusResponse.class; + } + + @Override + public String getAction() { + return "GetTransactionStatus"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetVariablesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetVariablesFeature.java new file mode 100644 index 000000000..a954b0553 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/GetVariablesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.GetVariablesRequest; +import eu.chargetime.ocpp.v201.model.messages.GetVariablesResponse; + +public class GetVariablesFeature extends FunctionFeature { + + public GetVariablesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return GetVariablesRequest.class; + } + + @Override + public Class getConfirmationType() { + return GetVariablesResponse.class; + } + + @Override + public String getAction() { + return "GetVariables"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/HeartbeatFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/HeartbeatFeature.java new file mode 100644 index 000000000..5a1d4414e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/HeartbeatFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.HeartbeatRequest; +import eu.chargetime.ocpp.v201.model.messages.HeartbeatResponse; + +public class HeartbeatFeature extends FunctionFeature { + + public HeartbeatFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return HeartbeatRequest.class; + } + + @Override + public Class getConfirmationType() { + return HeartbeatResponse.class; + } + + @Override + public String getAction() { + return "Heartbeat"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/InstallCertificateFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/InstallCertificateFeature.java new file mode 100644 index 000000000..ed047ea91 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/InstallCertificateFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.InstallCertificateRequest; +import eu.chargetime.ocpp.v201.model.messages.InstallCertificateResponse; + +public class InstallCertificateFeature extends FunctionFeature { + + public InstallCertificateFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return InstallCertificateRequest.class; + } + + @Override + public Class getConfirmationType() { + return InstallCertificateResponse.class; + } + + @Override + public String getAction() { + return "InstallCertificate"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/LogStatusNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/LogStatusNotificationFeature.java new file mode 100644 index 000000000..e203bca0c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/LogStatusNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.LogStatusNotificationRequest; +import eu.chargetime.ocpp.v201.model.messages.LogStatusNotificationResponse; + +public class LogStatusNotificationFeature extends FunctionFeature { + + public LogStatusNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return LogStatusNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return LogStatusNotificationResponse.class; + } + + @Override + public String getAction() { + return "LogStatusNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/MeterValuesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/MeterValuesFeature.java new file mode 100644 index 000000000..9c1483175 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/MeterValuesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.MeterValuesRequest; +import eu.chargetime.ocpp.v201.model.messages.MeterValuesResponse; + +public class MeterValuesFeature extends FunctionFeature { + + public MeterValuesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return MeterValuesRequest.class; + } + + @Override + public Class getConfirmationType() { + return MeterValuesResponse.class; + } + + @Override + public String getAction() { + return "MeterValues"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyChargingLimitFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyChargingLimitFeature.java new file mode 100644 index 000000000..86c05bd92 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyChargingLimitFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.NotifyChargingLimitRequest; +import eu.chargetime.ocpp.v201.model.messages.NotifyChargingLimitResponse; + +public class NotifyChargingLimitFeature extends FunctionFeature { + + public NotifyChargingLimitFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyChargingLimitRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyChargingLimitResponse.class; + } + + @Override + public String getAction() { + return "NotifyChargingLimit"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyCustomerInformationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyCustomerInformationFeature.java new file mode 100644 index 000000000..f03e85a30 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyCustomerInformationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.NotifyCustomerInformationRequest; +import eu.chargetime.ocpp.v201.model.messages.NotifyCustomerInformationResponse; + +public class NotifyCustomerInformationFeature extends FunctionFeature { + + public NotifyCustomerInformationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyCustomerInformationRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyCustomerInformationResponse.class; + } + + @Override + public String getAction() { + return "NotifyCustomerInformation"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyDisplayMessagesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyDisplayMessagesFeature.java new file mode 100644 index 000000000..3524f242f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyDisplayMessagesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.NotifyDisplayMessagesRequest; +import eu.chargetime.ocpp.v201.model.messages.NotifyDisplayMessagesResponse; + +public class NotifyDisplayMessagesFeature extends FunctionFeature { + + public NotifyDisplayMessagesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyDisplayMessagesRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyDisplayMessagesResponse.class; + } + + @Override + public String getAction() { + return "NotifyDisplayMessages"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyEVChargingNeedsFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyEVChargingNeedsFeature.java new file mode 100644 index 000000000..c09cd4df8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyEVChargingNeedsFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.NotifyEVChargingNeedsRequest; +import eu.chargetime.ocpp.v201.model.messages.NotifyEVChargingNeedsResponse; + +public class NotifyEVChargingNeedsFeature extends FunctionFeature { + + public NotifyEVChargingNeedsFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyEVChargingNeedsRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyEVChargingNeedsResponse.class; + } + + @Override + public String getAction() { + return "NotifyEVChargingNeeds"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyEVChargingScheduleFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyEVChargingScheduleFeature.java new file mode 100644 index 000000000..724f92ef0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyEVChargingScheduleFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.NotifyEVChargingScheduleRequest; +import eu.chargetime.ocpp.v201.model.messages.NotifyEVChargingScheduleResponse; + +public class NotifyEVChargingScheduleFeature extends FunctionFeature { + + public NotifyEVChargingScheduleFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyEVChargingScheduleRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyEVChargingScheduleResponse.class; + } + + @Override + public String getAction() { + return "NotifyEVChargingSchedule"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyEventFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyEventFeature.java new file mode 100644 index 000000000..f3237777a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyEventFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.NotifyEventRequest; +import eu.chargetime.ocpp.v201.model.messages.NotifyEventResponse; + +public class NotifyEventFeature extends FunctionFeature { + + public NotifyEventFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyEventRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyEventResponse.class; + } + + @Override + public String getAction() { + return "NotifyEvent"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyMonitoringReportFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyMonitoringReportFeature.java new file mode 100644 index 000000000..5c6f5810a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyMonitoringReportFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.NotifyMonitoringReportRequest; +import eu.chargetime.ocpp.v201.model.messages.NotifyMonitoringReportResponse; + +public class NotifyMonitoringReportFeature extends FunctionFeature { + + public NotifyMonitoringReportFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyMonitoringReportRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyMonitoringReportResponse.class; + } + + @Override + public String getAction() { + return "NotifyMonitoringReport"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyReportFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyReportFeature.java new file mode 100644 index 000000000..d4462340f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/NotifyReportFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.NotifyReportRequest; +import eu.chargetime.ocpp.v201.model.messages.NotifyReportResponse; + +public class NotifyReportFeature extends FunctionFeature { + + public NotifyReportFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return NotifyReportRequest.class; + } + + @Override + public Class getConfirmationType() { + return NotifyReportResponse.class; + } + + @Override + public String getAction() { + return "NotifyReport"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/PublishFirmwareFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/PublishFirmwareFeature.java new file mode 100644 index 000000000..aee197bb8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/PublishFirmwareFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.PublishFirmwareRequest; +import eu.chargetime.ocpp.v201.model.messages.PublishFirmwareResponse; + +public class PublishFirmwareFeature extends FunctionFeature { + + public PublishFirmwareFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return PublishFirmwareRequest.class; + } + + @Override + public Class getConfirmationType() { + return PublishFirmwareResponse.class; + } + + @Override + public String getAction() { + return "PublishFirmware"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/PublishFirmwareStatusNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/PublishFirmwareStatusNotificationFeature.java new file mode 100644 index 000000000..1ab1e4f75 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/PublishFirmwareStatusNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.PublishFirmwareStatusNotificationRequest; +import eu.chargetime.ocpp.v201.model.messages.PublishFirmwareStatusNotificationResponse; + +public class PublishFirmwareStatusNotificationFeature extends FunctionFeature { + + public PublishFirmwareStatusNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return PublishFirmwareStatusNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return PublishFirmwareStatusNotificationResponse.class; + } + + @Override + public String getAction() { + return "PublishFirmwareStatusNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ReportChargingProfilesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ReportChargingProfilesFeature.java new file mode 100644 index 000000000..6cf474144 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ReportChargingProfilesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.ReportChargingProfilesRequest; +import eu.chargetime.ocpp.v201.model.messages.ReportChargingProfilesResponse; + +public class ReportChargingProfilesFeature extends FunctionFeature { + + public ReportChargingProfilesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ReportChargingProfilesRequest.class; + } + + @Override + public Class getConfirmationType() { + return ReportChargingProfilesResponse.class; + } + + @Override + public String getAction() { + return "ReportChargingProfiles"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/RequestStartTransactionFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/RequestStartTransactionFeature.java new file mode 100644 index 000000000..e881a469c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/RequestStartTransactionFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.RequestStartTransactionRequest; +import eu.chargetime.ocpp.v201.model.messages.RequestStartTransactionResponse; + +public class RequestStartTransactionFeature extends FunctionFeature { + + public RequestStartTransactionFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return RequestStartTransactionRequest.class; + } + + @Override + public Class getConfirmationType() { + return RequestStartTransactionResponse.class; + } + + @Override + public String getAction() { + return "RequestStartTransaction"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/RequestStopTransactionFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/RequestStopTransactionFeature.java new file mode 100644 index 000000000..486f034d5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/RequestStopTransactionFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.RequestStopTransactionRequest; +import eu.chargetime.ocpp.v201.model.messages.RequestStopTransactionResponse; + +public class RequestStopTransactionFeature extends FunctionFeature { + + public RequestStopTransactionFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return RequestStopTransactionRequest.class; + } + + @Override + public Class getConfirmationType() { + return RequestStopTransactionResponse.class; + } + + @Override + public String getAction() { + return "RequestStopTransaction"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ReservationStatusUpdateFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ReservationStatusUpdateFeature.java new file mode 100644 index 000000000..cbfe5ada0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ReservationStatusUpdateFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.ReservationStatusUpdateRequest; +import eu.chargetime.ocpp.v201.model.messages.ReservationStatusUpdateResponse; + +public class ReservationStatusUpdateFeature extends FunctionFeature { + + public ReservationStatusUpdateFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ReservationStatusUpdateRequest.class; + } + + @Override + public Class getConfirmationType() { + return ReservationStatusUpdateResponse.class; + } + + @Override + public String getAction() { + return "ReservationStatusUpdate"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ReserveNowFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ReserveNowFeature.java new file mode 100644 index 000000000..f1bb7cd52 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ReserveNowFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.ReserveNowRequest; +import eu.chargetime.ocpp.v201.model.messages.ReserveNowResponse; + +public class ReserveNowFeature extends FunctionFeature { + + public ReserveNowFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ReserveNowRequest.class; + } + + @Override + public Class getConfirmationType() { + return ReserveNowResponse.class; + } + + @Override + public String getAction() { + return "ReserveNow"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ResetFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ResetFeature.java new file mode 100644 index 000000000..2dea3bfb9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/ResetFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.ResetRequest; +import eu.chargetime.ocpp.v201.model.messages.ResetResponse; + +public class ResetFeature extends FunctionFeature { + + public ResetFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return ResetRequest.class; + } + + @Override + public Class getConfirmationType() { + return ResetResponse.class; + } + + @Override + public String getAction() { + return "Reset"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SecurityEventNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SecurityEventNotificationFeature.java new file mode 100644 index 000000000..c717d4a26 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SecurityEventNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.SecurityEventNotificationRequest; +import eu.chargetime.ocpp.v201.model.messages.SecurityEventNotificationResponse; + +public class SecurityEventNotificationFeature extends FunctionFeature { + + public SecurityEventNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SecurityEventNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return SecurityEventNotificationResponse.class; + } + + @Override + public String getAction() { + return "SecurityEventNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SendLocalListFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SendLocalListFeature.java new file mode 100644 index 000000000..c48f5fdd3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SendLocalListFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.SendLocalListRequest; +import eu.chargetime.ocpp.v201.model.messages.SendLocalListResponse; + +public class SendLocalListFeature extends FunctionFeature { + + public SendLocalListFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SendLocalListRequest.class; + } + + @Override + public Class getConfirmationType() { + return SendLocalListResponse.class; + } + + @Override + public String getAction() { + return "SendLocalList"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetChargingProfileFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetChargingProfileFeature.java new file mode 100644 index 000000000..3e622baf4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetChargingProfileFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.SetChargingProfileRequest; +import eu.chargetime.ocpp.v201.model.messages.SetChargingProfileResponse; + +public class SetChargingProfileFeature extends FunctionFeature { + + public SetChargingProfileFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetChargingProfileRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetChargingProfileResponse.class; + } + + @Override + public String getAction() { + return "SetChargingProfile"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetDisplayMessageFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetDisplayMessageFeature.java new file mode 100644 index 000000000..81dc080e2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetDisplayMessageFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.SetDisplayMessageRequest; +import eu.chargetime.ocpp.v201.model.messages.SetDisplayMessageResponse; + +public class SetDisplayMessageFeature extends FunctionFeature { + + public SetDisplayMessageFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetDisplayMessageRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetDisplayMessageResponse.class; + } + + @Override + public String getAction() { + return "SetDisplayMessage"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetMonitoringBaseFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetMonitoringBaseFeature.java new file mode 100644 index 000000000..5e80b9774 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetMonitoringBaseFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.SetMonitoringBaseRequest; +import eu.chargetime.ocpp.v201.model.messages.SetMonitoringBaseResponse; + +public class SetMonitoringBaseFeature extends FunctionFeature { + + public SetMonitoringBaseFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetMonitoringBaseRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetMonitoringBaseResponse.class; + } + + @Override + public String getAction() { + return "SetMonitoringBase"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetMonitoringLevelFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetMonitoringLevelFeature.java new file mode 100644 index 000000000..6bccc36a2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetMonitoringLevelFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.SetMonitoringLevelRequest; +import eu.chargetime.ocpp.v201.model.messages.SetMonitoringLevelResponse; + +public class SetMonitoringLevelFeature extends FunctionFeature { + + public SetMonitoringLevelFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetMonitoringLevelRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetMonitoringLevelResponse.class; + } + + @Override + public String getAction() { + return "SetMonitoringLevel"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetNetworkProfileFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetNetworkProfileFeature.java new file mode 100644 index 000000000..e4e365211 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetNetworkProfileFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.SetNetworkProfileRequest; +import eu.chargetime.ocpp.v201.model.messages.SetNetworkProfileResponse; + +public class SetNetworkProfileFeature extends FunctionFeature { + + public SetNetworkProfileFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetNetworkProfileRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetNetworkProfileResponse.class; + } + + @Override + public String getAction() { + return "SetNetworkProfile"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetVariableMonitoringFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetVariableMonitoringFeature.java new file mode 100644 index 000000000..8a27b4e6d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetVariableMonitoringFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.SetVariableMonitoringRequest; +import eu.chargetime.ocpp.v201.model.messages.SetVariableMonitoringResponse; + +public class SetVariableMonitoringFeature extends FunctionFeature { + + public SetVariableMonitoringFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetVariableMonitoringRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetVariableMonitoringResponse.class; + } + + @Override + public String getAction() { + return "SetVariableMonitoring"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetVariablesFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetVariablesFeature.java new file mode 100644 index 000000000..391eb1f3a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SetVariablesFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.SetVariablesRequest; +import eu.chargetime.ocpp.v201.model.messages.SetVariablesResponse; + +public class SetVariablesFeature extends FunctionFeature { + + public SetVariablesFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SetVariablesRequest.class; + } + + @Override + public Class getConfirmationType() { + return SetVariablesResponse.class; + } + + @Override + public String getAction() { + return "SetVariables"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SignCertificateFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SignCertificateFeature.java new file mode 100644 index 000000000..afac10ccb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/SignCertificateFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.SignCertificateRequest; +import eu.chargetime.ocpp.v201.model.messages.SignCertificateResponse; + +public class SignCertificateFeature extends FunctionFeature { + + public SignCertificateFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return SignCertificateRequest.class; + } + + @Override + public Class getConfirmationType() { + return SignCertificateResponse.class; + } + + @Override + public String getAction() { + return "SignCertificate"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/StatusNotificationFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/StatusNotificationFeature.java new file mode 100644 index 000000000..b45719765 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/StatusNotificationFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.StatusNotificationRequest; +import eu.chargetime.ocpp.v201.model.messages.StatusNotificationResponse; + +public class StatusNotificationFeature extends FunctionFeature { + + public StatusNotificationFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return StatusNotificationRequest.class; + } + + @Override + public Class getConfirmationType() { + return StatusNotificationResponse.class; + } + + @Override + public String getAction() { + return "StatusNotification"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/TransactionEventFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/TransactionEventFeature.java new file mode 100644 index 000000000..b6a950ca6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/TransactionEventFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.TransactionEventRequest; +import eu.chargetime.ocpp.v201.model.messages.TransactionEventResponse; + +public class TransactionEventFeature extends FunctionFeature { + + public TransactionEventFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return TransactionEventRequest.class; + } + + @Override + public Class getConfirmationType() { + return TransactionEventResponse.class; + } + + @Override + public String getAction() { + return "TransactionEvent"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/TriggerMessageFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/TriggerMessageFeature.java new file mode 100644 index 000000000..8095cc3d7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/TriggerMessageFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.TriggerMessageRequest; +import eu.chargetime.ocpp.v201.model.messages.TriggerMessageResponse; + +public class TriggerMessageFeature extends FunctionFeature { + + public TriggerMessageFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return TriggerMessageRequest.class; + } + + @Override + public Class getConfirmationType() { + return TriggerMessageResponse.class; + } + + @Override + public String getAction() { + return "TriggerMessage"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/UnlockConnectorFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/UnlockConnectorFeature.java new file mode 100644 index 000000000..08d4a744e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/UnlockConnectorFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.UnlockConnectorRequest; +import eu.chargetime.ocpp.v201.model.messages.UnlockConnectorResponse; + +public class UnlockConnectorFeature extends FunctionFeature { + + public UnlockConnectorFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return UnlockConnectorRequest.class; + } + + @Override + public Class getConfirmationType() { + return UnlockConnectorResponse.class; + } + + @Override + public String getAction() { + return "UnlockConnector"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/UnpublishFirmwareFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/UnpublishFirmwareFeature.java new file mode 100644 index 000000000..206e23370 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/UnpublishFirmwareFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.UnpublishFirmwareRequest; +import eu.chargetime.ocpp.v201.model.messages.UnpublishFirmwareResponse; + +public class UnpublishFirmwareFeature extends FunctionFeature { + + public UnpublishFirmwareFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return UnpublishFirmwareRequest.class; + } + + @Override + public Class getConfirmationType() { + return UnpublishFirmwareResponse.class; + } + + @Override + public String getAction() { + return "UnpublishFirmware"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/UpdateFirmwareFeature.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/UpdateFirmwareFeature.java new file mode 100644 index 000000000..c81078b76 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/UpdateFirmwareFeature.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.model.messages.UpdateFirmwareRequest; +import eu.chargetime.ocpp.v201.model.messages.UpdateFirmwareResponse; + +public class UpdateFirmwareFeature extends FunctionFeature { + + public UpdateFirmwareFeature(Function ownerFunction) { + super(ownerFunction); + } + + @Override + public Class getRequestType() { + return UpdateFirmwareRequest.class; + } + + @Override + public Class getConfirmationType() { + return UpdateFirmwareResponse.class; + } + + @Override + public String getAction() { + return "UpdateFirmware"; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAuthorizationEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAuthorizationEventHandler.java new file mode 100644 index 000000000..ef68225b2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAuthorizationEventHandler.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the Authorization functional block. */ +public interface ClientAuthorizationEventHandler { + /** + * Handle a {@link ClearCacheRequest} and return a {@link ClearCacheResponse}. + * + * @param request incoming {@link ClearCacheRequest} to handle. + * @return outgoing {@link ClearCacheResponse} to reply with. + */ + ClearCacheResponse handleClearCacheRequest(ClearCacheRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAuthorizationFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAuthorizationFunction.java new file mode 100644 index 000000000..f19cb5469 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAuthorizationFunction.java @@ -0,0 +1,73 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Authorization functional block. */ +public class ClientAuthorizationFunction implements Function { + + private final ClientAuthorizationEventHandler eventHandler; + private final ArrayList features; + + public ClientAuthorizationFunction(ClientAuthorizationEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new AuthorizeFeature(null)); + features.add(new ClearCacheFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ClearCacheRequest) { + return eventHandler.handleClearCacheRequest((ClearCacheRequest) request); + } + return null; + } + + /** + * Create a client {@link AuthorizeRequest} with all required fields. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @return an instance of {@link AuthorizeRequest} + */ + public AuthorizeRequest createAuthorizeRequest(IdToken idToken) { + return new AuthorizeRequest(idToken); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAvailabilityEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAvailabilityEventHandler.java new file mode 100644 index 000000000..860c71fd6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAvailabilityEventHandler.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the Availability functional block. */ +public interface ClientAvailabilityEventHandler { + /** + * Handle a {@link ChangeAvailabilityRequest} and return a {@link ChangeAvailabilityResponse}. + * + * @param request incoming {@link ChangeAvailabilityRequest} to handle. + * @return outgoing {@link ChangeAvailabilityResponse} to reply with. + */ + ChangeAvailabilityResponse handleChangeAvailabilityRequest(ChangeAvailabilityRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAvailabilityFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAvailabilityFunction.java new file mode 100644 index 000000000..1f6ab930b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientAvailabilityFunction.java @@ -0,0 +1,96 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Availability functional block. */ +public class ClientAvailabilityFunction implements Function { + + private final ClientAvailabilityEventHandler eventHandler; + private final ArrayList features; + + public ClientAvailabilityFunction(ClientAvailabilityEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ChangeAvailabilityFeature(this)); + features.add(new NotifyEventFeature(null)); + features.add(new StatusNotificationFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ChangeAvailabilityRequest) { + return eventHandler.handleChangeAvailabilityRequest((ChangeAvailabilityRequest) request); + } + return null; + } + + /** + * Create a client {@link NotifyEventRequest} with all required fields. + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param eventData Class to report an event notification for a component-variable. + * @return an instance of {@link NotifyEventRequest} + */ + public NotifyEventRequest createNotifyEventRequest( + ZonedDateTime generatedAt, Integer seqNo, EventData[] eventData) { + return new NotifyEventRequest(generatedAt, seqNo, eventData); + } + + /** + * Create a client {@link StatusNotificationRequest} with all required fields. + * + * @param timestamp The time for which the status is reported. If absent time of receipt of the + * message will be assumed. + * @param connectorStatus The current status of the Connector. + * @param evseId The id of the EVSE to which the connector belongs for which the the status is + * reported. + * @param connectorId The id of the connector within the EVSE for which the status is reported. + * @return an instance of {@link StatusNotificationRequest} + */ + public StatusNotificationRequest createStatusNotificationRequest( + ZonedDateTime timestamp, + ConnectorStatusEnum connectorStatus, + Integer evseId, + Integer connectorId) { + return new StatusNotificationRequest(timestamp, connectorStatus, evseId, connectorId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDataTransferEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDataTransferEventHandler.java new file mode 100644 index 000000000..fb10e1418 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDataTransferEventHandler.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the DataTransfer functional block. */ +public interface ClientDataTransferEventHandler { + /** + * Handle a {@link DataTransferRequest} and return a {@link DataTransferResponse}. + * + * @param request incoming {@link DataTransferRequest} to handle. + * @return outgoing {@link DataTransferResponse} to reply with. + */ + DataTransferResponse handleDataTransferRequest(DataTransferRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDataTransferFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDataTransferFunction.java new file mode 100644 index 000000000..b5dbecc1f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDataTransferFunction.java @@ -0,0 +1,71 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the DataTransfer functional block. */ +public class ClientDataTransferFunction implements Function { + + private final ClientDataTransferEventHandler eventHandler; + private final ArrayList features; + + public ClientDataTransferFunction(ClientDataTransferEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new DataTransferFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof DataTransferRequest) { + return eventHandler.handleDataTransferRequest((DataTransferRequest) request); + } + return null; + } + + /** + * Create a client {@link DataTransferRequest} with all required fields. + * + * @param vendorId The identifier of the Vendor specific implementation + * @return an instance of {@link DataTransferRequest} + */ + public DataTransferRequest createDataTransferRequest(String vendorId) { + return new DataTransferRequest(vendorId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDiagnosticsEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDiagnosticsEventHandler.java new file mode 100644 index 000000000..43e567111 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDiagnosticsEventHandler.java @@ -0,0 +1,90 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the Diagnostics functional block. */ +public interface ClientDiagnosticsEventHandler { + /** + * Handle a {@link ClearVariableMonitoringRequest} and return a {@link + * ClearVariableMonitoringResponse}. + * + * @param request incoming {@link ClearVariableMonitoringRequest} to handle. + * @return outgoing {@link ClearVariableMonitoringResponse} to reply with. + */ + ClearVariableMonitoringResponse handleClearVariableMonitoringRequest( + ClearVariableMonitoringRequest request); + + /** + * Handle a {@link CustomerInformationRequest} and return a {@link CustomerInformationResponse}. + * + * @param request incoming {@link CustomerInformationRequest} to handle. + * @return outgoing {@link CustomerInformationResponse} to reply with. + */ + CustomerInformationResponse handleCustomerInformationRequest(CustomerInformationRequest request); + + /** + * Handle a {@link GetLogRequest} and return a {@link GetLogResponse}. + * + * @param request incoming {@link GetLogRequest} to handle. + * @return outgoing {@link GetLogResponse} to reply with. + */ + GetLogResponse handleGetLogRequest(GetLogRequest request); + + /** + * Handle a {@link GetMonitoringReportRequest} and return a {@link GetMonitoringReportResponse}. + * + * @param request incoming {@link GetMonitoringReportRequest} to handle. + * @return outgoing {@link GetMonitoringReportResponse} to reply with. + */ + GetMonitoringReportResponse handleGetMonitoringReportRequest(GetMonitoringReportRequest request); + + /** + * Handle a {@link SetMonitoringBaseRequest} and return a {@link SetMonitoringBaseResponse}. + * + * @param request incoming {@link SetMonitoringBaseRequest} to handle. + * @return outgoing {@link SetMonitoringBaseResponse} to reply with. + */ + SetMonitoringBaseResponse handleSetMonitoringBaseRequest(SetMonitoringBaseRequest request); + + /** + * Handle a {@link SetMonitoringLevelRequest} and return a {@link SetMonitoringLevelResponse}. + * + * @param request incoming {@link SetMonitoringLevelRequest} to handle. + * @return outgoing {@link SetMonitoringLevelResponse} to reply with. + */ + SetMonitoringLevelResponse handleSetMonitoringLevelRequest(SetMonitoringLevelRequest request); + + /** + * Handle a {@link SetVariableMonitoringRequest} and return a {@link + * SetVariableMonitoringResponse}. + * + * @param request incoming {@link SetVariableMonitoringRequest} to handle. + * @return outgoing {@link SetVariableMonitoringResponse} to reply with. + */ + SetVariableMonitoringResponse handleSetVariableMonitoringRequest( + SetVariableMonitoringRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDiagnosticsFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDiagnosticsFunction.java new file mode 100644 index 000000000..baae02e3e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDiagnosticsFunction.java @@ -0,0 +1,124 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Diagnostics functional block. */ +public class ClientDiagnosticsFunction implements Function { + + private final ClientDiagnosticsEventHandler eventHandler; + private final ArrayList features; + + public ClientDiagnosticsFunction(ClientDiagnosticsEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearVariableMonitoringFeature(this)); + features.add(new CustomerInformationFeature(this)); + features.add(new GetLogFeature(this)); + features.add(new GetMonitoringReportFeature(this)); + features.add(new LogStatusNotificationFeature(null)); + features.add(new NotifyCustomerInformationFeature(null)); + features.add(new NotifyMonitoringReportFeature(null)); + features.add(new SetMonitoringBaseFeature(this)); + features.add(new SetMonitoringLevelFeature(this)); + features.add(new SetVariableMonitoringFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ClearVariableMonitoringRequest) { + return eventHandler.handleClearVariableMonitoringRequest( + (ClearVariableMonitoringRequest) request); + } else if (request instanceof CustomerInformationRequest) { + return eventHandler.handleCustomerInformationRequest((CustomerInformationRequest) request); + } else if (request instanceof GetLogRequest) { + return eventHandler.handleGetLogRequest((GetLogRequest) request); + } else if (request instanceof GetMonitoringReportRequest) { + return eventHandler.handleGetMonitoringReportRequest((GetMonitoringReportRequest) request); + } else if (request instanceof SetMonitoringBaseRequest) { + return eventHandler.handleSetMonitoringBaseRequest((SetMonitoringBaseRequest) request); + } else if (request instanceof SetMonitoringLevelRequest) { + return eventHandler.handleSetMonitoringLevelRequest((SetMonitoringLevelRequest) request); + } else if (request instanceof SetVariableMonitoringRequest) { + return eventHandler.handleSetVariableMonitoringRequest( + (SetVariableMonitoringRequest) request); + } + return null; + } + + /** + * Create a client {@link LogStatusNotificationRequest} with all required fields. + * + * @param status The status of the log upload. + * @return an instance of {@link LogStatusNotificationRequest} + */ + public LogStatusNotificationRequest createLogStatusNotificationRequest( + UploadLogStatusEnum status) { + return new LogStatusNotificationRequest(status); + } + + /** + * Create a client {@link NotifyCustomerInformationRequest} with all required fields. + * + * @param data (Part of) the requested data. No format specified in which the data is returned. + * Should be human readable. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param requestId The Id of the request. + * @return an instance of {@link NotifyCustomerInformationRequest} + */ + public NotifyCustomerInformationRequest createNotifyCustomerInformationRequest( + String data, Integer seqNo, ZonedDateTime generatedAt, Integer requestId) { + return new NotifyCustomerInformationRequest(data, seqNo, generatedAt, requestId); + } + + /** + * Create a client {@link NotifyMonitoringReportRequest} with all required fields. + * + * @param requestId The id of the GetMonitoringRequest that requested this report. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @return an instance of {@link NotifyMonitoringReportRequest} + */ + public NotifyMonitoringReportRequest createNotifyMonitoringReportRequest( + Integer requestId, Integer seqNo, ZonedDateTime generatedAt) { + return new NotifyMonitoringReportRequest(requestId, seqNo, generatedAt); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDisplayMessageEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDisplayMessageEventHandler.java new file mode 100644 index 000000000..daf24c627 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDisplayMessageEventHandler.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the DisplayMessage functional block. */ +public interface ClientDisplayMessageEventHandler { + /** + * Handle a {@link ClearDisplayMessageRequest} and return a {@link ClearDisplayMessageResponse}. + * + * @param request incoming {@link ClearDisplayMessageRequest} to handle. + * @return outgoing {@link ClearDisplayMessageResponse} to reply with. + */ + ClearDisplayMessageResponse handleClearDisplayMessageRequest(ClearDisplayMessageRequest request); + + /** + * Handle a {@link GetDisplayMessagesRequest} and return a {@link GetDisplayMessagesResponse}. + * + * @param request incoming {@link GetDisplayMessagesRequest} to handle. + * @return outgoing {@link GetDisplayMessagesResponse} to reply with. + */ + GetDisplayMessagesResponse handleGetDisplayMessagesRequest(GetDisplayMessagesRequest request); + + /** + * Handle a {@link SetDisplayMessageRequest} and return a {@link SetDisplayMessageResponse}. + * + * @param request incoming {@link SetDisplayMessageRequest} to handle. + * @return outgoing {@link SetDisplayMessageResponse} to reply with. + */ + SetDisplayMessageResponse handleSetDisplayMessageRequest(SetDisplayMessageRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDisplayMessageFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDisplayMessageFunction.java new file mode 100644 index 000000000..06f5caa41 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientDisplayMessageFunction.java @@ -0,0 +1,78 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the DisplayMessage functional block. */ +public class ClientDisplayMessageFunction implements Function { + + private final ClientDisplayMessageEventHandler eventHandler; + private final ArrayList features; + + public ClientDisplayMessageFunction(ClientDisplayMessageEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearDisplayMessageFeature(this)); + features.add(new GetDisplayMessagesFeature(this)); + features.add(new NotifyDisplayMessagesFeature(null)); + features.add(new SetDisplayMessageFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ClearDisplayMessageRequest) { + return eventHandler.handleClearDisplayMessageRequest((ClearDisplayMessageRequest) request); + } else if (request instanceof GetDisplayMessagesRequest) { + return eventHandler.handleGetDisplayMessagesRequest((GetDisplayMessagesRequest) request); + } else if (request instanceof SetDisplayMessageRequest) { + return eventHandler.handleSetDisplayMessageRequest((SetDisplayMessageRequest) request); + } + return null; + } + + /** + * Create a client {@link NotifyDisplayMessagesRequest} with all required fields. + * + * @param requestId The id of the GetDisplayMessagesRequest that requested this message. + * @return an instance of {@link NotifyDisplayMessagesRequest} + */ + public NotifyDisplayMessagesRequest createNotifyDisplayMessagesRequest(Integer requestId) { + return new NotifyDisplayMessagesRequest(requestId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientFirmwareManagementEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientFirmwareManagementEventHandler.java new file mode 100644 index 000000000..238457359 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientFirmwareManagementEventHandler.java @@ -0,0 +1,54 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the FirmwareManagement functional block. */ +public interface ClientFirmwareManagementEventHandler { + /** + * Handle a {@link PublishFirmwareRequest} and return a {@link PublishFirmwareResponse}. + * + * @param request incoming {@link PublishFirmwareRequest} to handle. + * @return outgoing {@link PublishFirmwareResponse} to reply with. + */ + PublishFirmwareResponse handlePublishFirmwareRequest(PublishFirmwareRequest request); + + /** + * Handle a {@link UnpublishFirmwareRequest} and return a {@link UnpublishFirmwareResponse}. + * + * @param request incoming {@link UnpublishFirmwareRequest} to handle. + * @return outgoing {@link UnpublishFirmwareResponse} to reply with. + */ + UnpublishFirmwareResponse handleUnpublishFirmwareRequest(UnpublishFirmwareRequest request); + + /** + * Handle a {@link UpdateFirmwareRequest} and return a {@link UpdateFirmwareResponse}. + * + * @param request incoming {@link UpdateFirmwareRequest} to handle. + * @return outgoing {@link UpdateFirmwareResponse} to reply with. + */ + UpdateFirmwareResponse handleUpdateFirmwareRequest(UpdateFirmwareRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientFirmwareManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientFirmwareManagementFunction.java new file mode 100644 index 000000000..81f38368b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientFirmwareManagementFunction.java @@ -0,0 +1,91 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the FirmwareManagement functional block. */ +public class ClientFirmwareManagementFunction implements Function { + + private final ClientFirmwareManagementEventHandler eventHandler; + private final ArrayList features; + + public ClientFirmwareManagementFunction(ClientFirmwareManagementEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new FirmwareStatusNotificationFeature(null)); + features.add(new PublishFirmwareFeature(this)); + features.add(new PublishFirmwareStatusNotificationFeature(null)); + features.add(new UnpublishFirmwareFeature(this)); + features.add(new UpdateFirmwareFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof PublishFirmwareRequest) { + return eventHandler.handlePublishFirmwareRequest((PublishFirmwareRequest) request); + } else if (request instanceof UnpublishFirmwareRequest) { + return eventHandler.handleUnpublishFirmwareRequest((UnpublishFirmwareRequest) request); + } else if (request instanceof UpdateFirmwareRequest) { + return eventHandler.handleUpdateFirmwareRequest((UpdateFirmwareRequest) request); + } + return null; + } + + /** + * Create a client {@link FirmwareStatusNotificationRequest} with all required fields. + * + * @param status The progress status of the firmware installation. + * @return an instance of {@link FirmwareStatusNotificationRequest} + */ + public FirmwareStatusNotificationRequest createFirmwareStatusNotificationRequest( + FirmwareStatusEnum status) { + return new FirmwareStatusNotificationRequest(status); + } + + /** + * Create a client {@link PublishFirmwareStatusNotificationRequest} with all required fields. + * + * @param status The progress status of the publishfirmware installation. + * @return an instance of {@link PublishFirmwareStatusNotificationRequest} + */ + public PublishFirmwareStatusNotificationRequest createPublishFirmwareStatusNotificationRequest( + PublishFirmwareStatusEnum status) { + return new PublishFirmwareStatusNotificationRequest(status); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientISO15118CertificateManagementEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientISO15118CertificateManagementEventHandler.java new file mode 100644 index 000000000..3562a8c45 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientISO15118CertificateManagementEventHandler.java @@ -0,0 +1,48 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the ISO15118CertificateManagement functional block. */ +public interface ClientISO15118CertificateManagementEventHandler { + /** + * Handle a {@link DeleteCertificateRequest} and return a {@link DeleteCertificateResponse}. + * + * @param request incoming {@link DeleteCertificateRequest} to handle. + * @return outgoing {@link DeleteCertificateResponse} to reply with. + */ + DeleteCertificateResponse handleDeleteCertificateRequest(DeleteCertificateRequest request); + + /** + * Handle a {@link GetInstalledCertificateIdsRequest} and return a {@link + * GetInstalledCertificateIdsResponse}. + * + * @param request incoming {@link GetInstalledCertificateIdsRequest} to handle. + * @return outgoing {@link GetInstalledCertificateIdsResponse} to reply with. + */ + GetInstalledCertificateIdsResponse handleGetInstalledCertificateIdsRequest( + GetInstalledCertificateIdsRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientISO15118CertificateManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientISO15118CertificateManagementFunction.java new file mode 100644 index 000000000..851be6f8f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientISO15118CertificateManagementFunction.java @@ -0,0 +1,96 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** + * Class with client request creators and handlers for the ISO15118CertificateManagement functional + * block. + */ +public class ClientISO15118CertificateManagementFunction implements Function { + + private final ClientISO15118CertificateManagementEventHandler eventHandler; + private final ArrayList features; + + public ClientISO15118CertificateManagementFunction( + ClientISO15118CertificateManagementEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new DeleteCertificateFeature(this)); + features.add(new Get15118EVCertificateFeature(null)); + features.add(new GetCertificateStatusFeature(null)); + features.add(new GetInstalledCertificateIdsFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof DeleteCertificateRequest) { + return eventHandler.handleDeleteCertificateRequest((DeleteCertificateRequest) request); + } else if (request instanceof GetInstalledCertificateIdsRequest) { + return eventHandler.handleGetInstalledCertificateIdsRequest( + (GetInstalledCertificateIdsRequest) request); + } + return null; + } + + /** + * Create a client {@link Get15118EVCertificateRequest} with all required fields. + * + * @param iso15118SchemaVersion Schema version currently used for the 15118 session between EV and + * Charging Station. Needed for parsing of the EXI stream by the CSMS. + * @param action Whether certificate needs to be installed or updated. + * @param exiRequest Raw CertificateInstallationReq request from EV, Base64 encoded. + * @return an instance of {@link Get15118EVCertificateRequest} + */ + public Get15118EVCertificateRequest createGet15118EVCertificateRequest( + String iso15118SchemaVersion, CertificateActionEnum action, String exiRequest) { + return new Get15118EVCertificateRequest(iso15118SchemaVersion, action, exiRequest); + } + + /** + * Create a client {@link GetCertificateStatusRequest} with all required fields. + * + * @param ocspRequestData ocspRequestData + * @return an instance of {@link GetCertificateStatusRequest} + */ + public GetCertificateStatusRequest createGetCertificateStatusRequest( + OCSPRequestData ocspRequestData) { + return new GetCertificateStatusRequest(ocspRequestData); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientLocalAuthorizationListManagementEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientLocalAuthorizationListManagementEventHandler.java new file mode 100644 index 000000000..5c11d2482 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientLocalAuthorizationListManagementEventHandler.java @@ -0,0 +1,46 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the LocalAuthorizationListManagement functional block. */ +public interface ClientLocalAuthorizationListManagementEventHandler { + /** + * Handle a {@link GetLocalListVersionRequest} and return a {@link GetLocalListVersionResponse}. + * + * @param request incoming {@link GetLocalListVersionRequest} to handle. + * @return outgoing {@link GetLocalListVersionResponse} to reply with. + */ + GetLocalListVersionResponse handleGetLocalListVersionRequest(GetLocalListVersionRequest request); + + /** + * Handle a {@link SendLocalListRequest} and return a {@link SendLocalListResponse}. + * + * @param request incoming {@link SendLocalListRequest} to handle. + * @return outgoing {@link SendLocalListResponse} to reply with. + */ + SendLocalListResponse handleSendLocalListRequest(SendLocalListRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientLocalAuthorizationListManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientLocalAuthorizationListManagementFunction.java new file mode 100644 index 000000000..70b6faffb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientLocalAuthorizationListManagementFunction.java @@ -0,0 +1,68 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** + * Class with client request creators and handlers for the LocalAuthorizationListManagement + * functional block. + */ +public class ClientLocalAuthorizationListManagementFunction implements Function { + + private final ClientLocalAuthorizationListManagementEventHandler eventHandler; + private final ArrayList features; + + public ClientLocalAuthorizationListManagementFunction( + ClientLocalAuthorizationListManagementEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new GetLocalListVersionFeature(this)); + features.add(new SendLocalListFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof GetLocalListVersionRequest) { + return eventHandler.handleGetLocalListVersionRequest((GetLocalListVersionRequest) request); + } else if (request instanceof SendLocalListRequest) { + return eventHandler.handleSendLocalListRequest((SendLocalListRequest) request); + } + return null; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientMeterValuesFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientMeterValuesFunction.java new file mode 100644 index 000000000..f3ad36bad --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientMeterValuesFunction.java @@ -0,0 +1,69 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the MeterValues functional block. */ +public class ClientMeterValuesFunction implements Function { + + private final ArrayList features; + + public ClientMeterValuesFunction() { + features = new ArrayList<>(); + features.add(new MeterValuesFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + return null; + } + + /** + * Create a client {@link MeterValuesRequest} with all required fields. + * + * @param evseId A number (greater than 0) designating an EVSE of the Charging Station. ‘0’ (zero) + * is used to designate the main power meter. + * @param meterValue Collection of one or more sampled values in MeterValuesRequest and + * TransactionEvent. All sampled values in a MeterValue are sampled at the same point in time. + * @return an instance of {@link MeterValuesRequest} + */ + public MeterValuesRequest createMeterValuesRequest(Integer evseId, MeterValue[] meterValue) { + return new MeterValuesRequest(evseId, meterValue); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientProvisioningEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientProvisioningEventHandler.java new file mode 100644 index 000000000..fd4eea471 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientProvisioningEventHandler.java @@ -0,0 +1,78 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the Provisioning functional block. */ +public interface ClientProvisioningEventHandler { + /** + * Handle a {@link GetBaseReportRequest} and return a {@link GetBaseReportResponse}. + * + * @param request incoming {@link GetBaseReportRequest} to handle. + * @return outgoing {@link GetBaseReportResponse} to reply with. + */ + GetBaseReportResponse handleGetBaseReportRequest(GetBaseReportRequest request); + + /** + * Handle a {@link GetReportRequest} and return a {@link GetReportResponse}. + * + * @param request incoming {@link GetReportRequest} to handle. + * @return outgoing {@link GetReportResponse} to reply with. + */ + GetReportResponse handleGetReportRequest(GetReportRequest request); + + /** + * Handle a {@link GetVariablesRequest} and return a {@link GetVariablesResponse}. + * + * @param request incoming {@link GetVariablesRequest} to handle. + * @return outgoing {@link GetVariablesResponse} to reply with. + */ + GetVariablesResponse handleGetVariablesRequest(GetVariablesRequest request); + + /** + * Handle a {@link ResetRequest} and return a {@link ResetResponse}. + * + * @param request incoming {@link ResetRequest} to handle. + * @return outgoing {@link ResetResponse} to reply with. + */ + ResetResponse handleResetRequest(ResetRequest request); + + /** + * Handle a {@link SetNetworkProfileRequest} and return a {@link SetNetworkProfileResponse}. + * + * @param request incoming {@link SetNetworkProfileRequest} to handle. + * @return outgoing {@link SetNetworkProfileResponse} to reply with. + */ + SetNetworkProfileResponse handleSetNetworkProfileRequest(SetNetworkProfileRequest request); + + /** + * Handle a {@link SetVariablesRequest} and return a {@link SetVariablesResponse}. + * + * @param request incoming {@link SetVariablesRequest} to handle. + * @return outgoing {@link SetVariablesResponse} to reply with. + */ + SetVariablesResponse handleSetVariablesRequest(SetVariablesRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientProvisioningFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientProvisioningFunction.java new file mode 100644 index 000000000..5b75d5f90 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientProvisioningFunction.java @@ -0,0 +1,115 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Provisioning functional block. */ +public class ClientProvisioningFunction implements Function { + + private final ClientProvisioningEventHandler eventHandler; + private final ArrayList features; + + public ClientProvisioningFunction(ClientProvisioningEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new BootNotificationFeature(null)); + features.add(new GetBaseReportFeature(this)); + features.add(new GetReportFeature(this)); + features.add(new GetVariablesFeature(this)); + features.add(new HeartbeatFeature(null)); + features.add(new NotifyReportFeature(null)); + features.add(new ResetFeature(this)); + features.add(new SetNetworkProfileFeature(this)); + features.add(new SetVariablesFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof GetBaseReportRequest) { + return eventHandler.handleGetBaseReportRequest((GetBaseReportRequest) request); + } else if (request instanceof GetReportRequest) { + return eventHandler.handleGetReportRequest((GetReportRequest) request); + } else if (request instanceof GetVariablesRequest) { + return eventHandler.handleGetVariablesRequest((GetVariablesRequest) request); + } else if (request instanceof ResetRequest) { + return eventHandler.handleResetRequest((ResetRequest) request); + } else if (request instanceof SetNetworkProfileRequest) { + return eventHandler.handleSetNetworkProfileRequest((SetNetworkProfileRequest) request); + } else if (request instanceof SetVariablesRequest) { + return eventHandler.handleSetVariablesRequest((SetVariablesRequest) request); + } + return null; + } + + /** + * Create a client {@link BootNotificationRequest} with all required fields. + * + * @param chargingStation The physical system where an Electrical Vehicle (EV) can be charged. + * @param reason The reason for sending this message to the CSMS. + * @return an instance of {@link BootNotificationRequest} + */ + public BootNotificationRequest createBootNotificationRequest( + ChargingStation chargingStation, BootReasonEnum reason) { + return new BootNotificationRequest(chargingStation, reason); + } + + /** + * Create a client {@link HeartbeatRequest}. + * + * @return an instance of {@link HeartbeatRequest} + */ + public HeartbeatRequest createHeartbeatRequest() { + return new HeartbeatRequest(); + } + + /** + * Create a client {@link NotifyReportRequest} with all required fields. + * + * @param requestId The id of the GetReportRequest or GetBaseReportRequest that requested this + * report + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param seqNo Sequence number of this message. First message starts at 0. + * @return an instance of {@link NotifyReportRequest} + */ + public NotifyReportRequest createNotifyReportRequest( + Integer requestId, ZonedDateTime generatedAt, Integer seqNo) { + return new NotifyReportRequest(requestId, generatedAt, seqNo); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientRemoteControlEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientRemoteControlEventHandler.java new file mode 100644 index 000000000..12704e00a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientRemoteControlEventHandler.java @@ -0,0 +1,66 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the RemoteControl functional block. */ +public interface ClientRemoteControlEventHandler { + /** + * Handle a {@link RequestStartTransactionRequest} and return a {@link + * RequestStartTransactionResponse}. + * + * @param request incoming {@link RequestStartTransactionRequest} to handle. + * @return outgoing {@link RequestStartTransactionResponse} to reply with. + */ + RequestStartTransactionResponse handleRequestStartTransactionRequest( + RequestStartTransactionRequest request); + + /** + * Handle a {@link RequestStopTransactionRequest} and return a {@link + * RequestStopTransactionResponse}. + * + * @param request incoming {@link RequestStopTransactionRequest} to handle. + * @return outgoing {@link RequestStopTransactionResponse} to reply with. + */ + RequestStopTransactionResponse handleRequestStopTransactionRequest( + RequestStopTransactionRequest request); + + /** + * Handle a {@link TriggerMessageRequest} and return a {@link TriggerMessageResponse}. + * + * @param request incoming {@link TriggerMessageRequest} to handle. + * @return outgoing {@link TriggerMessageResponse} to reply with. + */ + TriggerMessageResponse handleTriggerMessageRequest(TriggerMessageRequest request); + + /** + * Handle a {@link UnlockConnectorRequest} and return a {@link UnlockConnectorResponse}. + * + * @param request incoming {@link UnlockConnectorRequest} to handle. + * @return outgoing {@link UnlockConnectorResponse} to reply with. + */ + UnlockConnectorResponse handleUnlockConnectorRequest(UnlockConnectorRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientRemoteControlFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientRemoteControlFunction.java new file mode 100644 index 000000000..5e13b3625 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientRemoteControlFunction.java @@ -0,0 +1,72 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the RemoteControl functional block. */ +public class ClientRemoteControlFunction implements Function { + + private final ClientRemoteControlEventHandler eventHandler; + private final ArrayList features; + + public ClientRemoteControlFunction(ClientRemoteControlEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new RequestStartTransactionFeature(this)); + features.add(new RequestStopTransactionFeature(this)); + features.add(new TriggerMessageFeature(this)); + features.add(new UnlockConnectorFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof RequestStartTransactionRequest) { + return eventHandler.handleRequestStartTransactionRequest( + (RequestStartTransactionRequest) request); + } else if (request instanceof RequestStopTransactionRequest) { + return eventHandler.handleRequestStopTransactionRequest( + (RequestStopTransactionRequest) request); + } else if (request instanceof TriggerMessageRequest) { + return eventHandler.handleTriggerMessageRequest((TriggerMessageRequest) request); + } else if (request instanceof UnlockConnectorRequest) { + return eventHandler.handleUnlockConnectorRequest((UnlockConnectorRequest) request); + } + return null; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientReservationEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientReservationEventHandler.java new file mode 100644 index 000000000..264932d6d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientReservationEventHandler.java @@ -0,0 +1,46 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the Reservation functional block. */ +public interface ClientReservationEventHandler { + /** + * Handle a {@link CancelReservationRequest} and return a {@link CancelReservationResponse}. + * + * @param request incoming {@link CancelReservationRequest} to handle. + * @return outgoing {@link CancelReservationResponse} to reply with. + */ + CancelReservationResponse handleCancelReservationRequest(CancelReservationRequest request); + + /** + * Handle a {@link ReserveNowRequest} and return a {@link ReserveNowResponse}. + * + * @param request incoming {@link ReserveNowRequest} to handle. + * @return outgoing {@link ReserveNowResponse} to reply with. + */ + ReserveNowResponse handleReserveNowRequest(ReserveNowRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientReservationFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientReservationFunction.java new file mode 100644 index 000000000..316e3e438 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientReservationFunction.java @@ -0,0 +1,77 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Reservation functional block. */ +public class ClientReservationFunction implements Function { + + private final ClientReservationEventHandler eventHandler; + private final ArrayList features; + + public ClientReservationFunction(ClientReservationEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new CancelReservationFeature(this)); + features.add(new ReservationStatusUpdateFeature(null)); + features.add(new ReserveNowFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof CancelReservationRequest) { + return eventHandler.handleCancelReservationRequest((CancelReservationRequest) request); + } else if (request instanceof ReserveNowRequest) { + return eventHandler.handleReserveNowRequest((ReserveNowRequest) request); + } + return null; + } + + /** + * Create a client {@link ReservationStatusUpdateRequest} with all required fields. + * + * @param reservationId The ID of the reservation. + * @param reservationUpdateStatus The updated reservation status. + * @return an instance of {@link ReservationStatusUpdateRequest} + */ + public ReservationStatusUpdateRequest createReservationStatusUpdateRequest( + Integer reservationId, ReservationUpdateStatusEnum reservationUpdateStatus) { + return new ReservationStatusUpdateRequest(reservationId, reservationUpdateStatus); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSecurityEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSecurityEventHandler.java new file mode 100644 index 000000000..9aefe9c58 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSecurityEventHandler.java @@ -0,0 +1,46 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the Security functional block. */ +public interface ClientSecurityEventHandler { + /** + * Handle a {@link CertificateSignedRequest} and return a {@link CertificateSignedResponse}. + * + * @param request incoming {@link CertificateSignedRequest} to handle. + * @return outgoing {@link CertificateSignedResponse} to reply with. + */ + CertificateSignedResponse handleCertificateSignedRequest(CertificateSignedRequest request); + + /** + * Handle a {@link InstallCertificateRequest} and return a {@link InstallCertificateResponse}. + * + * @param request incoming {@link InstallCertificateRequest} to handle. + * @return outgoing {@link InstallCertificateResponse} to reply with. + */ + InstallCertificateResponse handleInstallCertificateRequest(InstallCertificateRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSecurityFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSecurityFunction.java new file mode 100644 index 000000000..7862f82d7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSecurityFunction.java @@ -0,0 +1,92 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Security functional block. */ +public class ClientSecurityFunction implements Function { + + private final ClientSecurityEventHandler eventHandler; + private final ArrayList features; + + public ClientSecurityFunction(ClientSecurityEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new CertificateSignedFeature(this)); + features.add(new InstallCertificateFeature(this)); + features.add(new SecurityEventNotificationFeature(null)); + features.add(new SignCertificateFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof CertificateSignedRequest) { + return eventHandler.handleCertificateSignedRequest((CertificateSignedRequest) request); + } else if (request instanceof InstallCertificateRequest) { + return eventHandler.handleInstallCertificateRequest((InstallCertificateRequest) request); + } + return null; + } + + /** + * Create a client {@link SecurityEventNotificationRequest} with all required fields. + * + * @param type Type of the security event. This value should be taken from the Security events + * list. + * @param timestamp Date and time at which the event occurred. + * @return an instance of {@link SecurityEventNotificationRequest} + */ + public SecurityEventNotificationRequest createSecurityEventNotificationRequest( + String type, ZonedDateTime timestamp) { + return new SecurityEventNotificationRequest(type, timestamp); + } + + /** + * Create a client {@link SignCertificateRequest} with all required fields. + * + * @param csr The Charging Station SHALL send the public key in form of a Certificate Signing + * Request (CSR) as described in RFC 2986 [22] and then PEM encoded, using the + * SignCertificateRequest message. + * @return an instance of {@link SignCertificateRequest} + */ + public SignCertificateRequest createSignCertificateRequest(String csr) { + return new SignCertificateRequest(csr); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSmartChargingEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSmartChargingEventHandler.java new file mode 100644 index 000000000..d05768ac3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSmartChargingEventHandler.java @@ -0,0 +1,64 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the SmartCharging functional block. */ +public interface ClientSmartChargingEventHandler { + /** + * Handle a {@link ClearChargingProfileRequest} and return a {@link ClearChargingProfileResponse}. + * + * @param request incoming {@link ClearChargingProfileRequest} to handle. + * @return outgoing {@link ClearChargingProfileResponse} to reply with. + */ + ClearChargingProfileResponse handleClearChargingProfileRequest( + ClearChargingProfileRequest request); + + /** + * Handle a {@link GetChargingProfilesRequest} and return a {@link GetChargingProfilesResponse}. + * + * @param request incoming {@link GetChargingProfilesRequest} to handle. + * @return outgoing {@link GetChargingProfilesResponse} to reply with. + */ + GetChargingProfilesResponse handleGetChargingProfilesRequest(GetChargingProfilesRequest request); + + /** + * Handle a {@link GetCompositeScheduleRequest} and return a {@link GetCompositeScheduleResponse}. + * + * @param request incoming {@link GetCompositeScheduleRequest} to handle. + * @return outgoing {@link GetCompositeScheduleResponse} to reply with. + */ + GetCompositeScheduleResponse handleGetCompositeScheduleRequest( + GetCompositeScheduleRequest request); + + /** + * Handle a {@link SetChargingProfileRequest} and return a {@link SetChargingProfileResponse}. + * + * @param request incoming {@link SetChargingProfileRequest} to handle. + * @return outgoing {@link SetChargingProfileResponse} to reply with. + */ + SetChargingProfileResponse handleSetChargingProfileRequest(SetChargingProfileRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSmartChargingFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSmartChargingFunction.java new file mode 100644 index 000000000..b90ce361c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientSmartChargingFunction.java @@ -0,0 +1,146 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the SmartCharging functional block. */ +public class ClientSmartChargingFunction implements Function { + + private final ClientSmartChargingEventHandler eventHandler; + private final ArrayList features; + + public ClientSmartChargingFunction(ClientSmartChargingEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearChargingProfileFeature(this)); + features.add(new ClearedChargingLimitFeature(null)); + features.add(new GetChargingProfilesFeature(this)); + features.add(new GetCompositeScheduleFeature(this)); + features.add(new NotifyChargingLimitFeature(null)); + features.add(new NotifyEVChargingNeedsFeature(null)); + features.add(new NotifyEVChargingScheduleFeature(null)); + features.add(new ReportChargingProfilesFeature(null)); + features.add(new SetChargingProfileFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ClearChargingProfileRequest) { + return eventHandler.handleClearChargingProfileRequest((ClearChargingProfileRequest) request); + } else if (request instanceof GetChargingProfilesRequest) { + return eventHandler.handleGetChargingProfilesRequest((GetChargingProfilesRequest) request); + } else if (request instanceof GetCompositeScheduleRequest) { + return eventHandler.handleGetCompositeScheduleRequest((GetCompositeScheduleRequest) request); + } else if (request instanceof SetChargingProfileRequest) { + return eventHandler.handleSetChargingProfileRequest((SetChargingProfileRequest) request); + } + return null; + } + + /** + * Create a client {@link ClearedChargingLimitRequest} with all required fields. + * + * @param chargingLimitSource Source of the charging limit. + * @return an instance of {@link ClearedChargingLimitRequest} + */ + public ClearedChargingLimitRequest createClearedChargingLimitRequest( + ChargingLimitSourceEnum chargingLimitSource) { + return new ClearedChargingLimitRequest(chargingLimitSource); + } + + /** + * Create a client {@link NotifyChargingLimitRequest} with all required fields. + * + * @param chargingLimit Charging Limit + * @return an instance of {@link NotifyChargingLimitRequest} + */ + public NotifyChargingLimitRequest createNotifyChargingLimitRequest(ChargingLimit chargingLimit) { + return new NotifyChargingLimitRequest(chargingLimit); + } + + /** + * Create a client {@link NotifyEVChargingNeedsRequest} with all required fields. + * + * @param chargingNeeds Charging Needs + * @param evseId The EVSE and connector to which the EV is connected. EvseId may not be 0. + * @return an instance of {@link NotifyEVChargingNeedsRequest} + */ + public NotifyEVChargingNeedsRequest createNotifyEVChargingNeedsRequest( + ChargingNeeds chargingNeeds, Integer evseId) { + return new NotifyEVChargingNeedsRequest(chargingNeeds, evseId); + } + + /** + * Create a client {@link NotifyEVChargingScheduleRequest} with all required fields. + * + * @param timeBase Periods contained in the charging profile are relative to this point in time. + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: GetCompositeSchedule.conf and ChargingProfile. + * @param evseId The charging schedule contained in this notification applies to an EVSE. EvseId + * must be greater than 0. + * @return an instance of {@link NotifyEVChargingScheduleRequest} + */ + public NotifyEVChargingScheduleRequest createNotifyEVChargingScheduleRequest( + ZonedDateTime timeBase, ChargingSchedule chargingSchedule, Integer evseId) { + return new NotifyEVChargingScheduleRequest(timeBase, chargingSchedule, evseId); + } + + /** + * Create a client {@link ReportChargingProfilesRequest} with all required fields. + * + * @param requestId Id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the + * GetChargingProfilesRequest, this field SHALL contain the same value. + * @param chargingLimitSource Source that has installed this charging profile. + * @param chargingProfile A ChargingProfile consists of ChargingSchedule, describing the amount of + * power or current that can be delivered per time interval. + * @param evseId The evse to which the charging profile applies. If evseId = 0, the message + * contains an overall limit for the Charging Station. + * @return an instance of {@link ReportChargingProfilesRequest} + */ + public ReportChargingProfilesRequest createReportChargingProfilesRequest( + Integer requestId, + ChargingLimitSourceEnum chargingLimitSource, + ChargingProfile[] chargingProfile, + Integer evseId) { + return new ReportChargingProfilesRequest( + requestId, chargingLimitSource, chargingProfile, evseId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTariffAndCostEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTariffAndCostEventHandler.java new file mode 100644 index 000000000..c9b41f264 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTariffAndCostEventHandler.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the TariffAndCost functional block. */ +public interface ClientTariffAndCostEventHandler { + /** + * Handle a {@link CostUpdatedRequest} and return a {@link CostUpdatedResponse}. + * + * @param request incoming {@link CostUpdatedRequest} to handle. + * @return outgoing {@link CostUpdatedResponse} to reply with. + */ + CostUpdatedResponse handleCostUpdatedRequest(CostUpdatedRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTariffAndCostFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTariffAndCostFunction.java new file mode 100644 index 000000000..12f92a663 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTariffAndCostFunction.java @@ -0,0 +1,61 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the TariffAndCost functional block. */ +public class ClientTariffAndCostFunction implements Function { + + private final ClientTariffAndCostEventHandler eventHandler; + private final ArrayList features; + + public ClientTariffAndCostFunction(ClientTariffAndCostEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new CostUpdatedFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof CostUpdatedRequest) { + return eventHandler.handleCostUpdatedRequest((CostUpdatedRequest) request); + } + return null; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTransactionsEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTransactionsEventHandler.java new file mode 100644 index 000000000..5855f5da8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTransactionsEventHandler.java @@ -0,0 +1,39 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; + +/** Call back handler for client events of the Transactions functional block. */ +public interface ClientTransactionsEventHandler { + /** + * Handle a {@link GetTransactionStatusRequest} and return a {@link GetTransactionStatusResponse}. + * + * @param request incoming {@link GetTransactionStatusRequest} to handle. + * @return outgoing {@link GetTransactionStatusResponse} to reply with. + */ + GetTransactionStatusResponse handleGetTransactionStatusRequest( + GetTransactionStatusRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTransactionsFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTransactionsFunction.java new file mode 100644 index 000000000..e89593669 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ClientTransactionsFunction.java @@ -0,0 +1,85 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with client request creators and handlers for the Transactions functional block. */ +public class ClientTransactionsFunction implements Function { + + private final ClientTransactionsEventHandler eventHandler; + private final ArrayList features; + + public ClientTransactionsFunction(ClientTransactionsEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new GetTransactionStatusFeature(this)); + features.add(new TransactionEventFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof GetTransactionStatusRequest) { + return eventHandler.handleGetTransactionStatusRequest((GetTransactionStatusRequest) request); + } + return null; + } + + /** + * Create a client {@link TransactionEventRequest} with all required fields. + * + * @param eventType The type of this event. The first TransactionEvent of a transaction SHALL + * contain: "Started" The last TransactionEvent of a transaction SHALL contain: "Ended" All + * others SHALL contain: "Updated" + * @param timestamp The date and time at which this transaction event occurred. + * @param triggerReason Reason the Charging Station sends this message to the CSMS + * @param seqNo Incremental sequence number, helps with determining if all messages of a + * transaction have been received. + * @param transactionInfo Transaction + * @return an instance of {@link TransactionEventRequest} + */ + public TransactionEventRequest createTransactionEventRequest( + TransactionEventEnum eventType, + ZonedDateTime timestamp, + TriggerReasonEnum triggerReason, + Integer seqNo, + Transaction transactionInfo) { + return new TransactionEventRequest(eventType, timestamp, triggerReason, seqNo, transactionInfo); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAuthorizationEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAuthorizationEventHandler.java new file mode 100644 index 000000000..91c2d80d8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAuthorizationEventHandler.java @@ -0,0 +1,40 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Authorization functional block. */ +public interface ServerAuthorizationEventHandler { + /** + * Handle a {@link AuthorizeRequest} and return a {@link AuthorizeResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link AuthorizeRequest} to handle. + * @return outgoing {@link AuthorizeResponse} to reply with. + */ + AuthorizeResponse handleAuthorizeRequest(UUID sessionIndex, AuthorizeRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAuthorizationFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAuthorizationFunction.java new file mode 100644 index 000000000..e1476c153 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAuthorizationFunction.java @@ -0,0 +1,71 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Authorization functional block. */ +public class ServerAuthorizationFunction implements Function { + + private final ServerAuthorizationEventHandler eventHandler; + private final ArrayList features; + + public ServerAuthorizationFunction(ServerAuthorizationEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new AuthorizeFeature(this)); + features.add(new ClearCacheFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof AuthorizeRequest) { + return eventHandler.handleAuthorizeRequest(sessionIndex, (AuthorizeRequest) request); + } + return null; + } + + /** + * Create a server {@link ClearCacheRequest}. + * + * @return an instance of {@link ClearCacheRequest} + */ + public ClearCacheRequest createClearCacheRequest() { + return new ClearCacheRequest(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAvailabilityEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAvailabilityEventHandler.java new file mode 100644 index 000000000..c6a2393ce --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAvailabilityEventHandler.java @@ -0,0 +1,50 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Availability functional block. */ +public interface ServerAvailabilityEventHandler { + /** + * Handle a {@link NotifyEventRequest} and return a {@link NotifyEventResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyEventRequest} to handle. + * @return outgoing {@link NotifyEventResponse} to reply with. + */ + NotifyEventResponse handleNotifyEventRequest(UUID sessionIndex, NotifyEventRequest request); + + /** + * Handle a {@link StatusNotificationRequest} and return a {@link StatusNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link StatusNotificationRequest} to handle. + * @return outgoing {@link StatusNotificationResponse} to reply with. + */ + StatusNotificationResponse handleStatusNotificationRequest( + UUID sessionIndex, StatusNotificationRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAvailabilityFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAvailabilityFunction.java new file mode 100644 index 000000000..161d22210 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerAvailabilityFunction.java @@ -0,0 +1,78 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Availability functional block. */ +public class ServerAvailabilityFunction implements Function { + + private final ServerAvailabilityEventHandler eventHandler; + private final ArrayList features; + + public ServerAvailabilityFunction(ServerAvailabilityEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ChangeAvailabilityFeature(null)); + features.add(new NotifyEventFeature(this)); + features.add(new StatusNotificationFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof NotifyEventRequest) { + return eventHandler.handleNotifyEventRequest(sessionIndex, (NotifyEventRequest) request); + } else if (request instanceof StatusNotificationRequest) { + return eventHandler.handleStatusNotificationRequest( + sessionIndex, (StatusNotificationRequest) request); + } + return null; + } + + /** + * Create a server {@link ChangeAvailabilityRequest} with all required fields. + * + * @param operationalStatus The type of availability change that the Charging Station should + * perform. + * @return an instance of {@link ChangeAvailabilityRequest} + */ + public ChangeAvailabilityRequest createChangeAvailabilityRequest( + OperationalStatusEnum operationalStatus) { + return new ChangeAvailabilityRequest(operationalStatus); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDataTransferEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDataTransferEventHandler.java new file mode 100644 index 000000000..de8833fae --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDataTransferEventHandler.java @@ -0,0 +1,40 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the DataTransfer functional block. */ +public interface ServerDataTransferEventHandler { + /** + * Handle a {@link DataTransferRequest} and return a {@link DataTransferResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link DataTransferRequest} to handle. + * @return outgoing {@link DataTransferResponse} to reply with. + */ + DataTransferResponse handleDataTransferRequest(UUID sessionIndex, DataTransferRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDataTransferFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDataTransferFunction.java new file mode 100644 index 000000000..3a6096161 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDataTransferFunction.java @@ -0,0 +1,71 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the DataTransfer functional block. */ +public class ServerDataTransferFunction implements Function { + + private final ServerDataTransferEventHandler eventHandler; + private final ArrayList features; + + public ServerDataTransferFunction(ServerDataTransferEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new DataTransferFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof DataTransferRequest) { + return eventHandler.handleDataTransferRequest(sessionIndex, (DataTransferRequest) request); + } + return null; + } + + /** + * Create a server {@link DataTransferRequest} with all required fields. + * + * @param vendorId The identifier of the Vendor specific implementation + * @return an instance of {@link DataTransferRequest} + */ + public DataTransferRequest createDataTransferRequest(String vendorId) { + return new DataTransferRequest(vendorId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDiagnosticsEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDiagnosticsEventHandler.java new file mode 100644 index 000000000..10ef65fff --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDiagnosticsEventHandler.java @@ -0,0 +1,64 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Diagnostics functional block. */ +public interface ServerDiagnosticsEventHandler { + /** + * Handle a {@link LogStatusNotificationRequest} and return a {@link + * LogStatusNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link LogStatusNotificationRequest} to handle. + * @return outgoing {@link LogStatusNotificationResponse} to reply with. + */ + LogStatusNotificationResponse handleLogStatusNotificationRequest( + UUID sessionIndex, LogStatusNotificationRequest request); + + /** + * Handle a {@link NotifyCustomerInformationRequest} and return a {@link + * NotifyCustomerInformationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyCustomerInformationRequest} to handle. + * @return outgoing {@link NotifyCustomerInformationResponse} to reply with. + */ + NotifyCustomerInformationResponse handleNotifyCustomerInformationRequest( + UUID sessionIndex, NotifyCustomerInformationRequest request); + + /** + * Handle a {@link NotifyMonitoringReportRequest} and return a {@link + * NotifyMonitoringReportResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyMonitoringReportRequest} to handle. + * @return outgoing {@link NotifyMonitoringReportResponse} to reply with. + */ + NotifyMonitoringReportResponse handleNotifyMonitoringReportRequest( + UUID sessionIndex, NotifyMonitoringReportRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDiagnosticsFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDiagnosticsFunction.java new file mode 100644 index 000000000..389a11687 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDiagnosticsFunction.java @@ -0,0 +1,159 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Diagnostics functional block. */ +public class ServerDiagnosticsFunction implements Function { + + private final ServerDiagnosticsEventHandler eventHandler; + private final ArrayList features; + + public ServerDiagnosticsFunction(ServerDiagnosticsEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearVariableMonitoringFeature(null)); + features.add(new CustomerInformationFeature(null)); + features.add(new GetLogFeature(null)); + features.add(new GetMonitoringReportFeature(null)); + features.add(new LogStatusNotificationFeature(this)); + features.add(new NotifyCustomerInformationFeature(this)); + features.add(new NotifyMonitoringReportFeature(this)); + features.add(new SetMonitoringBaseFeature(null)); + features.add(new SetMonitoringLevelFeature(null)); + features.add(new SetVariableMonitoringFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof LogStatusNotificationRequest) { + return eventHandler.handleLogStatusNotificationRequest( + sessionIndex, (LogStatusNotificationRequest) request); + } else if (request instanceof NotifyCustomerInformationRequest) { + return eventHandler.handleNotifyCustomerInformationRequest( + sessionIndex, (NotifyCustomerInformationRequest) request); + } else if (request instanceof NotifyMonitoringReportRequest) { + return eventHandler.handleNotifyMonitoringReportRequest( + sessionIndex, (NotifyMonitoringReportRequest) request); + } + return null; + } + + /** + * Create a server {@link ClearVariableMonitoringRequest} with all required fields. + * + * @param id List of the monitors to be cleared, identified by there Id. + * @return an instance of {@link ClearVariableMonitoringRequest} + */ + public ClearVariableMonitoringRequest createClearVariableMonitoringRequest(Integer[] id) { + return new ClearVariableMonitoringRequest(id); + } + + /** + * Create a server {@link CustomerInformationRequest} with all required fields. + * + * @param requestId The Id of the request. + * @param report Flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer + * referred to. + * @param clear Flag indicating whether the Charging Station should clear all information about + * the customer referred to. + * @return an instance of {@link CustomerInformationRequest} + */ + public CustomerInformationRequest createCustomerInformationRequest( + Integer requestId, Boolean report, Boolean clear) { + return new CustomerInformationRequest(requestId, report, clear); + } + + /** + * Create a server {@link GetLogRequest} with all required fields. + * + * @param log Generic class for the configuration of logging entries. + * @param logType The type of log file that the Charging Station should send. + * @param requestId The Id of this request + * @return an instance of {@link GetLogRequest} + */ + public GetLogRequest createGetLogRequest(LogParameters log, LogEnum logType, Integer requestId) { + return new GetLogRequest(log, logType, requestId); + } + + /** + * Create a server {@link GetMonitoringReportRequest} with all required fields. + * + * @param requestId The Id of the request. + * @return an instance of {@link GetMonitoringReportRequest} + */ + public GetMonitoringReportRequest createGetMonitoringReportRequest(Integer requestId) { + return new GetMonitoringReportRequest(requestId); + } + + /** + * Create a server {@link SetMonitoringBaseRequest} with all required fields. + * + * @param monitoringBase Specify which monitoring base will be set + * @return an instance of {@link SetMonitoringBaseRequest} + */ + public SetMonitoringBaseRequest createSetMonitoringBaseRequest( + MonitoringBaseEnum monitoringBase) { + return new SetMonitoringBaseRequest(monitoringBase); + } + + /** + * Create a server {@link SetMonitoringLevelRequest} with all required fields. + * + * @param severity The Charging Station SHALL only report events with a severity number lower than + * or equal to this severity. The severity range is 0-9, with 0 as the highest and 9 as the + * lowest severity level. + * @return an instance of {@link SetMonitoringLevelRequest} + */ + public SetMonitoringLevelRequest createSetMonitoringLevelRequest(Integer severity) { + return new SetMonitoringLevelRequest(severity); + } + + /** + * Create a server {@link SetVariableMonitoringRequest} with all required fields. + * + * @param setMonitoringData Class to hold parameters of SetVariableMonitoring request. + * @return an instance of {@link SetVariableMonitoringRequest} + */ + public SetVariableMonitoringRequest createSetVariableMonitoringRequest( + SetMonitoringData[] setMonitoringData) { + return new SetVariableMonitoringRequest(setMonitoringData); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDisplayMessageEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDisplayMessageEventHandler.java new file mode 100644 index 000000000..57f7f0767 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDisplayMessageEventHandler.java @@ -0,0 +1,42 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the DisplayMessage functional block. */ +public interface ServerDisplayMessageEventHandler { + /** + * Handle a {@link NotifyDisplayMessagesRequest} and return a {@link + * NotifyDisplayMessagesResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyDisplayMessagesRequest} to handle. + * @return outgoing {@link NotifyDisplayMessagesResponse} to reply with. + */ + NotifyDisplayMessagesResponse handleNotifyDisplayMessagesRequest( + UUID sessionIndex, NotifyDisplayMessagesRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDisplayMessageFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDisplayMessageFunction.java new file mode 100644 index 000000000..7346782bd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerDisplayMessageFunction.java @@ -0,0 +1,95 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the DisplayMessage functional block. */ +public class ServerDisplayMessageFunction implements Function { + + private final ServerDisplayMessageEventHandler eventHandler; + private final ArrayList features; + + public ServerDisplayMessageFunction(ServerDisplayMessageEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearDisplayMessageFeature(null)); + features.add(new GetDisplayMessagesFeature(null)); + features.add(new NotifyDisplayMessagesFeature(this)); + features.add(new SetDisplayMessageFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof NotifyDisplayMessagesRequest) { + return eventHandler.handleNotifyDisplayMessagesRequest( + sessionIndex, (NotifyDisplayMessagesRequest) request); + } + return null; + } + + /** + * Create a server {@link ClearDisplayMessageRequest} with all required fields. + * + * @param id Id of the message that SHALL be removed from the Charging Station. + * @return an instance of {@link ClearDisplayMessageRequest} + */ + public ClearDisplayMessageRequest createClearDisplayMessageRequest(Integer id) { + return new ClearDisplayMessageRequest(id); + } + + /** + * Create a server {@link GetDisplayMessagesRequest} with all required fields. + * + * @param requestId The Id of this request. + * @return an instance of {@link GetDisplayMessagesRequest} + */ + public GetDisplayMessagesRequest createGetDisplayMessagesRequest(Integer requestId) { + return new GetDisplayMessagesRequest(requestId); + } + + /** + * Create a server {@link SetDisplayMessageRequest} with all required fields. + * + * @param message Message details, for a message to be displayed on a Charging Station. + * @return an instance of {@link SetDisplayMessageRequest} + */ + public SetDisplayMessageRequest createSetDisplayMessageRequest(MessageInfo message) { + return new SetDisplayMessageRequest(message); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerFirmwareManagementEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerFirmwareManagementEventHandler.java new file mode 100644 index 000000000..0e2524b58 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerFirmwareManagementEventHandler.java @@ -0,0 +1,53 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the FirmwareManagement functional block. */ +public interface ServerFirmwareManagementEventHandler { + /** + * Handle a {@link FirmwareStatusNotificationRequest} and return a {@link + * FirmwareStatusNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link FirmwareStatusNotificationRequest} to handle. + * @return outgoing {@link FirmwareStatusNotificationResponse} to reply with. + */ + FirmwareStatusNotificationResponse handleFirmwareStatusNotificationRequest( + UUID sessionIndex, FirmwareStatusNotificationRequest request); + + /** + * Handle a {@link PublishFirmwareStatusNotificationRequest} and return a {@link + * PublishFirmwareStatusNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link PublishFirmwareStatusNotificationRequest} to handle. + * @return outgoing {@link PublishFirmwareStatusNotificationResponse} to reply with. + */ + PublishFirmwareStatusNotificationResponse handlePublishFirmwareStatusNotificationRequest( + UUID sessionIndex, PublishFirmwareStatusNotificationRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerFirmwareManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerFirmwareManagementFunction.java new file mode 100644 index 000000000..6a7f0cf8f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerFirmwareManagementFunction.java @@ -0,0 +1,106 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the FirmwareManagement functional block. */ +public class ServerFirmwareManagementFunction implements Function { + + private final ServerFirmwareManagementEventHandler eventHandler; + private final ArrayList features; + + public ServerFirmwareManagementFunction(ServerFirmwareManagementEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new FirmwareStatusNotificationFeature(this)); + features.add(new PublishFirmwareFeature(null)); + features.add(new PublishFirmwareStatusNotificationFeature(this)); + features.add(new UnpublishFirmwareFeature(null)); + features.add(new UpdateFirmwareFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof FirmwareStatusNotificationRequest) { + return eventHandler.handleFirmwareStatusNotificationRequest( + sessionIndex, (FirmwareStatusNotificationRequest) request); + } else if (request instanceof PublishFirmwareStatusNotificationRequest) { + return eventHandler.handlePublishFirmwareStatusNotificationRequest( + sessionIndex, (PublishFirmwareStatusNotificationRequest) request); + } + return null; + } + + /** + * Create a server {@link PublishFirmwareRequest} with all required fields. + * + * @param location A string containing a URI pointing to a location from which to retrieve the + * firmware. + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32. + * @param requestId The Id of the request. + * @return an instance of {@link PublishFirmwareRequest} + */ + public PublishFirmwareRequest createPublishFirmwareRequest( + String location, String checksum, Integer requestId) { + return new PublishFirmwareRequest(location, checksum, requestId); + } + + /** + * Create a server {@link UnpublishFirmwareRequest} with all required fields. + * + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32. + * @return an instance of {@link UnpublishFirmwareRequest} + */ + public UnpublishFirmwareRequest createUnpublishFirmwareRequest(String checksum) { + return new UnpublishFirmwareRequest(checksum); + } + + /** + * Create a server {@link UpdateFirmwareRequest} with all required fields. + * + * @param requestId The Id of this request + * @param firmware A copy of the firmware that can be loaded/updated on the Charging Station. + * @return an instance of {@link UpdateFirmwareRequest} + */ + public UpdateFirmwareRequest createUpdateFirmwareRequest(Integer requestId, Firmware firmware) { + return new UpdateFirmwareRequest(requestId, firmware); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerISO15118CertificateManagementEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerISO15118CertificateManagementEventHandler.java new file mode 100644 index 000000000..9ec860065 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerISO15118CertificateManagementEventHandler.java @@ -0,0 +1,52 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the ISO15118CertificateManagement functional block. */ +public interface ServerISO15118CertificateManagementEventHandler { + /** + * Handle a {@link Get15118EVCertificateRequest} and return a {@link + * Get15118EVCertificateResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link Get15118EVCertificateRequest} to handle. + * @return outgoing {@link Get15118EVCertificateResponse} to reply with. + */ + Get15118EVCertificateResponse handleGet15118EVCertificateRequest( + UUID sessionIndex, Get15118EVCertificateRequest request); + + /** + * Handle a {@link GetCertificateStatusRequest} and return a {@link GetCertificateStatusResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link GetCertificateStatusRequest} to handle. + * @return outgoing {@link GetCertificateStatusResponse} to reply with. + */ + GetCertificateStatusResponse handleGetCertificateStatusRequest( + UUID sessionIndex, GetCertificateStatusRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerISO15118CertificateManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerISO15118CertificateManagementFunction.java new file mode 100644 index 000000000..915caafca --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerISO15118CertificateManagementFunction.java @@ -0,0 +1,92 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** + * Class with server request creators and handlers for the ISO15118CertificateManagement functional + * block. + */ +public class ServerISO15118CertificateManagementFunction implements Function { + + private final ServerISO15118CertificateManagementEventHandler eventHandler; + private final ArrayList features; + + public ServerISO15118CertificateManagementFunction( + ServerISO15118CertificateManagementEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new DeleteCertificateFeature(null)); + features.add(new Get15118EVCertificateFeature(this)); + features.add(new GetCertificateStatusFeature(this)); + features.add(new GetInstalledCertificateIdsFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof Get15118EVCertificateRequest) { + return eventHandler.handleGet15118EVCertificateRequest( + sessionIndex, (Get15118EVCertificateRequest) request); + } else if (request instanceof GetCertificateStatusRequest) { + return eventHandler.handleGetCertificateStatusRequest( + sessionIndex, (GetCertificateStatusRequest) request); + } + return null; + } + + /** + * Create a server {@link DeleteCertificateRequest} with all required fields. + * + * @param certificateHashData certificateHashData + * @return an instance of {@link DeleteCertificateRequest} + */ + public DeleteCertificateRequest createDeleteCertificateRequest( + CertificateHashData certificateHashData) { + return new DeleteCertificateRequest(certificateHashData); + } + + /** + * Create a server {@link GetInstalledCertificateIdsRequest}. + * + * @return an instance of {@link GetInstalledCertificateIdsRequest} + */ + public GetInstalledCertificateIdsRequest createGetInstalledCertificateIdsRequest() { + return new GetInstalledCertificateIdsRequest(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerLocalAuthorizationListManagementFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerLocalAuthorizationListManagementFunction.java new file mode 100644 index 000000000..d7a9d791e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerLocalAuthorizationListManagementFunction.java @@ -0,0 +1,83 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** + * Class with server request creators and handlers for the LocalAuthorizationListManagement + * functional block. + */ +public class ServerLocalAuthorizationListManagementFunction implements Function { + + private final ArrayList features; + + public ServerLocalAuthorizationListManagementFunction() { + features = new ArrayList<>(); + features.add(new GetLocalListVersionFeature(null)); + features.add(new SendLocalListFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + return null; + } + + /** + * Create a server {@link GetLocalListVersionRequest}. + * + * @return an instance of {@link GetLocalListVersionRequest} + */ + public GetLocalListVersionRequest createGetLocalListVersionRequest() { + return new GetLocalListVersionRequest(); + } + + /** + * Create a server {@link SendLocalListRequest} with all required fields. + * + * @param versionNumber In case of a full update this is the version number of the full list. In + * case of a differential update it is the version number of the list after the update has + * been applied. + * @param updateType The type of update (full or differential) of this request. + * @return an instance of {@link SendLocalListRequest} + */ + public SendLocalListRequest createSendLocalListRequest( + Integer versionNumber, UpdateEnum updateType) { + return new SendLocalListRequest(versionNumber, updateType); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerMeterValuesEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerMeterValuesEventHandler.java new file mode 100644 index 000000000..b898a8465 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerMeterValuesEventHandler.java @@ -0,0 +1,40 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the MeterValues functional block. */ +public interface ServerMeterValuesEventHandler { + /** + * Handle a {@link MeterValuesRequest} and return a {@link MeterValuesResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link MeterValuesRequest} to handle. + * @return outgoing {@link MeterValuesResponse} to reply with. + */ + MeterValuesResponse handleMeterValuesRequest(UUID sessionIndex, MeterValuesRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerMeterValuesFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerMeterValuesFunction.java new file mode 100644 index 000000000..47a0bb87f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerMeterValuesFunction.java @@ -0,0 +1,61 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the MeterValues functional block. */ +public class ServerMeterValuesFunction implements Function { + + private final ServerMeterValuesEventHandler eventHandler; + private final ArrayList features; + + public ServerMeterValuesFunction(ServerMeterValuesEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new MeterValuesFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof MeterValuesRequest) { + return eventHandler.handleMeterValuesRequest(sessionIndex, (MeterValuesRequest) request); + } + return null; + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerProvisioningEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerProvisioningEventHandler.java new file mode 100644 index 000000000..68d0903b8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerProvisioningEventHandler.java @@ -0,0 +1,59 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Provisioning functional block. */ +public interface ServerProvisioningEventHandler { + /** + * Handle a {@link BootNotificationRequest} and return a {@link BootNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link BootNotificationRequest} to handle. + * @return outgoing {@link BootNotificationResponse} to reply with. + */ + BootNotificationResponse handleBootNotificationRequest( + UUID sessionIndex, BootNotificationRequest request); + + /** + * Handle a {@link HeartbeatRequest} and return a {@link HeartbeatResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link HeartbeatRequest} to handle. + * @return outgoing {@link HeartbeatResponse} to reply with. + */ + HeartbeatResponse handleHeartbeatRequest(UUID sessionIndex, HeartbeatRequest request); + + /** + * Handle a {@link NotifyReportRequest} and return a {@link NotifyReportResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyReportRequest} to handle. + * @return outgoing {@link NotifyReportResponse} to reply with. + */ + NotifyReportResponse handleNotifyReportRequest(UUID sessionIndex, NotifyReportRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerProvisioningFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerProvisioningFunction.java new file mode 100644 index 000000000..e6f86c9c5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerProvisioningFunction.java @@ -0,0 +1,139 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Provisioning functional block. */ +public class ServerProvisioningFunction implements Function { + + private final ServerProvisioningEventHandler eventHandler; + private final ArrayList features; + + public ServerProvisioningFunction(ServerProvisioningEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new BootNotificationFeature(this)); + features.add(new GetBaseReportFeature(null)); + features.add(new GetReportFeature(null)); + features.add(new GetVariablesFeature(null)); + features.add(new HeartbeatFeature(this)); + features.add(new NotifyReportFeature(this)); + features.add(new ResetFeature(null)); + features.add(new SetNetworkProfileFeature(null)); + features.add(new SetVariablesFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof BootNotificationRequest) { + return eventHandler.handleBootNotificationRequest( + sessionIndex, (BootNotificationRequest) request); + } else if (request instanceof HeartbeatRequest) { + return eventHandler.handleHeartbeatRequest(sessionIndex, (HeartbeatRequest) request); + } else if (request instanceof NotifyReportRequest) { + return eventHandler.handleNotifyReportRequest(sessionIndex, (NotifyReportRequest) request); + } + return null; + } + + /** + * Create a server {@link GetBaseReportRequest} with all required fields. + * + * @param requestId The Id of the request. + * @param reportBase The report base. + * @return an instance of {@link GetBaseReportRequest} + */ + public GetBaseReportRequest createGetBaseReportRequest( + Integer requestId, ReportBaseEnum reportBase) { + return new GetBaseReportRequest(requestId, reportBase); + } + + /** + * Create a server {@link GetReportRequest} with all required fields. + * + * @param requestId The Id of the request. + * @return an instance of {@link GetReportRequest} + */ + public GetReportRequest createGetReportRequest(Integer requestId) { + return new GetReportRequest(requestId); + } + + /** + * Create a server {@link GetVariablesRequest} with all required fields. + * + * @param getVariableData Class to hold parameters for GetVariables request. + * @return an instance of {@link GetVariablesRequest} + */ + public GetVariablesRequest createGetVariablesRequest(GetVariableData[] getVariableData) { + return new GetVariablesRequest(getVariableData); + } + + /** + * Create a server {@link ResetRequest} with all required fields. + * + * @param type The type of reset that the Charging Station or EVSE should perform. + * @return an instance of {@link ResetRequest} + */ + public ResetRequest createResetRequest(ResetEnum type) { + return new ResetRequest(type); + } + + /** + * Create a server {@link SetNetworkProfileRequest} with all required fields. + * + * @param configurationSlot Slot in which the configuration should be stored. + * @param connectionData The NetworkConnectionProfile defines the functional and technical + * parameters of a communication link. + * @return an instance of {@link SetNetworkProfileRequest} + */ + public SetNetworkProfileRequest createSetNetworkProfileRequest( + Integer configurationSlot, NetworkConnectionProfile connectionData) { + return new SetNetworkProfileRequest(configurationSlot, connectionData); + } + + /** + * Create a server {@link SetVariablesRequest} with all required fields. + * + * @param setVariableData setVariableData + * @return an instance of {@link SetVariablesRequest} + */ + public SetVariablesRequest createSetVariablesRequest(SetVariableData[] setVariableData) { + return new SetVariablesRequest(setVariableData); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerRemoteControlFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerRemoteControlFunction.java new file mode 100644 index 000000000..c33f6c5c8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerRemoteControlFunction.java @@ -0,0 +1,106 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the RemoteControl functional block. */ +public class ServerRemoteControlFunction implements Function { + + private final ArrayList features; + + public ServerRemoteControlFunction() { + features = new ArrayList<>(); + features.add(new RequestStartTransactionFeature(null)); + features.add(new RequestStopTransactionFeature(null)); + features.add(new TriggerMessageFeature(null)); + features.add(new UnlockConnectorFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + return null; + } + + /** + * Create a server {@link RequestStartTransactionRequest} with all required fields. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @param remoteStartId Id given by the server to this start request. The Charging Station might + * return this in the TransactionEventRequest, letting the server know which transaction was + * started for this request. Use to start a transaction. + * @return an instance of {@link RequestStartTransactionRequest} + */ + public RequestStartTransactionRequest createRequestStartTransactionRequest( + IdToken idToken, Integer remoteStartId) { + return new RequestStartTransactionRequest(idToken, remoteStartId); + } + + /** + * Create a server {@link RequestStopTransactionRequest} with all required fields. + * + * @param transactionId The identifier of the transaction which the Charging Station is requested + * to stop. + * @return an instance of {@link RequestStopTransactionRequest} + */ + public RequestStopTransactionRequest createRequestStopTransactionRequest(String transactionId) { + return new RequestStopTransactionRequest(transactionId); + } + + /** + * Create a server {@link TriggerMessageRequest} with all required fields. + * + * @param requestedMessage Type of message to be triggered. + * @return an instance of {@link TriggerMessageRequest} + */ + public TriggerMessageRequest createTriggerMessageRequest(MessageTriggerEnum requestedMessage) { + return new TriggerMessageRequest(requestedMessage); + } + + /** + * Create a server {@link UnlockConnectorRequest} with all required fields. + * + * @param evseId The identifier of the EVSE for which a connector needs to be unlocked. + * @param connectorId The identifier of the connector that needs to be unlocked. + * @return an instance of {@link UnlockConnectorRequest} + */ + public UnlockConnectorRequest createUnlockConnectorRequest(Integer evseId, Integer connectorId) { + return new UnlockConnectorRequest(evseId, connectorId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerReservationEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerReservationEventHandler.java new file mode 100644 index 000000000..20be09aa2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerReservationEventHandler.java @@ -0,0 +1,42 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Reservation functional block. */ +public interface ServerReservationEventHandler { + /** + * Handle a {@link ReservationStatusUpdateRequest} and return a {@link + * ReservationStatusUpdateResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link ReservationStatusUpdateRequest} to handle. + * @return outgoing {@link ReservationStatusUpdateResponse} to reply with. + */ + ReservationStatusUpdateResponse handleReservationStatusUpdateRequest( + UUID sessionIndex, ReservationStatusUpdateRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerReservationFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerReservationFunction.java new file mode 100644 index 000000000..207d586fb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerReservationFunction.java @@ -0,0 +1,89 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Reservation functional block. */ +public class ServerReservationFunction implements Function { + + private final ServerReservationEventHandler eventHandler; + private final ArrayList features; + + public ServerReservationFunction(ServerReservationEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new CancelReservationFeature(null)); + features.add(new ReservationStatusUpdateFeature(this)); + features.add(new ReserveNowFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ReservationStatusUpdateRequest) { + return eventHandler.handleReservationStatusUpdateRequest( + sessionIndex, (ReservationStatusUpdateRequest) request); + } + return null; + } + + /** + * Create a server {@link CancelReservationRequest} with all required fields. + * + * @param reservationId Id of the reservation to cancel. + * @return an instance of {@link CancelReservationRequest} + */ + public CancelReservationRequest createCancelReservationRequest(Integer reservationId) { + return new CancelReservationRequest(reservationId); + } + + /** + * Create a server {@link ReserveNowRequest} with all required fields. + * + * @param id Id of reservation. + * @param expiryDateTime Date and time at which the reservation expires. + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @return an instance of {@link ReserveNowRequest} + */ + public ReserveNowRequest createReserveNowRequest( + Integer id, ZonedDateTime expiryDateTime, IdToken idToken) { + return new ReserveNowRequest(id, expiryDateTime, idToken); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSecurityEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSecurityEventHandler.java new file mode 100644 index 000000000..f721e69b0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSecurityEventHandler.java @@ -0,0 +1,52 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Security functional block. */ +public interface ServerSecurityEventHandler { + /** + * Handle a {@link SecurityEventNotificationRequest} and return a {@link + * SecurityEventNotificationResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link SecurityEventNotificationRequest} to handle. + * @return outgoing {@link SecurityEventNotificationResponse} to reply with. + */ + SecurityEventNotificationResponse handleSecurityEventNotificationRequest( + UUID sessionIndex, SecurityEventNotificationRequest request); + + /** + * Handle a {@link SignCertificateRequest} and return a {@link SignCertificateResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link SignCertificateRequest} to handle. + * @return outgoing {@link SignCertificateResponse} to reply with. + */ + SignCertificateResponse handleSignCertificateRequest( + UUID sessionIndex, SignCertificateRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSecurityFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSecurityFunction.java new file mode 100644 index 000000000..638402a63 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSecurityFunction.java @@ -0,0 +1,92 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Security functional block. */ +public class ServerSecurityFunction implements Function { + + private final ServerSecurityEventHandler eventHandler; + private final ArrayList features; + + public ServerSecurityFunction(ServerSecurityEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new CertificateSignedFeature(null)); + features.add(new InstallCertificateFeature(null)); + features.add(new SecurityEventNotificationFeature(this)); + features.add(new SignCertificateFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof SecurityEventNotificationRequest) { + return eventHandler.handleSecurityEventNotificationRequest( + sessionIndex, (SecurityEventNotificationRequest) request); + } else if (request instanceof SignCertificateRequest) { + return eventHandler.handleSignCertificateRequest( + sessionIndex, (SignCertificateRequest) request); + } + return null; + } + + /** + * Create a server {@link CertificateSignedRequest} with all required fields. + * + * @param certificateChain The signed PEM encoded X.509 certificate. This can also contain the + * necessary sub CA certificates. In that case, the order of the bundle should follow the + * certificate chain, starting from the leaf certificate. + * @return an instance of {@link CertificateSignedRequest} + */ + public CertificateSignedRequest createCertificateSignedRequest(String certificateChain) { + return new CertificateSignedRequest(certificateChain); + } + + /** + * Create a server {@link InstallCertificateRequest} with all required fields. + * + * @param certificateType The certificate type that is sent. + * @param certificate A PEM encoded X.509 certificate. + * @return an instance of {@link InstallCertificateRequest} + */ + public InstallCertificateRequest createInstallCertificateRequest( + InstallCertificateUseEnum certificateType, String certificate) { + return new InstallCertificateRequest(certificateType, certificate); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSmartChargingEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSmartChargingEventHandler.java new file mode 100644 index 000000000..6eb2a274d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSmartChargingEventHandler.java @@ -0,0 +1,84 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the SmartCharging functional block. */ +public interface ServerSmartChargingEventHandler { + /** + * Handle a {@link ClearedChargingLimitRequest} and return a {@link ClearedChargingLimitResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link ClearedChargingLimitRequest} to handle. + * @return outgoing {@link ClearedChargingLimitResponse} to reply with. + */ + ClearedChargingLimitResponse handleClearedChargingLimitRequest( + UUID sessionIndex, ClearedChargingLimitRequest request); + + /** + * Handle a {@link NotifyChargingLimitRequest} and return a {@link NotifyChargingLimitResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyChargingLimitRequest} to handle. + * @return outgoing {@link NotifyChargingLimitResponse} to reply with. + */ + NotifyChargingLimitResponse handleNotifyChargingLimitRequest( + UUID sessionIndex, NotifyChargingLimitRequest request); + + /** + * Handle a {@link NotifyEVChargingNeedsRequest} and return a {@link + * NotifyEVChargingNeedsResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyEVChargingNeedsRequest} to handle. + * @return outgoing {@link NotifyEVChargingNeedsResponse} to reply with. + */ + NotifyEVChargingNeedsResponse handleNotifyEVChargingNeedsRequest( + UUID sessionIndex, NotifyEVChargingNeedsRequest request); + + /** + * Handle a {@link NotifyEVChargingScheduleRequest} and return a {@link + * NotifyEVChargingScheduleResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link NotifyEVChargingScheduleRequest} to handle. + * @return outgoing {@link NotifyEVChargingScheduleResponse} to reply with. + */ + NotifyEVChargingScheduleResponse handleNotifyEVChargingScheduleRequest( + UUID sessionIndex, NotifyEVChargingScheduleRequest request); + + /** + * Handle a {@link ReportChargingProfilesRequest} and return a {@link + * ReportChargingProfilesResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link ReportChargingProfilesRequest} to handle. + * @return outgoing {@link ReportChargingProfilesResponse} to reply with. + */ + ReportChargingProfilesResponse handleReportChargingProfilesRequest( + UUID sessionIndex, ReportChargingProfilesRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSmartChargingFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSmartChargingFunction.java new file mode 100644 index 000000000..5cb282541 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerSmartChargingFunction.java @@ -0,0 +1,133 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the SmartCharging functional block. */ +public class ServerSmartChargingFunction implements Function { + + private final ServerSmartChargingEventHandler eventHandler; + private final ArrayList features; + + public ServerSmartChargingFunction(ServerSmartChargingEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new ClearChargingProfileFeature(null)); + features.add(new ClearedChargingLimitFeature(this)); + features.add(new GetChargingProfilesFeature(null)); + features.add(new GetCompositeScheduleFeature(null)); + features.add(new NotifyChargingLimitFeature(this)); + features.add(new NotifyEVChargingNeedsFeature(this)); + features.add(new NotifyEVChargingScheduleFeature(this)); + features.add(new ReportChargingProfilesFeature(this)); + features.add(new SetChargingProfileFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof ClearedChargingLimitRequest) { + return eventHandler.handleClearedChargingLimitRequest( + sessionIndex, (ClearedChargingLimitRequest) request); + } else if (request instanceof NotifyChargingLimitRequest) { + return eventHandler.handleNotifyChargingLimitRequest( + sessionIndex, (NotifyChargingLimitRequest) request); + } else if (request instanceof NotifyEVChargingNeedsRequest) { + return eventHandler.handleNotifyEVChargingNeedsRequest( + sessionIndex, (NotifyEVChargingNeedsRequest) request); + } else if (request instanceof NotifyEVChargingScheduleRequest) { + return eventHandler.handleNotifyEVChargingScheduleRequest( + sessionIndex, (NotifyEVChargingScheduleRequest) request); + } else if (request instanceof ReportChargingProfilesRequest) { + return eventHandler.handleReportChargingProfilesRequest( + sessionIndex, (ReportChargingProfilesRequest) request); + } + return null; + } + + /** + * Create a server {@link ClearChargingProfileRequest}. + * + * @return an instance of {@link ClearChargingProfileRequest} + */ + public ClearChargingProfileRequest createClearChargingProfileRequest() { + return new ClearChargingProfileRequest(); + } + + /** + * Create a server {@link GetChargingProfilesRequest} with all required fields. + * + * @param requestId Reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided. + * @param chargingProfile A ChargingProfile consists of ChargingSchedule, describing the amount of + * power or current that can be delivered per time interval. + * @return an instance of {@link GetChargingProfilesRequest} + */ + public GetChargingProfilesRequest createGetChargingProfilesRequest( + Integer requestId, ChargingProfileCriterion chargingProfile) { + return new GetChargingProfilesRequest(requestId, chargingProfile); + } + + /** + * Create a server {@link GetCompositeScheduleRequest} with all required fields. + * + * @param duration Length of the requested schedule in seconds. + * @param evseId The ID of the EVSE for which the schedule is requested. When evseid=0, the + * Charging Station will calculate the expected consumption for the grid connection. + * @return an instance of {@link GetCompositeScheduleRequest} + */ + public GetCompositeScheduleRequest createGetCompositeScheduleRequest( + Integer duration, Integer evseId) { + return new GetCompositeScheduleRequest(duration, evseId); + } + + /** + * Create a server {@link SetChargingProfileRequest} with all required fields. + * + * @param evseId For TxDefaultProfile an evseId=0 applies the profile to each individual evse. For + * ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an + * overal limit for the whole Charging Station. + * @param chargingProfile A ChargingProfile consists of ChargingSchedule, describing the amount of + * power or current that can be delivered per time interval. + * @return an instance of {@link SetChargingProfileRequest} + */ + public SetChargingProfileRequest createSetChargingProfileRequest( + Integer evseId, ChargingProfile chargingProfile) { + return new SetChargingProfileRequest(evseId, chargingProfile); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerTariffAndCostFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerTariffAndCostFunction.java new file mode 100644 index 000000000..9d35676c2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerTariffAndCostFunction.java @@ -0,0 +1,69 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the TariffAndCost functional block. */ +public class ServerTariffAndCostFunction implements Function { + + private final ArrayList features; + + public ServerTariffAndCostFunction() { + features = new ArrayList<>(); + features.add(new CostUpdatedFeature(null)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + return null; + } + + /** + * Create a server {@link CostUpdatedRequest} with all required fields. + * + * @param totalCost Current total cost, based on the information known by the CSMS, of the + * transaction including taxes. In the currency configured with the configuration Variable: + * [Currency] + * @param transactionId Transaction Id of the transaction the current cost are asked for. + * @return an instance of {@link CostUpdatedRequest} + */ + public CostUpdatedRequest createCostUpdatedRequest(Double totalCost, String transactionId) { + return new CostUpdatedRequest(totalCost, transactionId); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerTransactionsEventHandler.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerTransactionsEventHandler.java new file mode 100644 index 000000000..e8a890dfc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerTransactionsEventHandler.java @@ -0,0 +1,41 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.v201.model.messages.*; +import java.util.UUID; + +/** Call back handler for server events of the Transactions functional block. */ +public interface ServerTransactionsEventHandler { + /** + * Handle a {@link TransactionEventRequest} and return a {@link TransactionEventResponse}. + * + * @param sessionIndex identifier of the session on which the request was received. + * @param request incoming {@link TransactionEventRequest} to handle. + * @return outgoing {@link TransactionEventResponse} to reply with. + */ + TransactionEventResponse handleTransactionEventRequest( + UUID sessionIndex, TransactionEventRequest request); +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerTransactionsFunction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerTransactionsFunction.java new file mode 100644 index 000000000..a5b974344 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/feature/function/ServerTransactionsFunction.java @@ -0,0 +1,72 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.feature.function; + +import eu.chargetime.ocpp.feature.FunctionFeature; +import eu.chargetime.ocpp.feature.function.Function; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.model.Request; +import eu.chargetime.ocpp.v201.feature.*; +import eu.chargetime.ocpp.v201.model.messages.*; +import eu.chargetime.ocpp.v201.model.types.*; +import java.util.ArrayList; +import java.util.UUID; + +/** Class with server request creators and handlers for the Transactions functional block. */ +public class ServerTransactionsFunction implements Function { + + private final ServerTransactionsEventHandler eventHandler; + private final ArrayList features; + + public ServerTransactionsFunction(ServerTransactionsEventHandler eventHandler) { + this.eventHandler = eventHandler; + features = new ArrayList<>(); + features.add(new GetTransactionStatusFeature(null)); + features.add(new TransactionEventFeature(this)); + } + + @Override + public FunctionFeature[] getFeatureList() { + return features.toArray(new FunctionFeature[0]); + } + + @Override + public Confirmation handleRequest(UUID sessionIndex, Request request) { + if (request instanceof TransactionEventRequest) { + return eventHandler.handleTransactionEventRequest( + sessionIndex, (TransactionEventRequest) request); + } + return null; + } + + /** + * Create a server {@link GetTransactionStatusRequest}. + * + * @return an instance of {@link GetTransactionStatusRequest} + */ + public GetTransactionStatusRequest createGetTransactionStatusRequest() { + return new GetTransactionStatusRequest(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/AuthorizeRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/AuthorizeRequest.java new file mode 100644 index 000000000..41c0d4345 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/AuthorizeRequest.java @@ -0,0 +1,283 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.IdToken; +import eu.chargetime.ocpp.v201.model.types.OCSPRequestData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * AuthorizeRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class AuthorizeRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + private IdToken idToken; + + /** The X.509 certificated presented by EV and encoded in PEM format. */ + @Nullable private String certificate; + + /** iso15118CertificateHashData */ + @Nullable private OCSPRequestData[] iso15118CertificateHashData; + + /** + * Constructor for the AuthorizeRequest class + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + */ + public AuthorizeRequest(IdToken idToken) { + setIdToken(idToken); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AuthorizeRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(IdToken idToken) { + return idToken != null && idToken.validate(); + } + + /** + * Gets the X.509 certificated presented by EV and encoded in PEM format. + * + * @return The X.509 certificated presented by EV and encoded in PEM format + */ + @Nullable + public String getCertificate() { + return certificate; + } + + /** + * Sets the X.509 certificated presented by EV and encoded in PEM format. + * + * @param certificate The X.509 certificated presented by EV and encoded in PEM format + */ + public void setCertificate(@Nullable String certificate) { + if (!isValidCertificate(certificate)) { + throw new PropertyConstraintException(certificate, "certificate is invalid"); + } + this.certificate = certificate; + } + + /** + * Returns whether the given certificate is valid + * + * @param certificate the certificate to check the validity of + * @return {@code true} if certificate is valid, {@code false} if not + */ + private boolean isValidCertificate(@Nullable String certificate) { + return certificate == null || certificate.length() <= 5500; + } + + /** + * Adds the X.509 certificated presented by EV and encoded in PEM format. + * + * @param certificate The X.509 certificated presented by EV and encoded in PEM format + * @return this + */ + public AuthorizeRequest withCertificate(@Nullable String certificate) { + setCertificate(certificate); + return this; + } + + /** + * Gets iso15118CertificateHashData + * + * @return iso15118CertificateHashData + */ + @Nullable + public OCSPRequestData[] getIso15118CertificateHashData() { + return iso15118CertificateHashData; + } + + /** + * Sets iso15118CertificateHashData + * + * @param iso15118CertificateHashData iso15118CertificateHashData + */ + public void setIso15118CertificateHashData( + @Nullable OCSPRequestData[] iso15118CertificateHashData) { + if (!isValidIso15118CertificateHashData(iso15118CertificateHashData)) { + throw new PropertyConstraintException( + iso15118CertificateHashData, "iso15118CertificateHashData is invalid"); + } + this.iso15118CertificateHashData = iso15118CertificateHashData; + } + + /** + * Returns whether the given iso15118CertificateHashData is valid + * + * @param iso15118CertificateHashData the iso15118CertificateHashData to check the validity of + * @return {@code true} if iso15118CertificateHashData is valid, {@code false} if not + */ + private boolean isValidIso15118CertificateHashData( + @Nullable OCSPRequestData[] iso15118CertificateHashData) { + return iso15118CertificateHashData == null + || (iso15118CertificateHashData.length >= 1 + && iso15118CertificateHashData.length <= 4 + && Arrays.stream(iso15118CertificateHashData).allMatch(item -> item.validate())); + } + + /** + * Adds iso15118CertificateHashData + * + * @param iso15118CertificateHashData iso15118CertificateHashData + * @return this + */ + public AuthorizeRequest withIso15118CertificateHashData( + @Nullable OCSPRequestData[] iso15118CertificateHashData) { + setIso15118CertificateHashData(iso15118CertificateHashData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidIdToken(idToken) + && isValidCertificate(certificate) + && isValidIso15118CertificateHashData(iso15118CertificateHashData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AuthorizeRequest that = (AuthorizeRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(idToken, that.idToken) + && Objects.equals(certificate, that.certificate) + && Arrays.equals(iso15118CertificateHashData, that.iso15118CertificateHashData); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, idToken, certificate, Arrays.hashCode(iso15118CertificateHashData)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("idToken", idToken) + .add("certificate", certificate) + .add("iso15118CertificateHashData", iso15118CertificateHashData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/AuthorizeResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/AuthorizeResponse.java new file mode 100644 index 000000000..4dc50af57 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/AuthorizeResponse.java @@ -0,0 +1,217 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.AuthorizeCertificateStatusEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.IdTokenInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * AuthorizeResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class AuthorizeResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * ID Token + * + *

Status information about an identifier. It is advised to not stop charging for a token that + * expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not + * given, the status has no end date. + */ + private IdTokenInfo idTokenInfo; + + /** + * Certificate status information. + * + *

+   * - if all certificates are valid: return 'Accepted'.
+   * - if one of the certificates was revoked, return 'CertificateRevoked'.
+   * 
+ */ + @Nullable private AuthorizeCertificateStatusEnum certificateStatus; + + /** + * Constructor for the AuthorizeResponse class + * + * @param idTokenInfo Status information about an identifier. It is advised to not stop charging + * for a token that expires during charging, as ExpiryDate is only used for caching purposes. + * If ExpiryDate is not given, the status has no end date. + */ + public AuthorizeResponse(IdTokenInfo idTokenInfo) { + setIdTokenInfo(idTokenInfo); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AuthorizeResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @return Status information about an identifier + */ + public IdTokenInfo getIdTokenInfo() { + return idTokenInfo; + } + + /** + * Sets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @param idTokenInfo Status information about an identifier + */ + public void setIdTokenInfo(IdTokenInfo idTokenInfo) { + if (!isValidIdTokenInfo(idTokenInfo)) { + throw new PropertyConstraintException(idTokenInfo, "idTokenInfo is invalid"); + } + this.idTokenInfo = idTokenInfo; + } + + /** + * Returns whether the given idTokenInfo is valid + * + * @param idTokenInfo the idTokenInfo to check the validity of + * @return {@code true} if idTokenInfo is valid, {@code false} if not + */ + private boolean isValidIdTokenInfo(IdTokenInfo idTokenInfo) { + return idTokenInfo != null && idTokenInfo.validate(); + } + + /** + * Gets certificate status information. + * + * @return Certificate status information + */ + @Nullable + public AuthorizeCertificateStatusEnum getCertificateStatus() { + return certificateStatus; + } + + /** + * Sets certificate status information. + * + * @param certificateStatus Certificate status information + */ + public void setCertificateStatus(@Nullable AuthorizeCertificateStatusEnum certificateStatus) { + this.certificateStatus = certificateStatus; + } + + /** + * Adds certificate status information. + * + * @param certificateStatus Certificate status information + * @return this + */ + public AuthorizeResponse withCertificateStatus( + @Nullable AuthorizeCertificateStatusEnum certificateStatus) { + setCertificateStatus(certificateStatus); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidIdTokenInfo(idTokenInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AuthorizeResponse that = (AuthorizeResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(idTokenInfo, that.idTokenInfo) + && Objects.equals(certificateStatus, that.certificateStatus); + } + + @Override + public int hashCode() { + return Objects.hash(customData, idTokenInfo, certificateStatus); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("idTokenInfo", idTokenInfo) + .add("certificateStatus", certificateStatus) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/BootNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/BootNotificationRequest.java new file mode 100644 index 000000000..6cd820399 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/BootNotificationRequest.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.BootReasonEnum; +import eu.chargetime.ocpp.v201.model.types.ChargingStation; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * BootNotificationRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class BootNotificationRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Charge Point + * + *

The physical system where an Electrical Vehicle (EV) can be charged. + */ + private ChargingStation chargingStation; + + /** The reason for sending this message to the CSMS. */ + private BootReasonEnum reason; + + /** + * Constructor for the BootNotificationRequest class + * + * @param chargingStation The physical system where an Electrical Vehicle (EV) can be charged. + * @param reason The reason for sending this message to the CSMS. + */ + public BootNotificationRequest(ChargingStation chargingStation, BootReasonEnum reason) { + setChargingStation(chargingStation); + setReason(reason); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public BootNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the physical system where an Electrical Vehicle (EV) can be charged. + * + * @return The physical system where an Electrical Vehicle (EV) can be charged + */ + public ChargingStation getChargingStation() { + return chargingStation; + } + + /** + * Sets the physical system where an Electrical Vehicle (EV) can be charged. + * + * @param chargingStation The physical system where an Electrical Vehicle (EV) can be charged + */ + public void setChargingStation(ChargingStation chargingStation) { + if (!isValidChargingStation(chargingStation)) { + throw new PropertyConstraintException(chargingStation, "chargingStation is invalid"); + } + this.chargingStation = chargingStation; + } + + /** + * Returns whether the given chargingStation is valid + * + * @param chargingStation the chargingStation to check the validity of + * @return {@code true} if chargingStation is valid, {@code false} if not + */ + private boolean isValidChargingStation(ChargingStation chargingStation) { + return chargingStation != null && chargingStation.validate(); + } + + /** + * Gets the reason for sending this message to the CSMS. + * + * @return The reason for sending this message to the CSMS + */ + public BootReasonEnum getReason() { + return reason; + } + + /** + * Sets the reason for sending this message to the CSMS. + * + * @param reason The reason for sending this message to the CSMS + */ + public void setReason(BootReasonEnum reason) { + if (!isValidReason(reason)) { + throw new PropertyConstraintException(reason, "reason is invalid"); + } + this.reason = reason; + } + + /** + * Returns whether the given reason is valid + * + * @param reason the reason to check the validity of + * @return {@code true} if reason is valid, {@code false} if not + */ + private boolean isValidReason(BootReasonEnum reason) { + return reason != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidChargingStation(chargingStation) + && isValidReason(reason); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BootNotificationRequest that = (BootNotificationRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(chargingStation, that.chargingStation) + && Objects.equals(reason, that.reason); + } + + @Override + public int hashCode() { + return Objects.hash(customData, chargingStation, reason); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("chargingStation", chargingStation) + .add("reason", reason) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/BootNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/BootNotificationResponse.java new file mode 100644 index 000000000..e0b4ce702 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/BootNotificationResponse.java @@ -0,0 +1,302 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.RegistrationStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * BootNotificationResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class BootNotificationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** The CSMS’s current time. */ + private ZonedDateTime currentTime; + + /** + * When Status is Accepted, this contains the heartbeat interval in seconds. If the CSMS returns + * something other than Accepted, the value of the interval field indicates the minimum wait time + * before sending a next BootNotification request. + */ + private Integer interval; + + /** Whether the Charging Station has been registered within the CSMS. */ + private RegistrationStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the BootNotificationResponse class + * + * @param currentTime The CSMS’s current time. + * @param interval When Status is Accepted, this contains the heartbeat interval in seconds. If + * the CSMS returns something other than Accepted, the value of the interval field indicates + * the minimum wait time before sending a next BootNotification request. + * @param status Whether the Charging Station has been registered within the CSMS. + */ + public BootNotificationResponse( + ZonedDateTime currentTime, Integer interval, RegistrationStatusEnum status) { + setCurrentTime(currentTime); + setInterval(interval); + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public BootNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the CSMS’s current time. + * + * @return The CSMS’s current time + */ + public ZonedDateTime getCurrentTime() { + return currentTime; + } + + /** + * Sets the CSMS’s current time. + * + * @param currentTime The CSMS’s current time + */ + public void setCurrentTime(ZonedDateTime currentTime) { + if (!isValidCurrentTime(currentTime)) { + throw new PropertyConstraintException(currentTime, "currentTime is invalid"); + } + this.currentTime = currentTime; + } + + /** + * Returns whether the given currentTime is valid + * + * @param currentTime the currentTime to check the validity of + * @return {@code true} if currentTime is valid, {@code false} if not + */ + private boolean isValidCurrentTime(ZonedDateTime currentTime) { + return currentTime != null; + } + + /** + * Gets when Status is Accepted, this contains the heartbeat interval in seconds. If the CSMS + * returns something other than Accepted, the value of the interval field indicates the minimum + * wait time before sending a next BootNotification request. + * + * @return When Status is Accepted, this contains the heartbeat interval in seconds + */ + public Integer getInterval() { + return interval; + } + + /** + * Sets when Status is Accepted, this contains the heartbeat interval in seconds. If the CSMS + * returns something other than Accepted, the value of the interval field indicates the minimum + * wait time before sending a next BootNotification request. + * + * @param interval When Status is Accepted, this contains the heartbeat interval in seconds + */ + public void setInterval(Integer interval) { + if (!isValidInterval(interval)) { + throw new PropertyConstraintException(interval, "interval is invalid"); + } + this.interval = interval; + } + + /** + * Returns whether the given interval is valid + * + * @param interval the interval to check the validity of + * @return {@code true} if interval is valid, {@code false} if not + */ + private boolean isValidInterval(Integer interval) { + return interval != null; + } + + /** + * Gets whether the Charging Station has been registered within the CSMS. + * + * @return Whether the Charging Station has been registered within the CSMS + */ + public RegistrationStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station has been registered within the CSMS. + * + * @param status Whether the Charging Station has been registered within the CSMS + */ + public void setStatus(RegistrationStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(RegistrationStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public BootNotificationResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidCurrentTime(currentTime) + && isValidInterval(interval) + && isValidStatus(status) + && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BootNotificationResponse that = (BootNotificationResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(currentTime, that.currentTime) + && Objects.equals(interval, that.interval) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, currentTime, interval, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("currentTime", currentTime) + .add("interval", interval) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CancelReservationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CancelReservationRequest.java new file mode 100644 index 000000000..a5e36b465 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CancelReservationRequest.java @@ -0,0 +1,165 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CancelReservationRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class CancelReservationRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Id of the reservation to cancel. */ + private Integer reservationId; + + /** + * Constructor for the CancelReservationRequest class + * + * @param reservationId Id of the reservation to cancel. + */ + public CancelReservationRequest(Integer reservationId) { + setReservationId(reservationId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CancelReservationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets id of the reservation to cancel. + * + * @return Id of the reservation to cancel + */ + public Integer getReservationId() { + return reservationId; + } + + /** + * Sets id of the reservation to cancel. + * + * @param reservationId Id of the reservation to cancel + */ + public void setReservationId(Integer reservationId) { + if (!isValidReservationId(reservationId)) { + throw new PropertyConstraintException(reservationId, "reservationId is invalid"); + } + this.reservationId = reservationId; + } + + /** + * Returns whether the given reservationId is valid + * + * @param reservationId the reservationId to check the validity of + * @return {@code true} if reservationId is valid, {@code false} if not + */ + private boolean isValidReservationId(Integer reservationId) { + return reservationId != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidReservationId(reservationId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CancelReservationRequest that = (CancelReservationRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(reservationId, that.reservationId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, reservationId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("reservationId", reservationId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CancelReservationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CancelReservationResponse.java new file mode 100644 index 000000000..95e8b07a5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CancelReservationResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CancelReservationStatusEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CancelReservationResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class CancelReservationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** The success or failure of the canceling of a reservation by CSMS. */ + private CancelReservationStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the CancelReservationResponse class + * + * @param status The success or failure of the canceling of a reservation by CSMS. + */ + public CancelReservationResponse(CancelReservationStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CancelReservationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the success or failure of the canceling of a reservation by CSMS. + * + * @return The success or failure of the canceling of a reservation by CSMS + */ + public CancelReservationStatusEnum getStatus() { + return status; + } + + /** + * Sets the success or failure of the canceling of a reservation by CSMS. + * + * @param status The success or failure of the canceling of a reservation by CSMS + */ + public void setStatus(CancelReservationStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(CancelReservationStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public CancelReservationResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CancelReservationResponse that = (CancelReservationResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CertificateSignedRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CertificateSignedRequest.java new file mode 100644 index 000000000..e23733346 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CertificateSignedRequest.java @@ -0,0 +1,233 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CertificateSigningUseEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CertificateSignedRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class CertificateSignedRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * The signed PEM encoded X.509 certificate. This can also contain the necessary sub CA + * certificates. In that case, the order of the bundle should follow the certificate chain, + * starting from the leaf certificate. + * + *

The Configuration Variable MaxCertificateChainSize can be used to limit the maximum size of + * this field. + */ + private String certificateChain; + + /** + * The type of the signed certificate that is returned. When omitted the certificate is used for + * both the 15118 connection (if implemented) and the Charging Station to CSMS connection. This + * field is required when a typeOfCertificate was included in the SignCertificateRequest that + * requested this certificate to be signed AND both the 15118 connection and the Charging Station + * connection are implemented. + */ + @Nullable private CertificateSigningUseEnum certificateType; + + /** + * Constructor for the CertificateSignedRequest class + * + * @param certificateChain The signed PEM encoded X.509 certificate. This can also contain the + * necessary sub CA certificates. In that case, the order of the bundle should follow the + * certificate chain, starting from the leaf certificate. + */ + public CertificateSignedRequest(String certificateChain) { + setCertificateChain(certificateChain); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CertificateSignedRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the signed PEM encoded X.509 certificate. This can also contain the necessary sub CA + * certificates. In that case, the order of the bundle should follow the certificate chain, + * starting from the leaf certificate. + * + * @return The signed PEM encoded X.509 certificate + */ + public String getCertificateChain() { + return certificateChain; + } + + /** + * Sets the signed PEM encoded X.509 certificate. This can also contain the necessary sub CA + * certificates. In that case, the order of the bundle should follow the certificate chain, + * starting from the leaf certificate. + * + * @param certificateChain The signed PEM encoded X.509 certificate + */ + public void setCertificateChain(String certificateChain) { + if (!isValidCertificateChain(certificateChain)) { + throw new PropertyConstraintException(certificateChain, "certificateChain is invalid"); + } + this.certificateChain = certificateChain; + } + + /** + * Returns whether the given certificateChain is valid + * + * @param certificateChain the certificateChain to check the validity of + * @return {@code true} if certificateChain is valid, {@code false} if not + */ + private boolean isValidCertificateChain(String certificateChain) { + return certificateChain != null && certificateChain.length() <= 10000; + } + + /** + * Gets the type of the signed certificate that is returned. When omitted the certificate is used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * This field is required when a typeOfCertificate was included in the SignCertificateRequest that + * requested this certificate to be signed AND both the 15118 connection and the Charging Station + * connection are implemented. + * + * @return The type of the signed certificate that is returned + */ + @Nullable + public CertificateSigningUseEnum getCertificateType() { + return certificateType; + } + + /** + * Sets the type of the signed certificate that is returned. When omitted the certificate is used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * This field is required when a typeOfCertificate was included in the SignCertificateRequest that + * requested this certificate to be signed AND both the 15118 connection and the Charging Station + * connection are implemented. + * + * @param certificateType The type of the signed certificate that is returned + */ + public void setCertificateType(@Nullable CertificateSigningUseEnum certificateType) { + this.certificateType = certificateType; + } + + /** + * Adds the type of the signed certificate that is returned. When omitted the certificate is used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * This field is required when a typeOfCertificate was included in the SignCertificateRequest that + * requested this certificate to be signed AND both the 15118 connection and the Charging Station + * connection are implemented. + * + * @param certificateType The type of the signed certificate that is returned + * @return this + */ + public CertificateSignedRequest withCertificateType( + @Nullable CertificateSigningUseEnum certificateType) { + setCertificateType(certificateType); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidCertificateChain(certificateChain); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CertificateSignedRequest that = (CertificateSignedRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(certificateChain, that.certificateChain) + && Objects.equals(certificateType, that.certificateType); + } + + @Override + public int hashCode() { + return Objects.hash(customData, certificateChain, certificateType); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("certificateChain", certificateChain) + .add("certificateType", certificateType) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CertificateSignedResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CertificateSignedResponse.java new file mode 100644 index 000000000..ac2a0c81c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CertificateSignedResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CertificateSignedStatusEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CertificateSignedResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class CertificateSignedResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Returns whether certificate signing has been accepted, otherwise rejected. */ + private CertificateSignedStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the CertificateSignedResponse class + * + * @param status Returns whether certificate signing has been accepted, otherwise rejected. + */ + public CertificateSignedResponse(CertificateSignedStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CertificateSignedResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets returns whether certificate signing has been accepted, otherwise rejected. + * + * @return Returns whether certificate signing has been accepted, otherwise rejected + */ + public CertificateSignedStatusEnum getStatus() { + return status; + } + + /** + * Sets returns whether certificate signing has been accepted, otherwise rejected. + * + * @param status Returns whether certificate signing has been accepted, otherwise rejected + */ + public void setStatus(CertificateSignedStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(CertificateSignedStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public CertificateSignedResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CertificateSignedResponse that = (CertificateSignedResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ChangeAvailabilityRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ChangeAvailabilityRequest.java new file mode 100644 index 000000000..c7fd303ab --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ChangeAvailabilityRequest.java @@ -0,0 +1,223 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.EVSE; +import eu.chargetime.ocpp.v201.model.types.OperationalStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ChangeAvailabilityRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class ChangeAvailabilityRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * EVSE + * + *

Electric Vehicle Supply Equipment + */ + @Nullable private EVSE evse; + + /** The type of availability change that the Charging Station should perform. */ + private OperationalStatusEnum operationalStatus; + + /** + * Constructor for the ChangeAvailabilityRequest class + * + * @param operationalStatus The type of availability change that the Charging Station should + * perform. + */ + public ChangeAvailabilityRequest(OperationalStatusEnum operationalStatus) { + setOperationalStatus(operationalStatus); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChangeAvailabilityRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets electric Vehicle Supply Equipment + * + * @return Electric Vehicle Supply Equipment + */ + @Nullable + public EVSE getEvse() { + return evse; + } + + /** + * Sets electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + */ + public void setEvse(@Nullable EVSE evse) { + if (!isValidEvse(evse)) { + throw new PropertyConstraintException(evse, "evse is invalid"); + } + this.evse = evse; + } + + /** + * Returns whether the given evse is valid + * + * @param evse the evse to check the validity of + * @return {@code true} if evse is valid, {@code false} if not + */ + private boolean isValidEvse(@Nullable EVSE evse) { + return evse == null || evse.validate(); + } + + /** + * Adds electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + * @return this + */ + public ChangeAvailabilityRequest withEvse(@Nullable EVSE evse) { + setEvse(evse); + return this; + } + + /** + * Gets the type of availability change that the Charging Station should perform. + * + * @return The type of availability change that the Charging Station should perform + */ + public OperationalStatusEnum getOperationalStatus() { + return operationalStatus; + } + + /** + * Sets the type of availability change that the Charging Station should perform. + * + * @param operationalStatus The type of availability change that the Charging Station should + * perform + */ + public void setOperationalStatus(OperationalStatusEnum operationalStatus) { + if (!isValidOperationalStatus(operationalStatus)) { + throw new PropertyConstraintException(operationalStatus, "operationalStatus is invalid"); + } + this.operationalStatus = operationalStatus; + } + + /** + * Returns whether the given operationalStatus is valid + * + * @param operationalStatus the operationalStatus to check the validity of + * @return {@code true} if operationalStatus is valid, {@code false} if not + */ + private boolean isValidOperationalStatus(OperationalStatusEnum operationalStatus) { + return operationalStatus != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidEvse(evse) + && isValidOperationalStatus(operationalStatus); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangeAvailabilityRequest that = (ChangeAvailabilityRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(evse, that.evse) + && Objects.equals(operationalStatus, that.operationalStatus); + } + + @Override + public int hashCode() { + return Objects.hash(customData, evse, operationalStatus); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("evse", evse) + .add("operationalStatus", operationalStatus) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ChangeAvailabilityResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ChangeAvailabilityResponse.java new file mode 100644 index 000000000..68b5a1eda --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ChangeAvailabilityResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ChangeAvailabilityStatusEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ChangeAvailabilityResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class ChangeAvailabilityResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the Charging Station is able to perform the availability change. */ + private ChangeAvailabilityStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the ChangeAvailabilityResponse class + * + * @param status Whether the Charging Station is able to perform the availability change. + */ + public ChangeAvailabilityResponse(ChangeAvailabilityStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChangeAvailabilityResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station is able to perform the availability change. + * + * @return Whether the Charging Station is able to perform the availability change + */ + public ChangeAvailabilityStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station is able to perform the availability change. + * + * @param status Whether the Charging Station is able to perform the availability change + */ + public void setStatus(ChangeAvailabilityStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ChangeAvailabilityStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ChangeAvailabilityResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangeAvailabilityResponse that = (ChangeAvailabilityResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearCacheRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearCacheRequest.java new file mode 100644 index 000000000..12e447783 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearCacheRequest.java @@ -0,0 +1,123 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearCacheRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class ClearCacheRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ClearCacheRequest class */ + public ClearCacheRequest() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearCacheRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearCacheRequest that = (ClearCacheRequest) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearCacheResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearCacheResponse.java new file mode 100644 index 000000000..c081b7496 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearCacheResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ClearCacheStatusEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearCacheResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class ClearCacheResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Accepted if the Charging Station has executed the request, otherwise rejected. */ + private ClearCacheStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the ClearCacheResponse class + * + * @param status Accepted if the Charging Station has executed the request, otherwise rejected. + */ + public ClearCacheResponse(ClearCacheStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearCacheResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets accepted if the Charging Station has executed the request, otherwise rejected. + * + * @return Accepted if the Charging Station has executed the request, otherwise rejected + */ + public ClearCacheStatusEnum getStatus() { + return status; + } + + /** + * Sets accepted if the Charging Station has executed the request, otherwise rejected. + * + * @param status Accepted if the Charging Station has executed the request, otherwise rejected + */ + public void setStatus(ClearCacheStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ClearCacheStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ClearCacheResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearCacheResponse that = (ClearCacheResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearChargingProfileRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearChargingProfileRequest.java new file mode 100644 index 000000000..84c1a55bd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearChargingProfileRequest.java @@ -0,0 +1,221 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ClearChargingProfile; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearChargingProfileRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class ClearChargingProfileRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The Id of the charging profile to clear. */ + @Nullable private Integer chargingProfileId; + + /** + * Charging Profile + * + *

A ChargingProfile consists of a ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + */ + @Nullable private ClearChargingProfile chargingProfileCriteria; + + /** Constructor for the ClearChargingProfileRequest class */ + public ClearChargingProfileRequest() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearChargingProfileRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the Id of the charging profile to clear. + * + * @return The Id of the charging profile to clear + */ + @Nullable + public Integer getChargingProfileId() { + return chargingProfileId; + } + + /** + * Sets the Id of the charging profile to clear. + * + * @param chargingProfileId The Id of the charging profile to clear + */ + public void setChargingProfileId(@Nullable Integer chargingProfileId) { + this.chargingProfileId = chargingProfileId; + } + + /** + * Adds the Id of the charging profile to clear. + * + * @param chargingProfileId The Id of the charging profile to clear + * @return this + */ + public ClearChargingProfileRequest withChargingProfileId(@Nullable Integer chargingProfileId) { + setChargingProfileId(chargingProfileId); + return this; + } + + /** + * Gets a ChargingProfile consists of a ChargingSchedule, describing the amount of power or + * current that can be delivered per time interval. + * + * @return A ChargingProfile consists of a ChargingSchedule, describing the amount of power or + * current that can be delivered per time interval + */ + @Nullable + public ClearChargingProfile getChargingProfileCriteria() { + return chargingProfileCriteria; + } + + /** + * Sets a ChargingProfile consists of a ChargingSchedule, describing the amount of power or + * current that can be delivered per time interval. + * + * @param chargingProfileCriteria A ChargingProfile consists of a ChargingSchedule, describing the + * amount of power or current that can be delivered per time interval + */ + public void setChargingProfileCriteria(@Nullable ClearChargingProfile chargingProfileCriteria) { + if (!isValidChargingProfileCriteria(chargingProfileCriteria)) { + throw new PropertyConstraintException( + chargingProfileCriteria, "chargingProfileCriteria is invalid"); + } + this.chargingProfileCriteria = chargingProfileCriteria; + } + + /** + * Returns whether the given chargingProfileCriteria is valid + * + * @param chargingProfileCriteria the chargingProfileCriteria to check the validity of + * @return {@code true} if chargingProfileCriteria is valid, {@code false} if not + */ + private boolean isValidChargingProfileCriteria( + @Nullable ClearChargingProfile chargingProfileCriteria) { + return chargingProfileCriteria == null || chargingProfileCriteria.validate(); + } + + /** + * Adds a ChargingProfile consists of a ChargingSchedule, describing the amount of power or + * current that can be delivered per time interval. + * + * @param chargingProfileCriteria A ChargingProfile consists of a ChargingSchedule, describing the + * amount of power or current that can be delivered per time interval + * @return this + */ + public ClearChargingProfileRequest withChargingProfileCriteria( + @Nullable ClearChargingProfile chargingProfileCriteria) { + setChargingProfileCriteria(chargingProfileCriteria); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidChargingProfileCriteria(chargingProfileCriteria); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearChargingProfileRequest that = (ClearChargingProfileRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(chargingProfileId, that.chargingProfileId) + && Objects.equals(chargingProfileCriteria, that.chargingProfileCriteria); + } + + @Override + public int hashCode() { + return Objects.hash(customData, chargingProfileId, chargingProfileCriteria); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("chargingProfileId", chargingProfileId) + .add("chargingProfileCriteria", chargingProfileCriteria) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearChargingProfileResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearChargingProfileResponse.java new file mode 100644 index 000000000..4c4071c2e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearChargingProfileResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ClearChargingProfileStatusEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearChargingProfileResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class ClearChargingProfileResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the Charging Station was able to execute the request. */ + private ClearChargingProfileStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the ClearChargingProfileResponse class + * + * @param status Whether the Charging Station was able to execute the request. + */ + public ClearChargingProfileResponse(ClearChargingProfileStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearChargingProfileResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station was able to execute the request. + * + * @return Whether the Charging Station was able to execute the request + */ + public ClearChargingProfileStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station was able to execute the request. + * + * @param status Whether the Charging Station was able to execute the request + */ + public void setStatus(ClearChargingProfileStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ClearChargingProfileStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ClearChargingProfileResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearChargingProfileResponse that = (ClearChargingProfileResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearDisplayMessageRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearDisplayMessageRequest.java new file mode 100644 index 000000000..24be20acf --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearDisplayMessageRequest.java @@ -0,0 +1,164 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearDisplayMessageRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class ClearDisplayMessageRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Id of the message that SHALL be removed from the Charging Station. */ + private Integer id; + + /** + * Constructor for the ClearDisplayMessageRequest class + * + * @param id Id of the message that SHALL be removed from the Charging Station. + */ + public ClearDisplayMessageRequest(Integer id) { + setId(id); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearDisplayMessageRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets id of the message that SHALL be removed from the Charging Station. + * + * @return Id of the message that SHALL be removed from the Charging Station + */ + public Integer getId() { + return id; + } + + /** + * Sets id of the message that SHALL be removed from the Charging Station. + * + * @param id Id of the message that SHALL be removed from the Charging Station + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidId(id); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearDisplayMessageRequest that = (ClearDisplayMessageRequest) o; + return Objects.equals(customData, that.customData) && Objects.equals(id, that.id); + } + + @Override + public int hashCode() { + return Objects.hash(customData, id); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("id", id) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearDisplayMessageResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearDisplayMessageResponse.java new file mode 100644 index 000000000..e834fee67 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearDisplayMessageResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ClearMessageStatusEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearDisplayMessageResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class ClearDisplayMessageResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Returns whether the Charging Station has been able to remove the message. */ + private ClearMessageStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the ClearDisplayMessageResponse class + * + * @param status Returns whether the Charging Station has been able to remove the message. + */ + public ClearDisplayMessageResponse(ClearMessageStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearDisplayMessageResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets returns whether the Charging Station has been able to remove the message. + * + * @return Returns whether the Charging Station has been able to remove the message + */ + public ClearMessageStatusEnum getStatus() { + return status; + } + + /** + * Sets returns whether the Charging Station has been able to remove the message. + * + * @param status Returns whether the Charging Station has been able to remove the message + */ + public void setStatus(ClearMessageStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ClearMessageStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ClearDisplayMessageResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearDisplayMessageResponse that = (ClearDisplayMessageResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearVariableMonitoringRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearVariableMonitoringRequest.java new file mode 100644 index 000000000..a931548a6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearVariableMonitoringRequest.java @@ -0,0 +1,165 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearVariableMonitoringRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class ClearVariableMonitoringRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** List of the monitors to be cleared, identified by there Id. */ + private Integer[] id; + + /** + * Constructor for the ClearVariableMonitoringRequest class + * + * @param id List of the monitors to be cleared, identified by there Id. + */ + public ClearVariableMonitoringRequest(Integer[] id) { + setId(id); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearVariableMonitoringRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets list of the monitors to be cleared, identified by there Id. + * + * @return List of the monitors to be cleared, identified by there Id + */ + public Integer[] getId() { + return id; + } + + /** + * Sets list of the monitors to be cleared, identified by there Id. + * + * @param id List of the monitors to be cleared, identified by there Id + */ + public void setId(Integer[] id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer[] id) { + return id != null && id.length >= 1; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidId(id); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearVariableMonitoringRequest that = (ClearVariableMonitoringRequest) o; + return Objects.equals(customData, that.customData) && Arrays.equals(id, that.id); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(id)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("id", id) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearVariableMonitoringResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearVariableMonitoringResponse.java new file mode 100644 index 000000000..e3beb324f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearVariableMonitoringResponse.java @@ -0,0 +1,165 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ClearMonitoringResult; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearVariableMonitoringResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class ClearVariableMonitoringResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** clearMonitoringResult */ + private ClearMonitoringResult[] clearMonitoringResult; + + /** + * Constructor for the ClearVariableMonitoringResponse class + * + * @param clearMonitoringResult clearMonitoringResult + */ + public ClearVariableMonitoringResponse(ClearMonitoringResult[] clearMonitoringResult) { + setClearMonitoringResult(clearMonitoringResult); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearVariableMonitoringResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets clearMonitoringResult + * + * @return clearMonitoringResult + */ + public ClearMonitoringResult[] getClearMonitoringResult() { + return clearMonitoringResult; + } + + /** + * Sets clearMonitoringResult + * + * @param clearMonitoringResult clearMonitoringResult + */ + public void setClearMonitoringResult(ClearMonitoringResult[] clearMonitoringResult) { + if (!isValidClearMonitoringResult(clearMonitoringResult)) { + throw new PropertyConstraintException( + clearMonitoringResult, "clearMonitoringResult is invalid"); + } + this.clearMonitoringResult = clearMonitoringResult; + } + + /** + * Returns whether the given clearMonitoringResult is valid + * + * @param clearMonitoringResult the clearMonitoringResult to check the validity of + * @return {@code true} if clearMonitoringResult is valid, {@code false} if not + */ + private boolean isValidClearMonitoringResult(ClearMonitoringResult[] clearMonitoringResult) { + return clearMonitoringResult != null + && clearMonitoringResult.length >= 1 + && Arrays.stream(clearMonitoringResult).allMatch(item -> item.validate()); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidClearMonitoringResult(clearMonitoringResult); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearVariableMonitoringResponse that = (ClearVariableMonitoringResponse) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(clearMonitoringResult, that.clearMonitoringResult); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(clearMonitoringResult)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("clearMonitoringResult", clearMonitoringResult) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearedChargingLimitRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearedChargingLimitRequest.java new file mode 100644 index 000000000..0b54af960 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearedChargingLimitRequest.java @@ -0,0 +1,201 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ChargingLimitSourceEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearedChargingLimitRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class ClearedChargingLimitRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Source of the charging limit. */ + private ChargingLimitSourceEnum chargingLimitSource; + + /** EVSE Identifier. */ + @Nullable private Integer evseId; + + /** + * Constructor for the ClearedChargingLimitRequest class + * + * @param chargingLimitSource Source of the charging limit. + */ + public ClearedChargingLimitRequest(ChargingLimitSourceEnum chargingLimitSource) { + setChargingLimitSource(chargingLimitSource); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearedChargingLimitRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets source of the charging limit. + * + * @return Source of the charging limit + */ + public ChargingLimitSourceEnum getChargingLimitSource() { + return chargingLimitSource; + } + + /** + * Sets source of the charging limit. + * + * @param chargingLimitSource Source of the charging limit + */ + public void setChargingLimitSource(ChargingLimitSourceEnum chargingLimitSource) { + if (!isValidChargingLimitSource(chargingLimitSource)) { + throw new PropertyConstraintException(chargingLimitSource, "chargingLimitSource is invalid"); + } + this.chargingLimitSource = chargingLimitSource; + } + + /** + * Returns whether the given chargingLimitSource is valid + * + * @param chargingLimitSource the chargingLimitSource to check the validity of + * @return {@code true} if chargingLimitSource is valid, {@code false} if not + */ + private boolean isValidChargingLimitSource(ChargingLimitSourceEnum chargingLimitSource) { + return chargingLimitSource != null; + } + + /** + * Gets EVSE Identifier. + * + * @return EVSE Identifier + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets EVSE Identifier. + * + * @param evseId EVSE Identifier + */ + public void setEvseId(@Nullable Integer evseId) { + this.evseId = evseId; + } + + /** + * Adds EVSE Identifier. + * + * @param evseId EVSE Identifier + * @return this + */ + public ClearedChargingLimitRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidChargingLimitSource(chargingLimitSource); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearedChargingLimitRequest that = (ClearedChargingLimitRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(chargingLimitSource, that.chargingLimitSource) + && Objects.equals(evseId, that.evseId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, chargingLimitSource, evseId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("chargingLimitSource", chargingLimitSource) + .add("evseId", evseId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearedChargingLimitResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearedChargingLimitResponse.java new file mode 100644 index 000000000..3f41b650f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ClearedChargingLimitResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ClearedChargingLimitResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class ClearedChargingLimitResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ClearedChargingLimitResponse class */ + public ClearedChargingLimitResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearedChargingLimitResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearedChargingLimitResponse that = (ClearedChargingLimitResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CostUpdatedRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CostUpdatedRequest.java new file mode 100644 index 000000000..33a882c69 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CostUpdatedRequest.java @@ -0,0 +1,214 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CostUpdatedRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class CostUpdatedRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Current total cost, based on the information known by the CSMS, of the transaction including + * taxes. In the currency configured with the configuration Variable: [Currency] + */ + private Double totalCost; + + /** Transaction Id of the transaction the current cost are asked for. */ + private String transactionId; + + /** + * Constructor for the CostUpdatedRequest class + * + * @param totalCost Current total cost, based on the information known by the CSMS, of the + * transaction including taxes. In the currency configured with the configuration Variable: + * [Currency] + * @param transactionId Transaction Id of the transaction the current cost are asked for. + */ + public CostUpdatedRequest(Double totalCost, String transactionId) { + setTotalCost(totalCost); + setTransactionId(transactionId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CostUpdatedRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets current total cost, based on the information known by the CSMS, of the transaction + * including taxes. In the currency configured with the configuration Variable: [Currency] + * + * @return Current total cost, based on the information known by the CSMS, of the transaction + * including taxes + */ + public Double getTotalCost() { + return totalCost; + } + + /** + * Sets current total cost, based on the information known by the CSMS, of the transaction + * including taxes. In the currency configured with the configuration Variable: [Currency] + * + * @param totalCost Current total cost, based on the information known by the CSMS, of the + * transaction including taxes + */ + public void setTotalCost(Double totalCost) { + if (!isValidTotalCost(totalCost)) { + throw new PropertyConstraintException(totalCost, "totalCost is invalid"); + } + this.totalCost = totalCost; + } + + /** + * Returns whether the given totalCost is valid + * + * @param totalCost the totalCost to check the validity of + * @return {@code true} if totalCost is valid, {@code false} if not + */ + private boolean isValidTotalCost(Double totalCost) { + return totalCost != null; + } + + /** + * Gets transaction Id of the transaction the current cost are asked for. + * + * @return Transaction Id of the transaction the current cost are asked for + */ + public String getTransactionId() { + return transactionId; + } + + /** + * Sets transaction Id of the transaction the current cost are asked for. + * + * @param transactionId Transaction Id of the transaction the current cost are asked for + */ + public void setTransactionId(String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(String transactionId) { + return transactionId != null && transactionId.length() <= 36; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidTotalCost(totalCost) + && isValidTransactionId(transactionId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CostUpdatedRequest that = (CostUpdatedRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(totalCost, that.totalCost) + && Objects.equals(transactionId, that.transactionId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, totalCost, transactionId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("totalCost", totalCost) + .add("transactionId", transactionId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CostUpdatedResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CostUpdatedResponse.java new file mode 100644 index 000000000..70a5c633e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CostUpdatedResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CostUpdatedResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class CostUpdatedResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the CostUpdatedResponse class */ + public CostUpdatedResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CostUpdatedResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CostUpdatedResponse that = (CostUpdatedResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CustomerInformationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CustomerInformationRequest.java new file mode 100644 index 000000000..80234ecca --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CustomerInformationRequest.java @@ -0,0 +1,440 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CertificateHashData; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.IdToken; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CustomerInformationRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class CustomerInformationRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** customerCertificate */ + @Nullable private CertificateHashData customerCertificate; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private IdToken idToken; + + /** The Id of the request. */ + private Integer requestId; + + /** + * Flag indicating whether the Charging Station should return NotifyCustomerInformationRequest + * messages containing information about the customer referred to. + */ + private Boolean report; + + /** + * Flag indicating whether the Charging Station should clear all information about the customer + * referred to. + */ + private Boolean clear; + + /** + * A (e.g. vendor specific) identifier of the customer this request refers to. This field contains + * a custom identifier other than IdToken and Certificate. One of the possible identifiers + * (customerIdentifier, customerIdToken or customerCertificate) should be in the request message. + */ + @Nullable private String customerIdentifier; + + /** + * Constructor for the CustomerInformationRequest class + * + * @param requestId The Id of the request. + * @param report Flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer + * referred to. + * @param clear Flag indicating whether the Charging Station should clear all information about + * the customer referred to. + */ + public CustomerInformationRequest(Integer requestId, Boolean report, Boolean clear) { + setRequestId(requestId); + setReport(report); + setClear(clear); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CustomerInformationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets customerCertificate + * + * @return customerCertificate + */ + @Nullable + public CertificateHashData getCustomerCertificate() { + return customerCertificate; + } + + /** + * Sets customerCertificate + * + * @param customerCertificate customerCertificate + */ + public void setCustomerCertificate(@Nullable CertificateHashData customerCertificate) { + if (!isValidCustomerCertificate(customerCertificate)) { + throw new PropertyConstraintException(customerCertificate, "customerCertificate is invalid"); + } + this.customerCertificate = customerCertificate; + } + + /** + * Returns whether the given customerCertificate is valid + * + * @param customerCertificate the customerCertificate to check the validity of + * @return {@code true} if customerCertificate is valid, {@code false} if not + */ + private boolean isValidCustomerCertificate(@Nullable CertificateHashData customerCertificate) { + return customerCertificate == null || customerCertificate.validate(); + } + + /** + * Adds customerCertificate + * + * @param customerCertificate customerCertificate + * @return this + */ + public CustomerInformationRequest withCustomerCertificate( + @Nullable CertificateHashData customerCertificate) { + setCustomerCertificate(customerCertificate); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(@Nullable IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(@Nullable IdToken idToken) { + return idToken == null || idToken.validate(); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + * @return this + */ + public CustomerInformationRequest withIdToken(@Nullable IdToken idToken) { + setIdToken(idToken); + return this; + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer referred + * to. + * + * @return Flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer + * referred to + */ + public Boolean getReport() { + return report; + } + + /** + * Sets flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer referred + * to. + * + * @param report Flag indicating whether the Charging Station should return + * NotifyCustomerInformationRequest messages containing information about the customer + * referred to + */ + public void setReport(Boolean report) { + if (!isValidReport(report)) { + throw new PropertyConstraintException(report, "report is invalid"); + } + this.report = report; + } + + /** + * Returns whether the given report is valid + * + * @param report the report to check the validity of + * @return {@code true} if report is valid, {@code false} if not + */ + private boolean isValidReport(Boolean report) { + return report != null; + } + + /** + * Gets flag indicating whether the Charging Station should clear all information about the + * customer referred to. + * + * @return Flag indicating whether the Charging Station should clear all information about the + * customer referred to + */ + public Boolean getClear() { + return clear; + } + + /** + * Sets flag indicating whether the Charging Station should clear all information about the + * customer referred to. + * + * @param clear Flag indicating whether the Charging Station should clear all information about + * the customer referred to + */ + public void setClear(Boolean clear) { + if (!isValidClear(clear)) { + throw new PropertyConstraintException(clear, "clear is invalid"); + } + this.clear = clear; + } + + /** + * Returns whether the given clear is valid + * + * @param clear the clear to check the validity of + * @return {@code true} if clear is valid, {@code false} if not + */ + private boolean isValidClear(Boolean clear) { + return clear != null; + } + + /** + * Gets a (e.g. vendor specific) identifier of the customer this request refers to. This field + * contains a custom identifier other than IdToken and Certificate. One of the possible + * identifiers (customerIdentifier, customerIdToken or customerCertificate) should be in the + * request message. + * + * @return A (e.g. vendor specific) identifier of the customer this request refers to + */ + @Nullable + public String getCustomerIdentifier() { + return customerIdentifier; + } + + /** + * Sets a (e.g. vendor specific) identifier of the customer this request refers to. This field + * contains a custom identifier other than IdToken and Certificate. One of the possible + * identifiers (customerIdentifier, customerIdToken or customerCertificate) should be in the + * request message. + * + * @param customerIdentifier A (e.g. vendor specific) identifier of the customer this request + * refers to + */ + public void setCustomerIdentifier(@Nullable String customerIdentifier) { + if (!isValidCustomerIdentifier(customerIdentifier)) { + throw new PropertyConstraintException(customerIdentifier, "customerIdentifier is invalid"); + } + this.customerIdentifier = customerIdentifier; + } + + /** + * Returns whether the given customerIdentifier is valid + * + * @param customerIdentifier the customerIdentifier to check the validity of + * @return {@code true} if customerIdentifier is valid, {@code false} if not + */ + private boolean isValidCustomerIdentifier(@Nullable String customerIdentifier) { + return customerIdentifier == null || customerIdentifier.length() <= 64; + } + + /** + * Adds a (e.g. vendor specific) identifier of the customer this request refers to. This field + * contains a custom identifier other than IdToken and Certificate. One of the possible + * identifiers (customerIdentifier, customerIdToken or customerCertificate) should be in the + * request message. + * + * @param customerIdentifier A (e.g. vendor specific) identifier of the customer this request + * refers to + * @return this + */ + public CustomerInformationRequest withCustomerIdentifier(@Nullable String customerIdentifier) { + setCustomerIdentifier(customerIdentifier); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidCustomerCertificate(customerCertificate) + && isValidIdToken(idToken) + && isValidRequestId(requestId) + && isValidReport(report) + && isValidClear(clear) + && isValidCustomerIdentifier(customerIdentifier); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomerInformationRequest that = (CustomerInformationRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(customerCertificate, that.customerCertificate) + && Objects.equals(idToken, that.idToken) + && Objects.equals(requestId, that.requestId) + && Objects.equals(report, that.report) + && Objects.equals(clear, that.clear) + && Objects.equals(customerIdentifier, that.customerIdentifier); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, customerCertificate, idToken, requestId, report, clear, customerIdentifier); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("customerCertificate", customerCertificate) + .add("idToken", idToken) + .add("requestId", requestId) + .add("report", report) + .add("clear", clear) + .add("customerIdentifier", customerIdentifier) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CustomerInformationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CustomerInformationResponse.java new file mode 100644 index 000000000..ecf941126 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/CustomerInformationResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.CustomerInformationStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * CustomerInformationResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class CustomerInformationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the request was accepted. */ + private CustomerInformationStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the CustomerInformationResponse class + * + * @param status Whether the request was accepted. + */ + public CustomerInformationResponse(CustomerInformationStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CustomerInformationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the request was accepted. + * + * @return Whether the request was accepted + */ + public CustomerInformationStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the request was accepted. + * + * @param status Whether the request was accepted + */ + public void setStatus(CustomerInformationStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(CustomerInformationStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public CustomerInformationResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomerInformationResponse that = (CustomerInformationResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DataTransferRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DataTransferRequest.java new file mode 100644 index 000000000..ebd1c78f4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DataTransferRequest.java @@ -0,0 +1,256 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * DataTransferRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class DataTransferRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** May be used to indicate a specific message or implementation. */ + @Nullable private String messageId; + + /** + * Data without specified length or format. This needs to be decided by both parties (Open to + * implementation). + */ + @Nullable private Object data; + + /** The identifier of the Vendor specific implementation */ + private String vendorId; + + /** + * Constructor for the DataTransferRequest class + * + * @param vendorId The identifier of the Vendor specific implementation + */ + public DataTransferRequest(String vendorId) { + setVendorId(vendorId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DataTransferRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets may be used to indicate a specific message or implementation. + * + * @return May be used to indicate a specific message or implementation + */ + @Nullable + public String getMessageId() { + return messageId; + } + + /** + * Sets may be used to indicate a specific message or implementation. + * + * @param messageId May be used to indicate a specific message or implementation + */ + public void setMessageId(@Nullable String messageId) { + if (!isValidMessageId(messageId)) { + throw new PropertyConstraintException(messageId, "messageId is invalid"); + } + this.messageId = messageId; + } + + /** + * Returns whether the given messageId is valid + * + * @param messageId the messageId to check the validity of + * @return {@code true} if messageId is valid, {@code false} if not + */ + private boolean isValidMessageId(@Nullable String messageId) { + return messageId == null || messageId.length() <= 50; + } + + /** + * Adds may be used to indicate a specific message or implementation. + * + * @param messageId May be used to indicate a specific message or implementation + * @return this + */ + public DataTransferRequest withMessageId(@Nullable String messageId) { + setMessageId(messageId); + return this; + } + + /** + * Gets data without specified length or format. This needs to be decided by both parties (Open to + * implementation). + * + * @return Data without specified length or format + */ + @Nullable + public Object getData() { + return data; + } + + /** + * Sets data without specified length or format. This needs to be decided by both parties (Open to + * implementation). + * + * @param data Data without specified length or format + */ + public void setData(@Nullable Object data) { + this.data = data; + } + + /** + * Adds data without specified length or format. This needs to be decided by both parties (Open to + * implementation). + * + * @param data Data without specified length or format + * @return this + */ + public DataTransferRequest withData(@Nullable Object data) { + setData(data); + return this; + } + + /** + * Gets the identifier of the Vendor specific implementation + * + * @return The identifier of the Vendor specific implementation + */ + public String getVendorId() { + return vendorId; + } + + /** + * Sets the identifier of the Vendor specific implementation + * + * @param vendorId The identifier of the Vendor specific implementation + */ + public void setVendorId(String vendorId) { + if (!isValidVendorId(vendorId)) { + throw new PropertyConstraintException(vendorId, "vendorId is invalid"); + } + this.vendorId = vendorId; + } + + /** + * Returns whether the given vendorId is valid + * + * @param vendorId the vendorId to check the validity of + * @return {@code true} if vendorId is valid, {@code false} if not + */ + private boolean isValidVendorId(String vendorId) { + return vendorId != null && vendorId.length() <= 255; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidMessageId(messageId) + && isValidVendorId(vendorId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataTransferRequest that = (DataTransferRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(messageId, that.messageId) + && Objects.equals(data, that.data) + && Objects.equals(vendorId, that.vendorId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, messageId, data, vendorId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("messageId", messageId) + .add("data", data) + .add("vendorId", vendorId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DataTransferResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DataTransferResponse.java new file mode 100644 index 000000000..ad7a7b43f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DataTransferResponse.java @@ -0,0 +1,245 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.DataTransferStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * DataTransferResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class DataTransferResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** The success or failure of the data transfer. */ + private DataTransferStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Data without specified length or format, in response to request. */ + @Nullable private Object data; + + /** + * Constructor for the DataTransferResponse class + * + * @param status The success or failure of the data transfer. + */ + public DataTransferResponse(DataTransferStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DataTransferResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the success or failure of the data transfer. + * + * @return The success or failure of the data transfer + */ + public DataTransferStatusEnum getStatus() { + return status; + } + + /** + * Sets the success or failure of the data transfer. + * + * @param status The success or failure of the data transfer + */ + public void setStatus(DataTransferStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(DataTransferStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public DataTransferResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets data without specified length or format, in response to request. + * + * @return Data without specified length or format, in response to request + */ + @Nullable + public Object getData() { + return data; + } + + /** + * Sets data without specified length or format, in response to request. + * + * @param data Data without specified length or format, in response to request + */ + public void setData(@Nullable Object data) { + this.data = data; + } + + /** + * Adds data without specified length or format, in response to request. + * + * @param data Data without specified length or format, in response to request + * @return this + */ + public DataTransferResponse withData(@Nullable Object data) { + setData(data); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataTransferResponse that = (DataTransferResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(data, that.data); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo, data); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("data", data) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DeleteCertificateRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DeleteCertificateRequest.java new file mode 100644 index 000000000..957085fb0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DeleteCertificateRequest.java @@ -0,0 +1,166 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CertificateHashData; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * DeleteCertificateRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class DeleteCertificateRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** certificateHashData */ + private CertificateHashData certificateHashData; + + /** + * Constructor for the DeleteCertificateRequest class + * + * @param certificateHashData certificateHashData + */ + public DeleteCertificateRequest(CertificateHashData certificateHashData) { + setCertificateHashData(certificateHashData); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DeleteCertificateRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets certificateHashData + * + * @return certificateHashData + */ + public CertificateHashData getCertificateHashData() { + return certificateHashData; + } + + /** + * Sets certificateHashData + * + * @param certificateHashData certificateHashData + */ + public void setCertificateHashData(CertificateHashData certificateHashData) { + if (!isValidCertificateHashData(certificateHashData)) { + throw new PropertyConstraintException(certificateHashData, "certificateHashData is invalid"); + } + this.certificateHashData = certificateHashData; + } + + /** + * Returns whether the given certificateHashData is valid + * + * @param certificateHashData the certificateHashData to check the validity of + * @return {@code true} if certificateHashData is valid, {@code false} if not + */ + private boolean isValidCertificateHashData(CertificateHashData certificateHashData) { + return certificateHashData != null && certificateHashData.validate(); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidCertificateHashData(certificateHashData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteCertificateRequest that = (DeleteCertificateRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(certificateHashData, that.certificateHashData); + } + + @Override + public int hashCode() { + return Objects.hash(customData, certificateHashData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("certificateHashData", certificateHashData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DeleteCertificateResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DeleteCertificateResponse.java new file mode 100644 index 000000000..64e357d79 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/DeleteCertificateResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.DeleteCertificateStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * DeleteCertificateResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class DeleteCertificateResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Charging Station indicates if it can process the request. */ + private DeleteCertificateStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the DeleteCertificateResponse class + * + * @param status Charging Station indicates if it can process the request. + */ + public DeleteCertificateResponse(DeleteCertificateStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DeleteCertificateResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets charging Station indicates if it can process the request. + * + * @return Charging Station indicates if it can process the request + */ + public DeleteCertificateStatusEnum getStatus() { + return status; + } + + /** + * Sets charging Station indicates if it can process the request. + * + * @param status Charging Station indicates if it can process the request + */ + public void setStatus(DeleteCertificateStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(DeleteCertificateStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public DeleteCertificateResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteCertificateResponse that = (DeleteCertificateResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/FirmwareStatusNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/FirmwareStatusNotificationRequest.java new file mode 100644 index 000000000..236285da6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/FirmwareStatusNotificationRequest.java @@ -0,0 +1,214 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.FirmwareStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * FirmwareStatusNotificationRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class FirmwareStatusNotificationRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The progress status of the firmware installation. */ + private FirmwareStatusEnum status; + + /** + * The request id that was provided in the UpdateFirmwareRequest that started this firmware + * update. This field is mandatory, unless the message was triggered by a TriggerMessageRequest + * AND there is no firmware update ongoing. + */ + @Nullable private Integer requestId; + + /** + * Constructor for the FirmwareStatusNotificationRequest class + * + * @param status The progress status of the firmware installation. + */ + public FirmwareStatusNotificationRequest(FirmwareStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public FirmwareStatusNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the progress status of the firmware installation. + * + * @return The progress status of the firmware installation + */ + public FirmwareStatusEnum getStatus() { + return status; + } + + /** + * Sets the progress status of the firmware installation. + * + * @param status The progress status of the firmware installation + */ + public void setStatus(FirmwareStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(FirmwareStatusEnum status) { + return status != null; + } + + /** + * Gets the request id that was provided in the UpdateFirmwareRequest that started this firmware + * update. This field is mandatory, unless the message was triggered by a TriggerMessageRequest + * AND there is no firmware update ongoing. + * + * @return The request id that was provided in the UpdateFirmwareRequest that started this + * firmware update + */ + @Nullable + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the request id that was provided in the UpdateFirmwareRequest that started this firmware + * update. This field is mandatory, unless the message was triggered by a TriggerMessageRequest + * AND there is no firmware update ongoing. + * + * @param requestId The request id that was provided in the UpdateFirmwareRequest that started + * this firmware update + */ + public void setRequestId(@Nullable Integer requestId) { + this.requestId = requestId; + } + + /** + * Adds the request id that was provided in the UpdateFirmwareRequest that started this firmware + * update. This field is mandatory, unless the message was triggered by a TriggerMessageRequest + * AND there is no firmware update ongoing. + * + * @param requestId The request id that was provided in the UpdateFirmwareRequest that started + * this firmware update + * @return this + */ + public FirmwareStatusNotificationRequest withRequestId(@Nullable Integer requestId) { + setRequestId(requestId); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FirmwareStatusNotificationRequest that = (FirmwareStatusNotificationRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(requestId, that.requestId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, requestId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("requestId", requestId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/FirmwareStatusNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/FirmwareStatusNotificationResponse.java new file mode 100644 index 000000000..91867cbbc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/FirmwareStatusNotificationResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * FirmwareStatusNotificationResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class FirmwareStatusNotificationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the FirmwareStatusNotificationResponse class */ + public FirmwareStatusNotificationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public FirmwareStatusNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FirmwareStatusNotificationResponse that = (FirmwareStatusNotificationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/Get15118EVCertificateRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/Get15118EVCertificateRequest.java new file mode 100644 index 000000000..10e0e9c25 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/Get15118EVCertificateRequest.java @@ -0,0 +1,254 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CertificateActionEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Get15118EVCertificateRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class Get15118EVCertificateRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Schema version currently used for the 15118 session between EV and Charging Station. Needed for + * parsing of the EXI stream by the CSMS. + */ + private String iso15118SchemaVersion; + + /** Whether certificate needs to be installed or updated. */ + private CertificateActionEnum action; + + /** Raw CertificateInstallationReq request from EV, Base64 encoded. */ + private String exiRequest; + + /** + * Constructor for the Get15118EVCertificateRequest class + * + * @param iso15118SchemaVersion Schema version currently used for the 15118 session between EV and + * Charging Station. Needed for parsing of the EXI stream by the CSMS. + * @param action Whether certificate needs to be installed or updated. + * @param exiRequest Raw CertificateInstallationReq request from EV, Base64 encoded. + */ + public Get15118EVCertificateRequest( + String iso15118SchemaVersion, CertificateActionEnum action, String exiRequest) { + setIso15118SchemaVersion(iso15118SchemaVersion); + setAction(action); + setExiRequest(exiRequest); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Get15118EVCertificateRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets schema version currently used for the 15118 session between EV and Charging Station. + * Needed for parsing of the EXI stream by the CSMS. + * + * @return Schema version currently used for the 15118 session between EV and Charging Station + */ + public String getIso15118SchemaVersion() { + return iso15118SchemaVersion; + } + + /** + * Sets schema version currently used for the 15118 session between EV and Charging Station. + * Needed for parsing of the EXI stream by the CSMS. + * + * @param iso15118SchemaVersion Schema version currently used for the 15118 session between EV and + * Charging Station + */ + public void setIso15118SchemaVersion(String iso15118SchemaVersion) { + if (!isValidIso15118SchemaVersion(iso15118SchemaVersion)) { + throw new PropertyConstraintException( + iso15118SchemaVersion, "iso15118SchemaVersion is invalid"); + } + this.iso15118SchemaVersion = iso15118SchemaVersion; + } + + /** + * Returns whether the given iso15118SchemaVersion is valid + * + * @param iso15118SchemaVersion the iso15118SchemaVersion to check the validity of + * @return {@code true} if iso15118SchemaVersion is valid, {@code false} if not + */ + private boolean isValidIso15118SchemaVersion(String iso15118SchemaVersion) { + return iso15118SchemaVersion != null && iso15118SchemaVersion.length() <= 50; + } + + /** + * Gets whether certificate needs to be installed or updated. + * + * @return Whether certificate needs to be installed or updated + */ + public CertificateActionEnum getAction() { + return action; + } + + /** + * Sets whether certificate needs to be installed or updated. + * + * @param action Whether certificate needs to be installed or updated + */ + public void setAction(CertificateActionEnum action) { + if (!isValidAction(action)) { + throw new PropertyConstraintException(action, "action is invalid"); + } + this.action = action; + } + + /** + * Returns whether the given action is valid + * + * @param action the action to check the validity of + * @return {@code true} if action is valid, {@code false} if not + */ + private boolean isValidAction(CertificateActionEnum action) { + return action != null; + } + + /** + * Gets raw CertificateInstallationReq request from EV, Base64 encoded. + * + * @return Raw CertificateInstallationReq request from EV, Base64 encoded + */ + public String getExiRequest() { + return exiRequest; + } + + /** + * Sets raw CertificateInstallationReq request from EV, Base64 encoded. + * + * @param exiRequest Raw CertificateInstallationReq request from EV, Base64 encoded + */ + public void setExiRequest(String exiRequest) { + if (!isValidExiRequest(exiRequest)) { + throw new PropertyConstraintException(exiRequest, "exiRequest is invalid"); + } + this.exiRequest = exiRequest; + } + + /** + * Returns whether the given exiRequest is valid + * + * @param exiRequest the exiRequest to check the validity of + * @return {@code true} if exiRequest is valid, {@code false} if not + */ + private boolean isValidExiRequest(String exiRequest) { + return exiRequest != null && exiRequest.length() <= 5600; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidIso15118SchemaVersion(iso15118SchemaVersion) + && isValidAction(action) + && isValidExiRequest(exiRequest); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Get15118EVCertificateRequest that = (Get15118EVCertificateRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(iso15118SchemaVersion, that.iso15118SchemaVersion) + && Objects.equals(action, that.action) + && Objects.equals(exiRequest, that.exiRequest); + } + + @Override + public int hashCode() { + return Objects.hash(customData, iso15118SchemaVersion, action, exiRequest); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("iso15118SchemaVersion", iso15118SchemaVersion) + .add("action", action) + .add("exiRequest", exiRequest) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/Get15118EVCertificateResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/Get15118EVCertificateResponse.java new file mode 100644 index 000000000..432334ab3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/Get15118EVCertificateResponse.java @@ -0,0 +1,251 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.Iso15118EVCertificateStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Get15118EVCertificateResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class Get15118EVCertificateResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the message was processed properly. */ + private Iso15118EVCertificateStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Raw CertificateInstallationRes response for the EV, Base64 encoded. */ + private String exiResponse; + + /** + * Constructor for the Get15118EVCertificateResponse class + * + * @param status Whether the message was processed properly. + * @param exiResponse Raw CertificateInstallationRes response for the EV, Base64 encoded. + */ + public Get15118EVCertificateResponse(Iso15118EVCertificateStatusEnum status, String exiResponse) { + setStatus(status); + setExiResponse(exiResponse); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Get15118EVCertificateResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the message was processed properly. + * + * @return Whether the message was processed properly + */ + public Iso15118EVCertificateStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the message was processed properly. + * + * @param status Whether the message was processed properly + */ + public void setStatus(Iso15118EVCertificateStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(Iso15118EVCertificateStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public Get15118EVCertificateResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets raw CertificateInstallationRes response for the EV, Base64 encoded. + * + * @return Raw CertificateInstallationRes response for the EV, Base64 encoded + */ + public String getExiResponse() { + return exiResponse; + } + + /** + * Sets raw CertificateInstallationRes response for the EV, Base64 encoded. + * + * @param exiResponse Raw CertificateInstallationRes response for the EV, Base64 encoded + */ + public void setExiResponse(String exiResponse) { + if (!isValidExiResponse(exiResponse)) { + throw new PropertyConstraintException(exiResponse, "exiResponse is invalid"); + } + this.exiResponse = exiResponse; + } + + /** + * Returns whether the given exiResponse is valid + * + * @param exiResponse the exiResponse to check the validity of + * @return {@code true} if exiResponse is valid, {@code false} if not + */ + private boolean isValidExiResponse(String exiResponse) { + return exiResponse != null && exiResponse.length() <= 5600; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidExiResponse(exiResponse); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Get15118EVCertificateResponse that = (Get15118EVCertificateResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(exiResponse, that.exiResponse); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo, exiResponse); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("exiResponse", exiResponse) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetBaseReportRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetBaseReportRequest.java new file mode 100644 index 000000000..9437c79ef --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetBaseReportRequest.java @@ -0,0 +1,206 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.ReportBaseEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetBaseReportRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetBaseReportRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The Id of the request. */ + private Integer requestId; + + /** The report base. */ + private ReportBaseEnum reportBase; + + /** + * Constructor for the GetBaseReportRequest class + * + * @param requestId The Id of the request. + * @param reportBase The report base. + */ + public GetBaseReportRequest(Integer requestId, ReportBaseEnum reportBase) { + setRequestId(requestId); + setReportBase(reportBase); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetBaseReportRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets the report base. + * + * @return The report base + */ + public ReportBaseEnum getReportBase() { + return reportBase; + } + + /** + * Sets the report base. + * + * @param reportBase The report base + */ + public void setReportBase(ReportBaseEnum reportBase) { + if (!isValidReportBase(reportBase)) { + throw new PropertyConstraintException(reportBase, "reportBase is invalid"); + } + this.reportBase = reportBase; + } + + /** + * Returns whether the given reportBase is valid + * + * @param reportBase the reportBase to check the validity of + * @return {@code true} if reportBase is valid, {@code false} if not + */ + private boolean isValidReportBase(ReportBaseEnum reportBase) { + return reportBase != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidRequestId(requestId) + && isValidReportBase(reportBase); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetBaseReportRequest that = (GetBaseReportRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(requestId, that.requestId) + && Objects.equals(reportBase, that.reportBase); + } + + @Override + public int hashCode() { + return Objects.hash(customData, requestId, reportBase); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("requestId", requestId) + .add("reportBase", reportBase) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetBaseReportResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetBaseReportResponse.java new file mode 100644 index 000000000..621b590cf --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetBaseReportResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GenericDeviceModelStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetBaseReportResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetBaseReportResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the Charging Station is able to accept this request. */ + private GenericDeviceModelStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the GetBaseReportResponse class + * + * @param status Whether the Charging Station is able to accept this request. + */ + public GetBaseReportResponse(GenericDeviceModelStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetBaseReportResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station is able to accept this request. + * + * @return Whether the Charging Station is able to accept this request + */ + public GenericDeviceModelStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station is able to accept this request. + * + * @param status Whether the Charging Station is able to accept this request + */ + public void setStatus(GenericDeviceModelStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericDeviceModelStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetBaseReportResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetBaseReportResponse that = (GetBaseReportResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCertificateStatusRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCertificateStatusRequest.java new file mode 100644 index 000000000..4bec69877 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCertificateStatusRequest.java @@ -0,0 +1,166 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.OCSPRequestData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetCertificateStatusRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetCertificateStatusRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** ocspRequestData */ + private OCSPRequestData ocspRequestData; + + /** + * Constructor for the GetCertificateStatusRequest class + * + * @param ocspRequestData ocspRequestData + */ + public GetCertificateStatusRequest(OCSPRequestData ocspRequestData) { + setOcspRequestData(ocspRequestData); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetCertificateStatusRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets ocspRequestData + * + * @return ocspRequestData + */ + public OCSPRequestData getOcspRequestData() { + return ocspRequestData; + } + + /** + * Sets ocspRequestData + * + * @param ocspRequestData ocspRequestData + */ + public void setOcspRequestData(OCSPRequestData ocspRequestData) { + if (!isValidOcspRequestData(ocspRequestData)) { + throw new PropertyConstraintException(ocspRequestData, "ocspRequestData is invalid"); + } + this.ocspRequestData = ocspRequestData; + } + + /** + * Returns whether the given ocspRequestData is valid + * + * @param ocspRequestData the ocspRequestData to check the validity of + * @return {@code true} if ocspRequestData is valid, {@code false} if not + */ + private boolean isValidOcspRequestData(OCSPRequestData ocspRequestData) { + return ocspRequestData != null && ocspRequestData.validate(); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidOcspRequestData(ocspRequestData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetCertificateStatusRequest that = (GetCertificateStatusRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(ocspRequestData, that.ocspRequestData); + } + + @Override + public int hashCode() { + return Objects.hash(customData, ocspRequestData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("ocspRequestData", ocspRequestData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCertificateStatusResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCertificateStatusResponse.java new file mode 100644 index 000000000..6a645ed73 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCertificateStatusResponse.java @@ -0,0 +1,267 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GetCertificateStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetCertificateStatusResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetCertificateStatusResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the charging station was able to retrieve the OCSP certificate status. */ + private GetCertificateStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), and + * then base64 encoded. MAY only be omitted when status is not Accepted. + */ + @Nullable private String ocspResult; + + /** + * Constructor for the GetCertificateStatusResponse class + * + * @param status Whether the charging station was able to retrieve the OCSP certificate status. + */ + public GetCertificateStatusResponse(GetCertificateStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetCertificateStatusResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the charging station was able to retrieve the OCSP certificate status. + * + * @return Whether the charging station was able to retrieve the OCSP certificate status + */ + public GetCertificateStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the charging station was able to retrieve the OCSP certificate status. + * + * @param status Whether the charging station was able to retrieve the OCSP certificate status + */ + public void setStatus(GetCertificateStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GetCertificateStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetCertificateStatusResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), + * and then base64 encoded. MAY only be omitted when status is not Accepted. + * + * @return OCSPResponse class as defined in IETF RFC 6960 + */ + @Nullable + public String getOcspResult() { + return ocspResult; + } + + /** + * Sets OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), + * and then base64 encoded. MAY only be omitted when status is not Accepted. + * + * @param ocspResult OCSPResponse class as defined in IETF RFC 6960 + */ + public void setOcspResult(@Nullable String ocspResult) { + if (!isValidOcspResult(ocspResult)) { + throw new PropertyConstraintException(ocspResult, "ocspResult is invalid"); + } + this.ocspResult = ocspResult; + } + + /** + * Returns whether the given ocspResult is valid + * + * @param ocspResult the ocspResult to check the validity of + * @return {@code true} if ocspResult is valid, {@code false} if not + */ + private boolean isValidOcspResult(@Nullable String ocspResult) { + return ocspResult == null || ocspResult.length() <= 5500; + } + + /** + * Adds OCSPResponse class as defined in IETF RFC 6960. DER encoded (as defined in IETF RFC 6960), + * and then base64 encoded. MAY only be omitted when status is not Accepted. + * + * @param ocspResult OCSPResponse class as defined in IETF RFC 6960 + * @return this + */ + public GetCertificateStatusResponse withOcspResult(@Nullable String ocspResult) { + setOcspResult(ocspResult); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidOcspResult(ocspResult); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetCertificateStatusResponse that = (GetCertificateStatusResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(ocspResult, that.ocspResult); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo, ocspResult); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("ocspResult", ocspResult) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetChargingProfilesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetChargingProfilesRequest.java new file mode 100644 index 000000000..796082561 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetChargingProfilesRequest.java @@ -0,0 +1,269 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ChargingProfileCriterion; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetChargingProfilesRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetChargingProfilesRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided. + */ + private Integer requestId; + + /** + * For which EVSE installed charging profiles SHALL be reported. If 0, only charging profiles + * installed on the Charging Station itself (the grid connection) SHALL be reported. If omitted, + * all installed charging profiles SHALL be reported. + */ + @Nullable private Integer evseId; + + /** + * Charging Profile + * + *

A ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + */ + private ChargingProfileCriterion chargingProfile; + + /** + * Constructor for the GetChargingProfilesRequest class + * + * @param requestId Reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided. + * @param chargingProfile A ChargingProfile consists of ChargingSchedule, describing the amount of + * power or current that can be delivered per time interval. + */ + public GetChargingProfilesRequest(Integer requestId, ChargingProfileCriterion chargingProfile) { + setRequestId(requestId); + setChargingProfile(chargingProfile); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetChargingProfilesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided. + * + * @return Reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided. + * + * @param requestId Reference identification that is to be used by the Charging Station in the + * ReportChargingProfilesRequest when provided + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets for which EVSE installed charging profiles SHALL be reported. If 0, only charging profiles + * installed on the Charging Station itself (the grid connection) SHALL be reported. If omitted, + * all installed charging profiles SHALL be reported. + * + * @return For which EVSE installed charging profiles SHALL be reported + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets for which EVSE installed charging profiles SHALL be reported. If 0, only charging profiles + * installed on the Charging Station itself (the grid connection) SHALL be reported. If omitted, + * all installed charging profiles SHALL be reported. + * + * @param evseId For which EVSE installed charging profiles SHALL be reported + */ + public void setEvseId(@Nullable Integer evseId) { + this.evseId = evseId; + } + + /** + * Adds for which EVSE installed charging profiles SHALL be reported. If 0, only charging profiles + * installed on the Charging Station itself (the grid connection) SHALL be reported. If omitted, + * all installed charging profiles SHALL be reported. + * + * @param evseId For which EVSE installed charging profiles SHALL be reported + * @return this + */ + public GetChargingProfilesRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets a ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + * + * @return A ChargingProfile consists of ChargingSchedule, describing the amount of power or + * current that can be delivered per time interval + */ + public ChargingProfileCriterion getChargingProfile() { + return chargingProfile; + } + + /** + * Sets a ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + * + * @param chargingProfile A ChargingProfile consists of ChargingSchedule, describing the amount of + * power or current that can be delivered per time interval + */ + public void setChargingProfile(ChargingProfileCriterion chargingProfile) { + if (!isValidChargingProfile(chargingProfile)) { + throw new PropertyConstraintException(chargingProfile, "chargingProfile is invalid"); + } + this.chargingProfile = chargingProfile; + } + + /** + * Returns whether the given chargingProfile is valid + * + * @param chargingProfile the chargingProfile to check the validity of + * @return {@code true} if chargingProfile is valid, {@code false} if not + */ + private boolean isValidChargingProfile(ChargingProfileCriterion chargingProfile) { + return chargingProfile != null && chargingProfile.validate(); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidRequestId(requestId) + && isValidChargingProfile(chargingProfile); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetChargingProfilesRequest that = (GetChargingProfilesRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(requestId, that.requestId) + && Objects.equals(evseId, that.evseId) + && Objects.equals(chargingProfile, that.chargingProfile); + } + + @Override + public int hashCode() { + return Objects.hash(customData, requestId, evseId, chargingProfile); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("requestId", requestId) + .add("evseId", evseId) + .add("chargingProfile", chargingProfile) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetChargingProfilesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetChargingProfilesResponse.java new file mode 100644 index 000000000..89f10610f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetChargingProfilesResponse.java @@ -0,0 +1,218 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GetChargingProfileStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetChargingProfilesResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetChargingProfilesResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages. + */ + private GetChargingProfileStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the GetChargingProfilesResponse class + * + * @param status Whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages. + */ + public GetChargingProfilesResponse(GetChargingProfileStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetChargingProfilesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages. + * + * @return Whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages + */ + public GetChargingProfileStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages. + * + * @param status Whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages + */ + public void setStatus(GetChargingProfileStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GetChargingProfileStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetChargingProfilesResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetChargingProfilesResponse that = (GetChargingProfilesResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCompositeScheduleRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCompositeScheduleRequest.java new file mode 100644 index 000000000..300e4f68a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCompositeScheduleRequest.java @@ -0,0 +1,246 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ChargingRateUnitEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetCompositeScheduleRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetCompositeScheduleRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Length of the requested schedule in seconds. */ + private Integer duration; + + /** Can be used to force a power or current profile. */ + @Nullable private ChargingRateUnitEnum chargingRateUnit; + + /** + * The ID of the EVSE for which the schedule is requested. When evseid=0, the Charging Station + * will calculate the expected consumption for the grid connection. + */ + private Integer evseId; + + /** + * Constructor for the GetCompositeScheduleRequest class + * + * @param duration Length of the requested schedule in seconds. + * @param evseId The ID of the EVSE for which the schedule is requested. When evseid=0, the + * Charging Station will calculate the expected consumption for the grid connection. + */ + public GetCompositeScheduleRequest(Integer duration, Integer evseId) { + setDuration(duration); + setEvseId(evseId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetCompositeScheduleRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets length of the requested schedule in seconds. + * + * @return Length of the requested schedule in seconds + */ + public Integer getDuration() { + return duration; + } + + /** + * Sets length of the requested schedule in seconds. + * + * @param duration Length of the requested schedule in seconds + */ + public void setDuration(Integer duration) { + if (!isValidDuration(duration)) { + throw new PropertyConstraintException(duration, "duration is invalid"); + } + this.duration = duration; + } + + /** + * Returns whether the given duration is valid + * + * @param duration the duration to check the validity of + * @return {@code true} if duration is valid, {@code false} if not + */ + private boolean isValidDuration(Integer duration) { + return duration != null; + } + + /** + * Gets can be used to force a power or current profile. + * + * @return Can be used to force a power or current profile + */ + @Nullable + public ChargingRateUnitEnum getChargingRateUnit() { + return chargingRateUnit; + } + + /** + * Sets can be used to force a power or current profile. + * + * @param chargingRateUnit Can be used to force a power or current profile + */ + public void setChargingRateUnit(@Nullable ChargingRateUnitEnum chargingRateUnit) { + this.chargingRateUnit = chargingRateUnit; + } + + /** + * Adds can be used to force a power or current profile. + * + * @param chargingRateUnit Can be used to force a power or current profile + * @return this + */ + public GetCompositeScheduleRequest withChargingRateUnit( + @Nullable ChargingRateUnitEnum chargingRateUnit) { + setChargingRateUnit(chargingRateUnit); + return this; + } + + /** + * Gets the ID of the EVSE for which the schedule is requested. When evseid=0, the Charging + * Station will calculate the expected consumption for the grid connection. + * + * @return The ID of the EVSE for which the schedule is requested + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the ID of the EVSE for which the schedule is requested. When evseid=0, the Charging + * Station will calculate the expected consumption for the grid connection. + * + * @param evseId The ID of the EVSE for which the schedule is requested + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidDuration(duration) && isValidEvseId(evseId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetCompositeScheduleRequest that = (GetCompositeScheduleRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(duration, that.duration) + && Objects.equals(chargingRateUnit, that.chargingRateUnit) + && Objects.equals(evseId, that.evseId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, duration, chargingRateUnit, evseId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("duration", duration) + .add("chargingRateUnit", chargingRateUnit) + .add("evseId", evseId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCompositeScheduleResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCompositeScheduleResponse.java new file mode 100644 index 000000000..02278ce6b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetCompositeScheduleResponse.java @@ -0,0 +1,262 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CompositeSchedule; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetCompositeScheduleResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetCompositeScheduleResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** The Charging Station will indicate if it was able to process the request */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** Composite Schedule */ + @Nullable private CompositeSchedule schedule; + + /** + * Constructor for the GetCompositeScheduleResponse class + * + * @param status The Charging Station will indicate if it was able to process the request + */ + public GetCompositeScheduleResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetCompositeScheduleResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the Charging Station will indicate if it was able to process the request + * + * @return The Charging Station will indicate if it was able to process the request + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets the Charging Station will indicate if it was able to process the request + * + * @param status The Charging Station will indicate if it was able to process the request + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetCompositeScheduleResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets composite Schedule + * + * @return Composite Schedule + */ + @Nullable + public CompositeSchedule getSchedule() { + return schedule; + } + + /** + * Sets composite Schedule + * + * @param schedule Composite Schedule + */ + public void setSchedule(@Nullable CompositeSchedule schedule) { + if (!isValidSchedule(schedule)) { + throw new PropertyConstraintException(schedule, "schedule is invalid"); + } + this.schedule = schedule; + } + + /** + * Returns whether the given schedule is valid + * + * @param schedule the schedule to check the validity of + * @return {@code true} if schedule is valid, {@code false} if not + */ + private boolean isValidSchedule(@Nullable CompositeSchedule schedule) { + return schedule == null || schedule.validate(); + } + + /** + * Adds composite Schedule + * + * @param schedule Composite Schedule + * @return this + */ + public GetCompositeScheduleResponse withSchedule(@Nullable CompositeSchedule schedule) { + setSchedule(schedule); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidSchedule(schedule); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetCompositeScheduleResponse that = (GetCompositeScheduleResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(schedule, that.schedule); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo, schedule); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("schedule", schedule) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetDisplayMessagesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetDisplayMessagesRequest.java new file mode 100644 index 000000000..ff3fc98f6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetDisplayMessagesRequest.java @@ -0,0 +1,303 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.MessagePriorityEnum; +import eu.chargetime.ocpp.v201.model.types.MessageStateEnum; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetDisplayMessagesRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetDisplayMessagesRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * If provided the Charging Station shall return Display Messages of the given ids. This field + * SHALL NOT contain more ids than set in NumberOfDisplayMessages.maxLimit + */ + @Nullable private Integer[] id; + + /** The Id of this request. */ + private Integer requestId; + + /** + * If provided the Charging Station shall return Display Messages with the given priority only. + */ + @Nullable private MessagePriorityEnum priority; + + /** If provided the Charging Station shall return Display Messages with the given state only. */ + @Nullable private MessageStateEnum state; + + /** + * Constructor for the GetDisplayMessagesRequest class + * + * @param requestId The Id of this request. + */ + public GetDisplayMessagesRequest(Integer requestId) { + setRequestId(requestId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetDisplayMessagesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets if provided the Charging Station shall return Display Messages of the given ids. This + * field SHALL NOT contain more ids than set in NumberOfDisplayMessages.maxLimit + * + * @return If provided the Charging Station shall return Display Messages of the given ids + */ + @Nullable + public Integer[] getId() { + return id; + } + + /** + * Sets if provided the Charging Station shall return Display Messages of the given ids. This + * field SHALL NOT contain more ids than set in NumberOfDisplayMessages.maxLimit + * + * @param id If provided the Charging Station shall return Display Messages of the given ids + */ + public void setId(@Nullable Integer[] id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(@Nullable Integer[] id) { + return id == null || (id.length >= 1); + } + + /** + * Adds if provided the Charging Station shall return Display Messages of the given ids. This + * field SHALL NOT contain more ids than set in NumberOfDisplayMessages.maxLimit + * + * @param id If provided the Charging Station shall return Display Messages of the given ids + * @return this + */ + public GetDisplayMessagesRequest withId(@Nullable Integer[] id) { + setId(id); + return this; + } + + /** + * Gets the Id of this request. + * + * @return The Id of this request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of this request. + * + * @param requestId The Id of this request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets if provided the Charging Station shall return Display Messages with the given priority + * only. + * + * @return If provided the Charging Station shall return Display Messages with the given priority + * only + */ + @Nullable + public MessagePriorityEnum getPriority() { + return priority; + } + + /** + * Sets if provided the Charging Station shall return Display Messages with the given priority + * only. + * + * @param priority If provided the Charging Station shall return Display Messages with the given + * priority only + */ + public void setPriority(@Nullable MessagePriorityEnum priority) { + this.priority = priority; + } + + /** + * Adds if provided the Charging Station shall return Display Messages with the given priority + * only. + * + * @param priority If provided the Charging Station shall return Display Messages with the given + * priority only + * @return this + */ + public GetDisplayMessagesRequest withPriority(@Nullable MessagePriorityEnum priority) { + setPriority(priority); + return this; + } + + /** + * Gets if provided the Charging Station shall return Display Messages with the given state only. + * + * @return If provided the Charging Station shall return Display Messages with the given state + * only + */ + @Nullable + public MessageStateEnum getState() { + return state; + } + + /** + * Sets if provided the Charging Station shall return Display Messages with the given state only. + * + * @param state If provided the Charging Station shall return Display Messages with the given + * state only + */ + public void setState(@Nullable MessageStateEnum state) { + this.state = state; + } + + /** + * Adds if provided the Charging Station shall return Display Messages with the given state only. + * + * @param state If provided the Charging Station shall return Display Messages with the given + * state only + * @return this + */ + public GetDisplayMessagesRequest withState(@Nullable MessageStateEnum state) { + setState(state); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidId(id) && isValidRequestId(requestId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetDisplayMessagesRequest that = (GetDisplayMessagesRequest) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(id, that.id) + && Objects.equals(requestId, that.requestId) + && Objects.equals(priority, that.priority) + && Objects.equals(state, that.state); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(id), requestId, priority, state); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("id", id) + .add("requestId", requestId) + .add("priority", priority) + .add("state", state) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetDisplayMessagesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetDisplayMessagesResponse.java new file mode 100644 index 000000000..a6b8d2b31 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetDisplayMessagesResponse.java @@ -0,0 +1,218 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GetDisplayMessagesStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetDisplayMessagesResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetDisplayMessagesResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Whether the Charging Station has Display Messages that match the request criteria in the + * GetDisplayMessagesRequest + */ + private GetDisplayMessagesStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the GetDisplayMessagesResponse class + * + * @param status Whether the Charging Station has Display Messages that match the request criteria + * in the GetDisplayMessagesRequest + */ + public GetDisplayMessagesResponse(GetDisplayMessagesStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetDisplayMessagesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station has Display Messages that match the request criteria in the + * GetDisplayMessagesRequest + * + * @return Whether the Charging Station has Display Messages that match the request criteria in + * the GetDisplayMessagesRequest + */ + public GetDisplayMessagesStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station has Display Messages that match the request criteria in the + * GetDisplayMessagesRequest + * + * @param status Whether the Charging Station has Display Messages that match the request criteria + * in the GetDisplayMessagesRequest + */ + public void setStatus(GetDisplayMessagesStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GetDisplayMessagesStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetDisplayMessagesResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetDisplayMessagesResponse that = (GetDisplayMessagesResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetInstalledCertificateIdsRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetInstalledCertificateIdsRequest.java new file mode 100644 index 000000000..c9be927ce --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetInstalledCertificateIdsRequest.java @@ -0,0 +1,174 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GetCertificateIdUseEnum; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetInstalledCertificateIdsRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetInstalledCertificateIdsRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The type of certificates requested. When omitted, all certificate types are requested. */ + @Nullable private GetCertificateIdUseEnum[] certificateType; + + /** Constructor for the GetInstalledCertificateIdsRequest class */ + public GetInstalledCertificateIdsRequest() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetInstalledCertificateIdsRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the type of certificates requested. When omitted, all certificate types are requested. + * + * @return The type of certificates requested + */ + @Nullable + public GetCertificateIdUseEnum[] getCertificateType() { + return certificateType; + } + + /** + * Sets the type of certificates requested. When omitted, all certificate types are requested. + * + * @param certificateType The type of certificates requested + */ + public void setCertificateType(@Nullable GetCertificateIdUseEnum[] certificateType) { + if (!isValidCertificateType(certificateType)) { + throw new PropertyConstraintException(certificateType, "certificateType is invalid"); + } + this.certificateType = certificateType; + } + + /** + * Returns whether the given certificateType is valid + * + * @param certificateType the certificateType to check the validity of + * @return {@code true} if certificateType is valid, {@code false} if not + */ + private boolean isValidCertificateType(@Nullable GetCertificateIdUseEnum[] certificateType) { + return certificateType == null || (certificateType.length >= 1); + } + + /** + * Adds the type of certificates requested. When omitted, all certificate types are requested. + * + * @param certificateType The type of certificates requested + * @return this + */ + public GetInstalledCertificateIdsRequest withCertificateType( + @Nullable GetCertificateIdUseEnum[] certificateType) { + setCertificateType(certificateType); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidCertificateType(certificateType); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetInstalledCertificateIdsRequest that = (GetInstalledCertificateIdsRequest) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(certificateType, that.certificateType); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(certificateType)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("certificateType", certificateType) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetInstalledCertificateIdsResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetInstalledCertificateIdsResponse.java new file mode 100644 index 000000000..6a17d5a48 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetInstalledCertificateIdsResponse.java @@ -0,0 +1,269 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CertificateHashDataChain; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GetInstalledCertificateStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetInstalledCertificateIdsResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetInstalledCertificateIdsResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Charging Station indicates if it can process the request. */ + private GetInstalledCertificateStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** certificateHashDataChain */ + @Nullable private CertificateHashDataChain[] certificateHashDataChain; + + /** + * Constructor for the GetInstalledCertificateIdsResponse class + * + * @param status Charging Station indicates if it can process the request. + */ + public GetInstalledCertificateIdsResponse(GetInstalledCertificateStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetInstalledCertificateIdsResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets charging Station indicates if it can process the request. + * + * @return Charging Station indicates if it can process the request + */ + public GetInstalledCertificateStatusEnum getStatus() { + return status; + } + + /** + * Sets charging Station indicates if it can process the request. + * + * @param status Charging Station indicates if it can process the request + */ + public void setStatus(GetInstalledCertificateStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GetInstalledCertificateStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetInstalledCertificateIdsResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets certificateHashDataChain + * + * @return certificateHashDataChain + */ + @Nullable + public CertificateHashDataChain[] getCertificateHashDataChain() { + return certificateHashDataChain; + } + + /** + * Sets certificateHashDataChain + * + * @param certificateHashDataChain certificateHashDataChain + */ + public void setCertificateHashDataChain( + @Nullable CertificateHashDataChain[] certificateHashDataChain) { + if (!isValidCertificateHashDataChain(certificateHashDataChain)) { + throw new PropertyConstraintException( + certificateHashDataChain, "certificateHashDataChain is invalid"); + } + this.certificateHashDataChain = certificateHashDataChain; + } + + /** + * Returns whether the given certificateHashDataChain is valid + * + * @param certificateHashDataChain the certificateHashDataChain to check the validity of + * @return {@code true} if certificateHashDataChain is valid, {@code false} if not + */ + private boolean isValidCertificateHashDataChain( + @Nullable CertificateHashDataChain[] certificateHashDataChain) { + return certificateHashDataChain == null + || (certificateHashDataChain.length >= 1 + && Arrays.stream(certificateHashDataChain).allMatch(item -> item.validate())); + } + + /** + * Adds certificateHashDataChain + * + * @param certificateHashDataChain certificateHashDataChain + * @return this + */ + public GetInstalledCertificateIdsResponse withCertificateHashDataChain( + @Nullable CertificateHashDataChain[] certificateHashDataChain) { + setCertificateHashDataChain(certificateHashDataChain); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidCertificateHashDataChain(certificateHashDataChain); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetInstalledCertificateIdsResponse that = (GetInstalledCertificateIdsResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Arrays.equals(certificateHashDataChain, that.certificateHashDataChain); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo, Arrays.hashCode(certificateHashDataChain)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("certificateHashDataChain", certificateHashDataChain) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLocalListVersionRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLocalListVersionRequest.java new file mode 100644 index 000000000..63221fddd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLocalListVersionRequest.java @@ -0,0 +1,123 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetLocalListVersionRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetLocalListVersionRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the GetLocalListVersionRequest class */ + public GetLocalListVersionRequest() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetLocalListVersionRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetLocalListVersionRequest that = (GetLocalListVersionRequest) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLocalListVersionResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLocalListVersionResponse.java new file mode 100644 index 000000000..93736aa14 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLocalListVersionResponse.java @@ -0,0 +1,162 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetLocalListVersionResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetLocalListVersionResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** The current version number of the local authorization list in the Charging Station. */ + private Integer versionNumber; + + /** + * Constructor for the GetLocalListVersionResponse class + * + * @param versionNumber The current version number of the local authorization list in the Charging + * Station. + */ + public GetLocalListVersionResponse(Integer versionNumber) { + setVersionNumber(versionNumber); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetLocalListVersionResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the current version number of the local authorization list in the Charging Station. + * + * @return The current version number of the local authorization list in the Charging Station + */ + public Integer getVersionNumber() { + return versionNumber; + } + + /** + * Sets the current version number of the local authorization list in the Charging Station. + * + * @param versionNumber The current version number of the local authorization list in the Charging + * Station + */ + public void setVersionNumber(Integer versionNumber) { + if (!isValidVersionNumber(versionNumber)) { + throw new PropertyConstraintException(versionNumber, "versionNumber is invalid"); + } + this.versionNumber = versionNumber; + } + + /** + * Returns whether the given versionNumber is valid + * + * @param versionNumber the versionNumber to check the validity of + * @return {@code true} if versionNumber is valid, {@code false} if not + */ + private boolean isValidVersionNumber(Integer versionNumber) { + return versionNumber != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidVersionNumber(versionNumber); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetLocalListVersionResponse that = (GetLocalListVersionResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(versionNumber, that.versionNumber); + } + + @Override + public int hashCode() { + return Objects.hash(customData, versionNumber); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("versionNumber", versionNumber) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLogRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLogRequest.java new file mode 100644 index 000000000..61e97c2c5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLogRequest.java @@ -0,0 +1,335 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.LogEnum; +import eu.chargetime.ocpp.v201.model.types.LogParameters; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetLogRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetLogRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Log + * + *

Generic class for the configuration of logging entries. + */ + private LogParameters log; + + /** The type of log file that the Charging Station should send. */ + private LogEnum logType; + + /** The Id of this request */ + private Integer requestId; + + /** + * How many times the Charging Station must try to upload the log before giving up. If this field + * is not present, it is left to Charging Station to decide how many times it wants to retry. + */ + @Nullable private Integer retries; + + /** + * The interval in seconds after which a retry may be attempted. If this field is not present, it + * is left to Charging Station to decide how long to wait between attempts. + */ + @Nullable private Integer retryInterval; + + /** + * Constructor for the GetLogRequest class + * + * @param log Generic class for the configuration of logging entries. + * @param logType The type of log file that the Charging Station should send. + * @param requestId The Id of this request + */ + public GetLogRequest(LogParameters log, LogEnum logType, Integer requestId) { + setLog(log); + setLogType(logType); + setRequestId(requestId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetLogRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets generic class for the configuration of logging entries. + * + * @return Generic class for the configuration of logging entries + */ + public LogParameters getLog() { + return log; + } + + /** + * Sets generic class for the configuration of logging entries. + * + * @param log Generic class for the configuration of logging entries + */ + public void setLog(LogParameters log) { + if (!isValidLog(log)) { + throw new PropertyConstraintException(log, "log is invalid"); + } + this.log = log; + } + + /** + * Returns whether the given log is valid + * + * @param log the log to check the validity of + * @return {@code true} if log is valid, {@code false} if not + */ + private boolean isValidLog(LogParameters log) { + return log != null && log.validate(); + } + + /** + * Gets the type of log file that the Charging Station should send. + * + * @return The type of log file that the Charging Station should send + */ + public LogEnum getLogType() { + return logType; + } + + /** + * Sets the type of log file that the Charging Station should send. + * + * @param logType The type of log file that the Charging Station should send + */ + public void setLogType(LogEnum logType) { + if (!isValidLogType(logType)) { + throw new PropertyConstraintException(logType, "logType is invalid"); + } + this.logType = logType; + } + + /** + * Returns whether the given logType is valid + * + * @param logType the logType to check the validity of + * @return {@code true} if logType is valid, {@code false} if not + */ + private boolean isValidLogType(LogEnum logType) { + return logType != null; + } + + /** + * Gets the Id of this request + * + * @return The Id of this request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of this request + * + * @param requestId The Id of this request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets how many times the Charging Station must try to upload the log before giving up. If this + * field is not present, it is left to Charging Station to decide how many times it wants to + * retry. + * + * @return How many times the Charging Station must try to upload the log before giving up + */ + @Nullable + public Integer getRetries() { + return retries; + } + + /** + * Sets how many times the Charging Station must try to upload the log before giving up. If this + * field is not present, it is left to Charging Station to decide how many times it wants to + * retry. + * + * @param retries How many times the Charging Station must try to upload the log before giving up + */ + public void setRetries(@Nullable Integer retries) { + this.retries = retries; + } + + /** + * Adds how many times the Charging Station must try to upload the log before giving up. If this + * field is not present, it is left to Charging Station to decide how many times it wants to + * retry. + * + * @param retries How many times the Charging Station must try to upload the log before giving up + * @return this + */ + public GetLogRequest withRetries(@Nullable Integer retries) { + setRetries(retries); + return this; + } + + /** + * Gets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @return The interval in seconds after which a retry may be attempted + */ + @Nullable + public Integer getRetryInterval() { + return retryInterval; + } + + /** + * Sets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + */ + public void setRetryInterval(@Nullable Integer retryInterval) { + this.retryInterval = retryInterval; + } + + /** + * Adds the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + * @return this + */ + public GetLogRequest withRetryInterval(@Nullable Integer retryInterval) { + setRetryInterval(retryInterval); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidLog(log) + && isValidLogType(logType) + && isValidRequestId(requestId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetLogRequest that = (GetLogRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(log, that.log) + && Objects.equals(logType, that.logType) + && Objects.equals(requestId, that.requestId) + && Objects.equals(retries, that.retries) + && Objects.equals(retryInterval, that.retryInterval); + } + + @Override + public int hashCode() { + return Objects.hash(customData, log, logType, requestId, retries, retryInterval); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("log", log) + .add("logType", logType) + .add("requestId", requestId) + .add("retries", retries) + .add("retryInterval", retryInterval) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLogResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLogResponse.java new file mode 100644 index 000000000..c66d3cd2c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetLogResponse.java @@ -0,0 +1,267 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.LogStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetLogResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetLogResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** This field indicates whether the Charging Station was able to accept the request. */ + private LogStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * The name of the log file that will be uploaded. This field is not present when no logging + * information is available. + */ + @Nullable private String filename; + + /** + * Constructor for the GetLogResponse class + * + * @param status This field indicates whether the Charging Station was able to accept the request. + */ + public GetLogResponse(LogStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetLogResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets this field indicates whether the Charging Station was able to accept the request. + * + * @return This field indicates whether the Charging Station was able to accept the request + */ + public LogStatusEnum getStatus() { + return status; + } + + /** + * Sets this field indicates whether the Charging Station was able to accept the request. + * + * @param status This field indicates whether the Charging Station was able to accept the request + */ + public void setStatus(LogStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(LogStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetLogResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets the name of the log file that will be uploaded. This field is not present when no logging + * information is available. + * + * @return The name of the log file that will be uploaded + */ + @Nullable + public String getFilename() { + return filename; + } + + /** + * Sets the name of the log file that will be uploaded. This field is not present when no logging + * information is available. + * + * @param filename The name of the log file that will be uploaded + */ + public void setFilename(@Nullable String filename) { + if (!isValidFilename(filename)) { + throw new PropertyConstraintException(filename, "filename is invalid"); + } + this.filename = filename; + } + + /** + * Returns whether the given filename is valid + * + * @param filename the filename to check the validity of + * @return {@code true} if filename is valid, {@code false} if not + */ + private boolean isValidFilename(@Nullable String filename) { + return filename == null || filename.length() <= 255; + } + + /** + * Adds the name of the log file that will be uploaded. This field is not present when no logging + * information is available. + * + * @param filename The name of the log file that will be uploaded + * @return this + */ + public GetLogResponse withFilename(@Nullable String filename) { + setFilename(filename); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidFilename(filename); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetLogResponse that = (GetLogResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(filename, that.filename); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo, filename); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("filename", filename) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetMonitoringReportRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetMonitoringReportRequest.java new file mode 100644 index 000000000..d2c955c7e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetMonitoringReportRequest.java @@ -0,0 +1,281 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ComponentVariable; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.MonitoringCriterionEnum; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetMonitoringReportRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetMonitoringReportRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Class to report components, variables and variable attributes and characteristics. */ + @Nullable private ComponentVariable[] componentVariable; + + /** The Id of the request. */ + private Integer requestId; + + /** This field contains criteria for components for which a monitoring report is requested */ + @Nullable private MonitoringCriterionEnum[] monitoringCriteria; + + /** + * Constructor for the GetMonitoringReportRequest class + * + * @param requestId The Id of the request. + */ + public GetMonitoringReportRequest(Integer requestId) { + setRequestId(requestId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetMonitoringReportRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets class to report components, variables and variable attributes and characteristics. + * + * @return Class to report components, variables and variable attributes and characteristics + */ + @Nullable + public ComponentVariable[] getComponentVariable() { + return componentVariable; + } + + /** + * Sets class to report components, variables and variable attributes and characteristics. + * + * @param componentVariable Class to report components, variables and variable attributes and + * characteristics + */ + public void setComponentVariable(@Nullable ComponentVariable[] componentVariable) { + if (!isValidComponentVariable(componentVariable)) { + throw new PropertyConstraintException(componentVariable, "componentVariable is invalid"); + } + this.componentVariable = componentVariable; + } + + /** + * Returns whether the given componentVariable is valid + * + * @param componentVariable the componentVariable to check the validity of + * @return {@code true} if componentVariable is valid, {@code false} if not + */ + private boolean isValidComponentVariable(@Nullable ComponentVariable[] componentVariable) { + return componentVariable == null + || (componentVariable.length >= 1 + && Arrays.stream(componentVariable).allMatch(item -> item.validate())); + } + + /** + * Adds class to report components, variables and variable attributes and characteristics. + * + * @param componentVariable Class to report components, variables and variable attributes and + * characteristics + * @return this + */ + public GetMonitoringReportRequest withComponentVariable( + @Nullable ComponentVariable[] componentVariable) { + setComponentVariable(componentVariable); + return this; + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets this field contains criteria for components for which a monitoring report is requested + * + * @return This field contains criteria for components for which a monitoring report is requested + */ + @Nullable + public MonitoringCriterionEnum[] getMonitoringCriteria() { + return monitoringCriteria; + } + + /** + * Sets this field contains criteria for components for which a monitoring report is requested + * + * @param monitoringCriteria This field contains criteria for components for which a monitoring + * report is requested + */ + public void setMonitoringCriteria(@Nullable MonitoringCriterionEnum[] monitoringCriteria) { + if (!isValidMonitoringCriteria(monitoringCriteria)) { + throw new PropertyConstraintException(monitoringCriteria, "monitoringCriteria is invalid"); + } + this.monitoringCriteria = monitoringCriteria; + } + + /** + * Returns whether the given monitoringCriteria is valid + * + * @param monitoringCriteria the monitoringCriteria to check the validity of + * @return {@code true} if monitoringCriteria is valid, {@code false} if not + */ + private boolean isValidMonitoringCriteria( + @Nullable MonitoringCriterionEnum[] monitoringCriteria) { + return monitoringCriteria == null + || (monitoringCriteria.length >= 1 && monitoringCriteria.length <= 3); + } + + /** + * Adds this field contains criteria for components for which a monitoring report is requested + * + * @param monitoringCriteria This field contains criteria for components for which a monitoring + * report is requested + * @return this + */ + public GetMonitoringReportRequest withMonitoringCriteria( + @Nullable MonitoringCriterionEnum[] monitoringCriteria) { + setMonitoringCriteria(monitoringCriteria); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidComponentVariable(componentVariable) + && isValidRequestId(requestId) + && isValidMonitoringCriteria(monitoringCriteria); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetMonitoringReportRequest that = (GetMonitoringReportRequest) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(componentVariable, that.componentVariable) + && Objects.equals(requestId, that.requestId) + && Arrays.equals(monitoringCriteria, that.monitoringCriteria); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + Arrays.hashCode(componentVariable), + requestId, + Arrays.hashCode(monitoringCriteria)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("componentVariable", componentVariable) + .add("requestId", requestId) + .add("monitoringCriteria", monitoringCriteria) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetMonitoringReportResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetMonitoringReportResponse.java new file mode 100644 index 000000000..d1b9eabf8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetMonitoringReportResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GenericDeviceModelStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetMonitoringReportResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetMonitoringReportResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** This field indicates whether the Charging Station was able to accept the request. */ + private GenericDeviceModelStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the GetMonitoringReportResponse class + * + * @param status This field indicates whether the Charging Station was able to accept the request. + */ + public GetMonitoringReportResponse(GenericDeviceModelStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetMonitoringReportResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets this field indicates whether the Charging Station was able to accept the request. + * + * @return This field indicates whether the Charging Station was able to accept the request + */ + public GenericDeviceModelStatusEnum getStatus() { + return status; + } + + /** + * Sets this field indicates whether the Charging Station was able to accept the request. + * + * @param status This field indicates whether the Charging Station was able to accept the request + */ + public void setStatus(GenericDeviceModelStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericDeviceModelStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetMonitoringReportResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetMonitoringReportResponse that = (GetMonitoringReportResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetReportRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetReportRequest.java new file mode 100644 index 000000000..1aa6cd412 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetReportRequest.java @@ -0,0 +1,279 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ComponentCriterionEnum; +import eu.chargetime.ocpp.v201.model.types.ComponentVariable; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetReportRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetReportRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Class to report components, variables and variable attributes and characteristics. */ + @Nullable private ComponentVariable[] componentVariable; + + /** The Id of the request. */ + private Integer requestId; + + /** This field contains criteria for components for which a report is requested */ + @Nullable private ComponentCriterionEnum[] componentCriteria; + + /** + * Constructor for the GetReportRequest class + * + * @param requestId The Id of the request. + */ + public GetReportRequest(Integer requestId) { + setRequestId(requestId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetReportRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets class to report components, variables and variable attributes and characteristics. + * + * @return Class to report components, variables and variable attributes and characteristics + */ + @Nullable + public ComponentVariable[] getComponentVariable() { + return componentVariable; + } + + /** + * Sets class to report components, variables and variable attributes and characteristics. + * + * @param componentVariable Class to report components, variables and variable attributes and + * characteristics + */ + public void setComponentVariable(@Nullable ComponentVariable[] componentVariable) { + if (!isValidComponentVariable(componentVariable)) { + throw new PropertyConstraintException(componentVariable, "componentVariable is invalid"); + } + this.componentVariable = componentVariable; + } + + /** + * Returns whether the given componentVariable is valid + * + * @param componentVariable the componentVariable to check the validity of + * @return {@code true} if componentVariable is valid, {@code false} if not + */ + private boolean isValidComponentVariable(@Nullable ComponentVariable[] componentVariable) { + return componentVariable == null + || (componentVariable.length >= 1 + && Arrays.stream(componentVariable).allMatch(item -> item.validate())); + } + + /** + * Adds class to report components, variables and variable attributes and characteristics. + * + * @param componentVariable Class to report components, variables and variable attributes and + * characteristics + * @return this + */ + public GetReportRequest withComponentVariable(@Nullable ComponentVariable[] componentVariable) { + setComponentVariable(componentVariable); + return this; + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets this field contains criteria for components for which a report is requested + * + * @return This field contains criteria for components for which a report is requested + */ + @Nullable + public ComponentCriterionEnum[] getComponentCriteria() { + return componentCriteria; + } + + /** + * Sets this field contains criteria for components for which a report is requested + * + * @param componentCriteria This field contains criteria for components for which a report is + * requested + */ + public void setComponentCriteria(@Nullable ComponentCriterionEnum[] componentCriteria) { + if (!isValidComponentCriteria(componentCriteria)) { + throw new PropertyConstraintException(componentCriteria, "componentCriteria is invalid"); + } + this.componentCriteria = componentCriteria; + } + + /** + * Returns whether the given componentCriteria is valid + * + * @param componentCriteria the componentCriteria to check the validity of + * @return {@code true} if componentCriteria is valid, {@code false} if not + */ + private boolean isValidComponentCriteria(@Nullable ComponentCriterionEnum[] componentCriteria) { + return componentCriteria == null + || (componentCriteria.length >= 1 && componentCriteria.length <= 4); + } + + /** + * Adds this field contains criteria for components for which a report is requested + * + * @param componentCriteria This field contains criteria for components for which a report is + * requested + * @return this + */ + public GetReportRequest withComponentCriteria( + @Nullable ComponentCriterionEnum[] componentCriteria) { + setComponentCriteria(componentCriteria); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidComponentVariable(componentVariable) + && isValidRequestId(requestId) + && isValidComponentCriteria(componentCriteria); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetReportRequest that = (GetReportRequest) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(componentVariable, that.componentVariable) + && Objects.equals(requestId, that.requestId) + && Arrays.equals(componentCriteria, that.componentCriteria); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + Arrays.hashCode(componentVariable), + requestId, + Arrays.hashCode(componentCriteria)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("componentVariable", componentVariable) + .add("requestId", requestId) + .add("componentCriteria", componentCriteria) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetReportResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetReportResponse.java new file mode 100644 index 000000000..a3a4504c3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetReportResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GenericDeviceModelStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetReportResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetReportResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** This field indicates whether the Charging Station was able to accept the request. */ + private GenericDeviceModelStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the GetReportResponse class + * + * @param status This field indicates whether the Charging Station was able to accept the request. + */ + public GetReportResponse(GenericDeviceModelStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetReportResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets this field indicates whether the Charging Station was able to accept the request. + * + * @return This field indicates whether the Charging Station was able to accept the request + */ + public GenericDeviceModelStatusEnum getStatus() { + return status; + } + + /** + * Sets this field indicates whether the Charging Station was able to accept the request. + * + * @param status This field indicates whether the Charging Station was able to accept the request + */ + public void setStatus(GenericDeviceModelStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericDeviceModelStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public GetReportResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetReportResponse that = (GetReportResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetTransactionStatusRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetTransactionStatusRequest.java new file mode 100644 index 000000000..c2a642fff --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetTransactionStatusRequest.java @@ -0,0 +1,171 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetTransactionStatusRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetTransactionStatusRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The Id of the transaction for which the status is requested. */ + @Nullable private String transactionId; + + /** Constructor for the GetTransactionStatusRequest class */ + public GetTransactionStatusRequest() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetTransactionStatusRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the Id of the transaction for which the status is requested. + * + * @return The Id of the transaction for which the status is requested + */ + @Nullable + public String getTransactionId() { + return transactionId; + } + + /** + * Sets the Id of the transaction for which the status is requested. + * + * @param transactionId The Id of the transaction for which the status is requested + */ + public void setTransactionId(@Nullable String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(@Nullable String transactionId) { + return transactionId == null || transactionId.length() <= 36; + } + + /** + * Adds the Id of the transaction for which the status is requested. + * + * @param transactionId The Id of the transaction for which the status is requested + * @return this + */ + public GetTransactionStatusRequest withTransactionId(@Nullable String transactionId) { + setTransactionId(transactionId); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidTransactionId(transactionId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetTransactionStatusRequest that = (GetTransactionStatusRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(transactionId, that.transactionId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, transactionId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("transactionId", transactionId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetTransactionStatusResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetTransactionStatusResponse.java new file mode 100644 index 000000000..c8a2e88ae --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetTransactionStatusResponse.java @@ -0,0 +1,195 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetTransactionStatusResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetTransactionStatusResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the transaction is still ongoing. */ + @Nullable private Boolean ongoingIndicator; + + /** Whether there are still message to be delivered. */ + private Boolean messagesInQueue; + + /** + * Constructor for the GetTransactionStatusResponse class + * + * @param messagesInQueue Whether there are still message to be delivered. + */ + public GetTransactionStatusResponse(Boolean messagesInQueue) { + setMessagesInQueue(messagesInQueue); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetTransactionStatusResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the transaction is still ongoing. + * + * @return Whether the transaction is still ongoing + */ + @Nullable + public Boolean getOngoingIndicator() { + return ongoingIndicator; + } + + /** + * Sets whether the transaction is still ongoing. + * + * @param ongoingIndicator Whether the transaction is still ongoing + */ + public void setOngoingIndicator(@Nullable Boolean ongoingIndicator) { + this.ongoingIndicator = ongoingIndicator; + } + + /** + * Adds whether the transaction is still ongoing. + * + * @param ongoingIndicator Whether the transaction is still ongoing + * @return this + */ + public GetTransactionStatusResponse withOngoingIndicator(@Nullable Boolean ongoingIndicator) { + setOngoingIndicator(ongoingIndicator); + return this; + } + + /** + * Gets whether there are still message to be delivered. + * + * @return Whether there are still message to be delivered + */ + public Boolean getMessagesInQueue() { + return messagesInQueue; + } + + /** + * Sets whether there are still message to be delivered. + * + * @param messagesInQueue Whether there are still message to be delivered + */ + public void setMessagesInQueue(Boolean messagesInQueue) { + if (!isValidMessagesInQueue(messagesInQueue)) { + throw new PropertyConstraintException(messagesInQueue, "messagesInQueue is invalid"); + } + this.messagesInQueue = messagesInQueue; + } + + /** + * Returns whether the given messagesInQueue is valid + * + * @param messagesInQueue the messagesInQueue to check the validity of + * @return {@code true} if messagesInQueue is valid, {@code false} if not + */ + private boolean isValidMessagesInQueue(Boolean messagesInQueue) { + return messagesInQueue != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidMessagesInQueue(messagesInQueue); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetTransactionStatusResponse that = (GetTransactionStatusResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(ongoingIndicator, that.ongoingIndicator) + && Objects.equals(messagesInQueue, that.messagesInQueue); + } + + @Override + public int hashCode() { + return Objects.hash(customData, ongoingIndicator, messagesInQueue); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("ongoingIndicator", ongoingIndicator) + .add("messagesInQueue", messagesInQueue) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetVariablesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetVariablesRequest.java new file mode 100644 index 000000000..73a118d4c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetVariablesRequest.java @@ -0,0 +1,169 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GetVariableData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetVariablesRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class GetVariablesRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Class to hold parameters for GetVariables request. */ + private GetVariableData[] getVariableData; + + /** + * Constructor for the GetVariablesRequest class + * + * @param getVariableData Class to hold parameters for GetVariables request. + */ + public GetVariablesRequest(GetVariableData[] getVariableData) { + setGetVariableData(getVariableData); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetVariablesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets class to hold parameters for GetVariables request. + * + * @return Class to hold parameters for GetVariables request + */ + public GetVariableData[] getGetVariableData() { + return getVariableData; + } + + /** + * Sets class to hold parameters for GetVariables request. + * + * @param getVariableData Class to hold parameters for GetVariables request + */ + public void setGetVariableData(GetVariableData[] getVariableData) { + if (!isValidGetVariableData(getVariableData)) { + throw new PropertyConstraintException(getVariableData, "getVariableData is invalid"); + } + this.getVariableData = getVariableData; + } + + /** + * Returns whether the given getVariableData is valid + * + * @param getVariableData the getVariableData to check the validity of + * @return {@code true} if getVariableData is valid, {@code false} if not + */ + private boolean isValidGetVariableData(GetVariableData[] getVariableData) { + return getVariableData != null + && getVariableData.length >= 1 + && Arrays.stream(getVariableData).allMatch(item -> item.validate()); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidGetVariableData(getVariableData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetVariablesRequest that = (GetVariablesRequest) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(getVariableData, that.getVariableData); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(getVariableData)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("getVariableData", getVariableData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetVariablesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetVariablesResponse.java new file mode 100644 index 000000000..21a24926c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/GetVariablesResponse.java @@ -0,0 +1,164 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GetVariableResult; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * GetVariablesResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class GetVariablesResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Class to hold results of GetVariables request. */ + private GetVariableResult[] getVariableResult; + + /** + * Constructor for the GetVariablesResponse class + * + * @param getVariableResult Class to hold results of GetVariables request. + */ + public GetVariablesResponse(GetVariableResult[] getVariableResult) { + setGetVariableResult(getVariableResult); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetVariablesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets class to hold results of GetVariables request. + * + * @return Class to hold results of GetVariables request + */ + public GetVariableResult[] getGetVariableResult() { + return getVariableResult; + } + + /** + * Sets class to hold results of GetVariables request. + * + * @param getVariableResult Class to hold results of GetVariables request + */ + public void setGetVariableResult(GetVariableResult[] getVariableResult) { + if (!isValidGetVariableResult(getVariableResult)) { + throw new PropertyConstraintException(getVariableResult, "getVariableResult is invalid"); + } + this.getVariableResult = getVariableResult; + } + + /** + * Returns whether the given getVariableResult is valid + * + * @param getVariableResult the getVariableResult to check the validity of + * @return {@code true} if getVariableResult is valid, {@code false} if not + */ + private boolean isValidGetVariableResult(GetVariableResult[] getVariableResult) { + return getVariableResult != null + && getVariableResult.length >= 1 + && Arrays.stream(getVariableResult).allMatch(item -> item.validate()); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidGetVariableResult(getVariableResult); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetVariablesResponse that = (GetVariablesResponse) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(getVariableResult, that.getVariableResult); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(getVariableResult)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("getVariableResult", getVariableResult) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/HeartbeatRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/HeartbeatRequest.java new file mode 100644 index 000000000..d35a3d9ab --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/HeartbeatRequest.java @@ -0,0 +1,123 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * HeartbeatRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class HeartbeatRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the HeartbeatRequest class */ + public HeartbeatRequest() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public HeartbeatRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HeartbeatRequest that = (HeartbeatRequest) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/HeartbeatResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/HeartbeatResponse.java new file mode 100644 index 000000000..c06b472cc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/HeartbeatResponse.java @@ -0,0 +1,161 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * HeartbeatResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class HeartbeatResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** The current time of the CSMS. */ + private ZonedDateTime currentTime; + + /** + * Constructor for the HeartbeatResponse class + * + * @param currentTime The current time of the CSMS. + */ + public HeartbeatResponse(ZonedDateTime currentTime) { + setCurrentTime(currentTime); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public HeartbeatResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the current time of the CSMS. + * + * @return The current time of the CSMS + */ + public ZonedDateTime getCurrentTime() { + return currentTime; + } + + /** + * Sets the current time of the CSMS. + * + * @param currentTime The current time of the CSMS + */ + public void setCurrentTime(ZonedDateTime currentTime) { + if (!isValidCurrentTime(currentTime)) { + throw new PropertyConstraintException(currentTime, "currentTime is invalid"); + } + this.currentTime = currentTime; + } + + /** + * Returns whether the given currentTime is valid + * + * @param currentTime the currentTime to check the validity of + * @return {@code true} if currentTime is valid, {@code false} if not + */ + private boolean isValidCurrentTime(ZonedDateTime currentTime) { + return currentTime != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidCurrentTime(currentTime); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HeartbeatResponse that = (HeartbeatResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(currentTime, that.currentTime); + } + + @Override + public int hashCode() { + return Objects.hash(customData, currentTime); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("currentTime", currentTime) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/InstallCertificateRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/InstallCertificateRequest.java new file mode 100644 index 000000000..9f10ca4d6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/InstallCertificateRequest.java @@ -0,0 +1,206 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.InstallCertificateUseEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * InstallCertificateRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class InstallCertificateRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The certificate type that is sent. */ + private InstallCertificateUseEnum certificateType; + + /** A PEM encoded X.509 certificate. */ + private String certificate; + + /** + * Constructor for the InstallCertificateRequest class + * + * @param certificateType The certificate type that is sent. + * @param certificate A PEM encoded X.509 certificate. + */ + public InstallCertificateRequest(InstallCertificateUseEnum certificateType, String certificate) { + setCertificateType(certificateType); + setCertificate(certificate); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public InstallCertificateRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the certificate type that is sent. + * + * @return The certificate type that is sent + */ + public InstallCertificateUseEnum getCertificateType() { + return certificateType; + } + + /** + * Sets the certificate type that is sent. + * + * @param certificateType The certificate type that is sent + */ + public void setCertificateType(InstallCertificateUseEnum certificateType) { + if (!isValidCertificateType(certificateType)) { + throw new PropertyConstraintException(certificateType, "certificateType is invalid"); + } + this.certificateType = certificateType; + } + + /** + * Returns whether the given certificateType is valid + * + * @param certificateType the certificateType to check the validity of + * @return {@code true} if certificateType is valid, {@code false} if not + */ + private boolean isValidCertificateType(InstallCertificateUseEnum certificateType) { + return certificateType != null; + } + + /** + * Gets a PEM encoded X.509 certificate. + * + * @return A PEM encoded X.509 certificate + */ + public String getCertificate() { + return certificate; + } + + /** + * Sets a PEM encoded X.509 certificate. + * + * @param certificate A PEM encoded X.509 certificate + */ + public void setCertificate(String certificate) { + if (!isValidCertificate(certificate)) { + throw new PropertyConstraintException(certificate, "certificate is invalid"); + } + this.certificate = certificate; + } + + /** + * Returns whether the given certificate is valid + * + * @param certificate the certificate to check the validity of + * @return {@code true} if certificate is valid, {@code false} if not + */ + private boolean isValidCertificate(String certificate) { + return certificate != null && certificate.length() <= 5500; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidCertificateType(certificateType) + && isValidCertificate(certificate); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InstallCertificateRequest that = (InstallCertificateRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(certificateType, that.certificateType) + && Objects.equals(certificate, that.certificate); + } + + @Override + public int hashCode() { + return Objects.hash(customData, certificateType, certificate); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("certificateType", certificateType) + .add("certificate", certificate) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/InstallCertificateResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/InstallCertificateResponse.java new file mode 100644 index 000000000..698c3368d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/InstallCertificateResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.InstallCertificateStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * InstallCertificateResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class InstallCertificateResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Charging Station indicates if installation was successful. */ + private InstallCertificateStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the InstallCertificateResponse class + * + * @param status Charging Station indicates if installation was successful. + */ + public InstallCertificateResponse(InstallCertificateStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public InstallCertificateResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets charging Station indicates if installation was successful. + * + * @return Charging Station indicates if installation was successful + */ + public InstallCertificateStatusEnum getStatus() { + return status; + } + + /** + * Sets charging Station indicates if installation was successful. + * + * @param status Charging Station indicates if installation was successful + */ + public void setStatus(InstallCertificateStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(InstallCertificateStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public InstallCertificateResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InstallCertificateResponse that = (InstallCertificateResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/LogStatusNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/LogStatusNotificationRequest.java new file mode 100644 index 000000000..63dd2593e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/LogStatusNotificationRequest.java @@ -0,0 +1,211 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.UploadLogStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * LogStatusNotificationRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class LogStatusNotificationRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The status of the log upload. */ + private UploadLogStatusEnum status; + + /** + * The request id that was provided in GetLogRequest that started this log upload. This field is + * mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no log + * upload ongoing. + */ + @Nullable private Integer requestId; + + /** + * Constructor for the LogStatusNotificationRequest class + * + * @param status The status of the log upload. + */ + public LogStatusNotificationRequest(UploadLogStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public LogStatusNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the status of the log upload. + * + * @return The status of the log upload + */ + public UploadLogStatusEnum getStatus() { + return status; + } + + /** + * Sets the status of the log upload. + * + * @param status The status of the log upload + */ + public void setStatus(UploadLogStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(UploadLogStatusEnum status) { + return status != null; + } + + /** + * Gets the request id that was provided in GetLogRequest that started this log upload. This field + * is mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no log + * upload ongoing. + * + * @return The request id that was provided in GetLogRequest that started this log upload + */ + @Nullable + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the request id that was provided in GetLogRequest that started this log upload. This field + * is mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no log + * upload ongoing. + * + * @param requestId The request id that was provided in GetLogRequest that started this log upload + */ + public void setRequestId(@Nullable Integer requestId) { + this.requestId = requestId; + } + + /** + * Adds the request id that was provided in GetLogRequest that started this log upload. This field + * is mandatory, unless the message was triggered by a TriggerMessageRequest AND there is no log + * upload ongoing. + * + * @param requestId The request id that was provided in GetLogRequest that started this log upload + * @return this + */ + public LogStatusNotificationRequest withRequestId(@Nullable Integer requestId) { + setRequestId(requestId); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogStatusNotificationRequest that = (LogStatusNotificationRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(requestId, that.requestId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, requestId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("requestId", requestId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/LogStatusNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/LogStatusNotificationResponse.java new file mode 100644 index 000000000..99f925cdb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/LogStatusNotificationResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * LogStatusNotificationResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class LogStatusNotificationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the LogStatusNotificationResponse class */ + public LogStatusNotificationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public LogStatusNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogStatusNotificationResponse that = (LogStatusNotificationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/MeterValuesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/MeterValuesRequest.java new file mode 100644 index 000000000..ed9d7c2c7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/MeterValuesRequest.java @@ -0,0 +1,224 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.MeterValue; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Request Body + * + *

OCPP 2.0.1 FINAL + */ +public final class MeterValuesRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Request Body. EVSEID. Numeric Identifier + * + *

A number (greater than 0) designating an EVSE of the Charging Station. ‘0’ (zero) is used to + * designate the main power meter. + */ + private Integer evseId; + + /** + * Meter Value + * + *

Collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + */ + private MeterValue[] meterValue; + + /** + * Constructor for the MeterValuesRequest class + * + * @param evseId A number (greater than 0) designating an EVSE of the Charging Station. ‘0’ (zero) + * is used to designate the main power meter. + * @param meterValue Collection of one or more sampled values in MeterValuesRequest and + * TransactionEvent. All sampled values in a MeterValue are sampled at the same point in time. + */ + public MeterValuesRequest(Integer evseId, MeterValue[] meterValue) { + setEvseId(evseId); + setMeterValue(meterValue); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MeterValuesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets a number (greater than 0) designating an EVSE of the Charging Station. ‘0’ (zero) is used + * to designate the main power meter. + * + * @return A number (greater than 0) designating an EVSE of the Charging Station + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets a number (greater than 0) designating an EVSE of the Charging Station. ‘0’ (zero) is used + * to designate the main power meter. + * + * @param evseId A number (greater than 0) designating an EVSE of the Charging Station + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null; + } + + /** + * Gets collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + * + * @return Collection of one or more sampled values in MeterValuesRequest and TransactionEvent + */ + public MeterValue[] getMeterValue() { + return meterValue; + } + + /** + * Sets collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + * + * @param meterValue Collection of one or more sampled values in MeterValuesRequest and + * TransactionEvent + */ + public void setMeterValue(MeterValue[] meterValue) { + if (!isValidMeterValue(meterValue)) { + throw new PropertyConstraintException(meterValue, "meterValue is invalid"); + } + this.meterValue = meterValue; + } + + /** + * Returns whether the given meterValue is valid + * + * @param meterValue the meterValue to check the validity of + * @return {@code true} if meterValue is valid, {@code false} if not + */ + private boolean isValidMeterValue(MeterValue[] meterValue) { + return meterValue != null + && meterValue.length >= 1 + && Arrays.stream(meterValue).allMatch(item -> item.validate()); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidEvseId(evseId) && isValidMeterValue(meterValue); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MeterValuesRequest that = (MeterValuesRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(evseId, that.evseId) + && Arrays.equals(meterValue, that.meterValue); + } + + @Override + public int hashCode() { + return Objects.hash(customData, evseId, Arrays.hashCode(meterValue)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("evseId", evseId) + .add("meterValue", meterValue) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/MeterValuesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/MeterValuesResponse.java new file mode 100644 index 000000000..5b5b89a9f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/MeterValuesResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * MeterValuesResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class MeterValuesResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the MeterValuesResponse class */ + public MeterValuesResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MeterValuesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MeterValuesResponse that = (MeterValuesResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyChargingLimitRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyChargingLimitRequest.java new file mode 100644 index 000000000..c4aa5b148 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyChargingLimitRequest.java @@ -0,0 +1,273 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ChargingLimit; +import eu.chargetime.ocpp.v201.model.types.ChargingSchedule; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyChargingLimitRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyChargingLimitRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Charging Schedule + * + *

Charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile. + */ + @Nullable private ChargingSchedule[] chargingSchedule; + + /** + * The charging schedule contained in this notification applies to an EVSE. evseId must be greater + * than 0. + */ + @Nullable private Integer evseId; + + /** Charging Limit */ + private ChargingLimit chargingLimit; + + /** + * Constructor for the NotifyChargingLimitRequest class + * + * @param chargingLimit Charging Limit + */ + public NotifyChargingLimitRequest(ChargingLimit chargingLimit) { + setChargingLimit(chargingLimit); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyChargingLimitRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile. + * + * @return Charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile + */ + @Nullable + public ChargingSchedule[] getChargingSchedule() { + return chargingSchedule; + } + + /** + * Sets charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile. + * + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: GetCompositeSchedule.conf and ChargingProfile + */ + public void setChargingSchedule(@Nullable ChargingSchedule[] chargingSchedule) { + if (!isValidChargingSchedule(chargingSchedule)) { + throw new PropertyConstraintException(chargingSchedule, "chargingSchedule is invalid"); + } + this.chargingSchedule = chargingSchedule; + } + + /** + * Returns whether the given chargingSchedule is valid + * + * @param chargingSchedule the chargingSchedule to check the validity of + * @return {@code true} if chargingSchedule is valid, {@code false} if not + */ + private boolean isValidChargingSchedule(@Nullable ChargingSchedule[] chargingSchedule) { + return chargingSchedule == null + || (chargingSchedule.length >= 1 + && Arrays.stream(chargingSchedule).allMatch(item -> item.validate())); + } + + /** + * Adds charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile. + * + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: GetCompositeSchedule.conf and ChargingProfile + * @return this + */ + public NotifyChargingLimitRequest withChargingSchedule( + @Nullable ChargingSchedule[] chargingSchedule) { + setChargingSchedule(chargingSchedule); + return this; + } + + /** + * Gets the charging schedule contained in this notification applies to an EVSE. evseId must be + * greater than 0. + * + * @return The charging schedule contained in this notification applies to an EVSE + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the charging schedule contained in this notification applies to an EVSE. evseId must be + * greater than 0. + * + * @param evseId The charging schedule contained in this notification applies to an EVSE + */ + public void setEvseId(@Nullable Integer evseId) { + this.evseId = evseId; + } + + /** + * Adds the charging schedule contained in this notification applies to an EVSE. evseId must be + * greater than 0. + * + * @param evseId The charging schedule contained in this notification applies to an EVSE + * @return this + */ + public NotifyChargingLimitRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets charging Limit + * + * @return Charging Limit + */ + public ChargingLimit getChargingLimit() { + return chargingLimit; + } + + /** + * Sets charging Limit + * + * @param chargingLimit Charging Limit + */ + public void setChargingLimit(ChargingLimit chargingLimit) { + if (!isValidChargingLimit(chargingLimit)) { + throw new PropertyConstraintException(chargingLimit, "chargingLimit is invalid"); + } + this.chargingLimit = chargingLimit; + } + + /** + * Returns whether the given chargingLimit is valid + * + * @param chargingLimit the chargingLimit to check the validity of + * @return {@code true} if chargingLimit is valid, {@code false} if not + */ + private boolean isValidChargingLimit(ChargingLimit chargingLimit) { + return chargingLimit != null && chargingLimit.validate(); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidChargingSchedule(chargingSchedule) + && isValidChargingLimit(chargingLimit); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyChargingLimitRequest that = (NotifyChargingLimitRequest) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(chargingSchedule, that.chargingSchedule) + && Objects.equals(evseId, that.evseId) + && Objects.equals(chargingLimit, that.chargingLimit); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(chargingSchedule), evseId, chargingLimit); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("chargingSchedule", chargingSchedule) + .add("evseId", evseId) + .add("chargingLimit", chargingLimit) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyChargingLimitResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyChargingLimitResponse.java new file mode 100644 index 000000000..195a0f307 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyChargingLimitResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyChargingLimitResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyChargingLimitResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyChargingLimitResponse class */ + public NotifyChargingLimitResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyChargingLimitResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyChargingLimitResponse that = (NotifyChargingLimitResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyCustomerInformationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyCustomerInformationRequest.java new file mode 100644 index 000000000..10993eb24 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyCustomerInformationRequest.java @@ -0,0 +1,331 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyCustomerInformationRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyCustomerInformationRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * (Part of) the requested data. No format specified in which the data is returned. Should be + * human readable. + */ + private String data; + + /** + * “to be continued” indicator. Indicates whether another part of the monitoringData follows in an + * upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + */ + @Nullable private Boolean tbc; + + /** Sequence number of this message. First message starts at 0. */ + private Integer seqNo; + + /** Timestamp of the moment this message was generated at the Charging Station. */ + private ZonedDateTime generatedAt; + + /** The Id of the request. */ + private Integer requestId; + + /** + * Constructor for the NotifyCustomerInformationRequest class + * + * @param data (Part of) the requested data. No format specified in which the data is returned. + * Should be human readable. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param requestId The Id of the request. + */ + public NotifyCustomerInformationRequest( + String data, Integer seqNo, ZonedDateTime generatedAt, Integer requestId) { + setData(data); + setSeqNo(seqNo); + setGeneratedAt(generatedAt); + setRequestId(requestId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyCustomerInformationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets (Part of) the requested data. No format specified in which the data is returned. Should be + * human readable. + * + * @return (Part of) the requested data + */ + public String getData() { + return data; + } + + /** + * Sets (Part of) the requested data. No format specified in which the data is returned. Should be + * human readable. + * + * @param data (Part of) the requested data + */ + public void setData(String data) { + if (!isValidData(data)) { + throw new PropertyConstraintException(data, "data is invalid"); + } + this.data = data; + } + + /** + * Returns whether the given data is valid + * + * @param data the data to check the validity of + * @return {@code true} if data is valid, {@code false} if not + */ + private boolean isValidData(String data) { + return data != null && data.length() <= 512; + } + + /** + * Gets “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @return “to be continued” indicator + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + * @return this + */ + public NotifyCustomerInformationRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets sequence number of this message. First message starts at 0. + * + * @return Sequence number of this message + */ + public Integer getSeqNo() { + return seqNo; + } + + /** + * Sets sequence number of this message. First message starts at 0. + * + * @param seqNo Sequence number of this message + */ + public void setSeqNo(Integer seqNo) { + if (!isValidSeqNo(seqNo)) { + throw new PropertyConstraintException(seqNo, "seqNo is invalid"); + } + this.seqNo = seqNo; + } + + /** + * Returns whether the given seqNo is valid + * + * @param seqNo the seqNo to check the validity of + * @return {@code true} if seqNo is valid, {@code false} if not + */ + private boolean isValidSeqNo(Integer seqNo) { + return seqNo != null; + } + + /** + * Gets timestamp of the moment this message was generated at the Charging Station. + * + * @return Timestamp of the moment this message was generated at the Charging Station + */ + public ZonedDateTime getGeneratedAt() { + return generatedAt; + } + + /** + * Sets timestamp of the moment this message was generated at the Charging Station. + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station + */ + public void setGeneratedAt(ZonedDateTime generatedAt) { + if (!isValidGeneratedAt(generatedAt)) { + throw new PropertyConstraintException(generatedAt, "generatedAt is invalid"); + } + this.generatedAt = generatedAt; + } + + /** + * Returns whether the given generatedAt is valid + * + * @param generatedAt the generatedAt to check the validity of + * @return {@code true} if generatedAt is valid, {@code false} if not + */ + private boolean isValidGeneratedAt(ZonedDateTime generatedAt) { + return generatedAt != null; + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidData(data) + && isValidSeqNo(seqNo) + && isValidGeneratedAt(generatedAt) + && isValidRequestId(requestId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyCustomerInformationRequest that = (NotifyCustomerInformationRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(data, that.data) + && Objects.equals(tbc, that.tbc) + && Objects.equals(seqNo, that.seqNo) + && Objects.equals(generatedAt, that.generatedAt) + && Objects.equals(requestId, that.requestId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, data, tbc, seqNo, generatedAt, requestId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("data", data) + .add("tbc", tbc) + .add("seqNo", seqNo) + .add("generatedAt", generatedAt) + .add("requestId", requestId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyCustomerInformationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyCustomerInformationResponse.java new file mode 100644 index 000000000..afbd035a6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyCustomerInformationResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyCustomerInformationResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyCustomerInformationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyCustomerInformationResponse class */ + public NotifyCustomerInformationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyCustomerInformationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyCustomerInformationResponse that = (NotifyCustomerInformationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyDisplayMessagesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyDisplayMessagesRequest.java new file mode 100644 index 000000000..64d30b7ae --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyDisplayMessagesRequest.java @@ -0,0 +1,263 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.MessageInfo; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyDisplayMessagesRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyDisplayMessagesRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Message Info + * + *

Message details, for a message to be displayed on a Charging Station. + */ + @Nullable private MessageInfo[] messageInfo; + + /** The id of the GetDisplayMessagesRequest that requested this message. */ + private Integer requestId; + + /** + * "to be continued" indicator. Indicates whether another part of the report follows in an + * upcoming NotifyDisplayMessagesRequest message. Default value when omitted is false. + */ + @Nullable private Boolean tbc; + + /** + * Constructor for the NotifyDisplayMessagesRequest class + * + * @param requestId The id of the GetDisplayMessagesRequest that requested this message. + */ + public NotifyDisplayMessagesRequest(Integer requestId) { + setRequestId(requestId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyDisplayMessagesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + @Nullable + public MessageInfo[] getMessageInfo() { + return messageInfo; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param messageInfo Message details, for a message to be displayed on a Charging Station + */ + public void setMessageInfo(@Nullable MessageInfo[] messageInfo) { + if (!isValidMessageInfo(messageInfo)) { + throw new PropertyConstraintException(messageInfo, "messageInfo is invalid"); + } + this.messageInfo = messageInfo; + } + + /** + * Returns whether the given messageInfo is valid + * + * @param messageInfo the messageInfo to check the validity of + * @return {@code true} if messageInfo is valid, {@code false} if not + */ + private boolean isValidMessageInfo(@Nullable MessageInfo[] messageInfo) { + return messageInfo == null + || (messageInfo.length >= 1 + && Arrays.stream(messageInfo).allMatch(item -> item.validate())); + } + + /** + * Adds message details, for a message to be displayed on a Charging Station. + * + * @param messageInfo Message details, for a message to be displayed on a Charging Station + * @return this + */ + public NotifyDisplayMessagesRequest withMessageInfo(@Nullable MessageInfo[] messageInfo) { + setMessageInfo(messageInfo); + return this; + } + + /** + * Gets the id of the GetDisplayMessagesRequest that requested this message. + * + * @return The id of the GetDisplayMessagesRequest that requested this message + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the id of the GetDisplayMessagesRequest that requested this message. + * + * @param requestId The id of the GetDisplayMessagesRequest that requested this message + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets "to be continued" indicator. Indicates whether another part of the report follows in an + * upcoming NotifyDisplayMessagesRequest message. Default value when omitted is false. + * + * @return "to be continued" indicator + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets "to be continued" indicator. Indicates whether another part of the report follows in an + * upcoming NotifyDisplayMessagesRequest message. Default value when omitted is false. + * + * @param tbc "to be continued" indicator + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds "to be continued" indicator. Indicates whether another part of the report follows in an + * upcoming NotifyDisplayMessagesRequest message. Default value when omitted is false. + * + * @param tbc "to be continued" indicator + * @return this + */ + public NotifyDisplayMessagesRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidMessageInfo(messageInfo) + && isValidRequestId(requestId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyDisplayMessagesRequest that = (NotifyDisplayMessagesRequest) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(messageInfo, that.messageInfo) + && Objects.equals(requestId, that.requestId) + && Objects.equals(tbc, that.tbc); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(messageInfo), requestId, tbc); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("messageInfo", messageInfo) + .add("requestId", requestId) + .add("tbc", tbc) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyDisplayMessagesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyDisplayMessagesResponse.java new file mode 100644 index 000000000..efc9f989d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyDisplayMessagesResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyDisplayMessagesResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyDisplayMessagesResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyDisplayMessagesResponse class */ + public NotifyDisplayMessagesResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyDisplayMessagesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyDisplayMessagesResponse that = (NotifyDisplayMessagesResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingNeedsRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingNeedsRequest.java new file mode 100644 index 000000000..262e9d72b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingNeedsRequest.java @@ -0,0 +1,241 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ChargingNeeds; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEVChargingNeedsRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyEVChargingNeedsRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The maximum schedule tuples the car supports per schedule. */ + @Nullable private Integer maxScheduleTuples; + + /** Charging Needs */ + private ChargingNeeds chargingNeeds; + + /** The EVSE and connector to which the EV is connected. EvseId may not be 0. */ + private Integer evseId; + + /** + * Constructor for the NotifyEVChargingNeedsRequest class + * + * @param chargingNeeds Charging Needs + * @param evseId The EVSE and connector to which the EV is connected. EvseId may not be 0. + */ + public NotifyEVChargingNeedsRequest(ChargingNeeds chargingNeeds, Integer evseId) { + setChargingNeeds(chargingNeeds); + setEvseId(evseId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEVChargingNeedsRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the maximum schedule tuples the car supports per schedule. + * + * @return The maximum schedule tuples the car supports per schedule + */ + @Nullable + public Integer getMaxScheduleTuples() { + return maxScheduleTuples; + } + + /** + * Sets the maximum schedule tuples the car supports per schedule. + * + * @param maxScheduleTuples The maximum schedule tuples the car supports per schedule + */ + public void setMaxScheduleTuples(@Nullable Integer maxScheduleTuples) { + this.maxScheduleTuples = maxScheduleTuples; + } + + /** + * Adds the maximum schedule tuples the car supports per schedule. + * + * @param maxScheduleTuples The maximum schedule tuples the car supports per schedule + * @return this + */ + public NotifyEVChargingNeedsRequest withMaxScheduleTuples(@Nullable Integer maxScheduleTuples) { + setMaxScheduleTuples(maxScheduleTuples); + return this; + } + + /** + * Gets charging Needs + * + * @return Charging Needs + */ + public ChargingNeeds getChargingNeeds() { + return chargingNeeds; + } + + /** + * Sets charging Needs + * + * @param chargingNeeds Charging Needs + */ + public void setChargingNeeds(ChargingNeeds chargingNeeds) { + if (!isValidChargingNeeds(chargingNeeds)) { + throw new PropertyConstraintException(chargingNeeds, "chargingNeeds is invalid"); + } + this.chargingNeeds = chargingNeeds; + } + + /** + * Returns whether the given chargingNeeds is valid + * + * @param chargingNeeds the chargingNeeds to check the validity of + * @return {@code true} if chargingNeeds is valid, {@code false} if not + */ + private boolean isValidChargingNeeds(ChargingNeeds chargingNeeds) { + return chargingNeeds != null && chargingNeeds.validate(); + } + + /** + * Gets the EVSE and connector to which the EV is connected. EvseId may not be 0. + * + * @return The EVSE and connector to which the EV is connected + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the EVSE and connector to which the EV is connected. EvseId may not be 0. + * + * @param evseId The EVSE and connector to which the EV is connected + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidChargingNeeds(chargingNeeds) + && isValidEvseId(evseId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEVChargingNeedsRequest that = (NotifyEVChargingNeedsRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(maxScheduleTuples, that.maxScheduleTuples) + && Objects.equals(chargingNeeds, that.chargingNeeds) + && Objects.equals(evseId, that.evseId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, maxScheduleTuples, chargingNeeds, evseId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("maxScheduleTuples", maxScheduleTuples) + .add("chargingNeeds", chargingNeeds) + .add("evseId", evseId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingNeedsResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingNeedsResponse.java new file mode 100644 index 000000000..1c4f646f8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingNeedsResponse.java @@ -0,0 +1,216 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.NotifyEVChargingNeedsStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEVChargingNeedsResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyEVChargingNeedsResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Returns whether the CSMS has been able to process the message successfully. It does not imply + * that the evChargingNeeds can be met with the current charging profile. + */ + private NotifyEVChargingNeedsStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the NotifyEVChargingNeedsResponse class + * + * @param status Returns whether the CSMS has been able to process the message successfully. It + * does not imply that the evChargingNeeds can be met with the current charging profile. + */ + public NotifyEVChargingNeedsResponse(NotifyEVChargingNeedsStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEVChargingNeedsResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets returns whether the CSMS has been able to process the message successfully. It does not + * imply that the evChargingNeeds can be met with the current charging profile. + * + * @return Returns whether the CSMS has been able to process the message successfully + */ + public NotifyEVChargingNeedsStatusEnum getStatus() { + return status; + } + + /** + * Sets returns whether the CSMS has been able to process the message successfully. It does not + * imply that the evChargingNeeds can be met with the current charging profile. + * + * @param status Returns whether the CSMS has been able to process the message successfully + */ + public void setStatus(NotifyEVChargingNeedsStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(NotifyEVChargingNeedsStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public NotifyEVChargingNeedsResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEVChargingNeedsResponse that = (NotifyEVChargingNeedsResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingScheduleRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingScheduleRequest.java new file mode 100644 index 000000000..382ad7a4c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingScheduleRequest.java @@ -0,0 +1,263 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ChargingSchedule; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEVChargingScheduleRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyEVChargingScheduleRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Periods contained in the charging profile are relative to this point in time. */ + private ZonedDateTime timeBase; + + /** + * Charging Schedule + * + *

Charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile. + */ + private ChargingSchedule chargingSchedule; + + /** + * The charging schedule contained in this notification applies to an EVSE. EvseId must be greater + * than 0. + */ + private Integer evseId; + + /** + * Constructor for the NotifyEVChargingScheduleRequest class + * + * @param timeBase Periods contained in the charging profile are relative to this point in time. + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: GetCompositeSchedule.conf and ChargingProfile. + * @param evseId The charging schedule contained in this notification applies to an EVSE. EvseId + * must be greater than 0. + */ + public NotifyEVChargingScheduleRequest( + ZonedDateTime timeBase, ChargingSchedule chargingSchedule, Integer evseId) { + setTimeBase(timeBase); + setChargingSchedule(chargingSchedule); + setEvseId(evseId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEVChargingScheduleRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets periods contained in the charging profile are relative to this point in time. + * + * @return Periods contained in the charging profile are relative to this point in time + */ + public ZonedDateTime getTimeBase() { + return timeBase; + } + + /** + * Sets periods contained in the charging profile are relative to this point in time. + * + * @param timeBase Periods contained in the charging profile are relative to this point in time + */ + public void setTimeBase(ZonedDateTime timeBase) { + if (!isValidTimeBase(timeBase)) { + throw new PropertyConstraintException(timeBase, "timeBase is invalid"); + } + this.timeBase = timeBase; + } + + /** + * Returns whether the given timeBase is valid + * + * @param timeBase the timeBase to check the validity of + * @return {@code true} if timeBase is valid, {@code false} if not + */ + private boolean isValidTimeBase(ZonedDateTime timeBase) { + return timeBase != null; + } + + /** + * Gets charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile. + * + * @return Charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile + */ + public ChargingSchedule getChargingSchedule() { + return chargingSchedule; + } + + /** + * Sets charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile. + * + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: GetCompositeSchedule.conf and ChargingProfile + */ + public void setChargingSchedule(ChargingSchedule chargingSchedule) { + if (!isValidChargingSchedule(chargingSchedule)) { + throw new PropertyConstraintException(chargingSchedule, "chargingSchedule is invalid"); + } + this.chargingSchedule = chargingSchedule; + } + + /** + * Returns whether the given chargingSchedule is valid + * + * @param chargingSchedule the chargingSchedule to check the validity of + * @return {@code true} if chargingSchedule is valid, {@code false} if not + */ + private boolean isValidChargingSchedule(ChargingSchedule chargingSchedule) { + return chargingSchedule != null && chargingSchedule.validate(); + } + + /** + * Gets the charging schedule contained in this notification applies to an EVSE. EvseId must be + * greater than 0. + * + * @return The charging schedule contained in this notification applies to an EVSE + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the charging schedule contained in this notification applies to an EVSE. EvseId must be + * greater than 0. + * + * @param evseId The charging schedule contained in this notification applies to an EVSE + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidTimeBase(timeBase) + && isValidChargingSchedule(chargingSchedule) + && isValidEvseId(evseId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEVChargingScheduleRequest that = (NotifyEVChargingScheduleRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(timeBase, that.timeBase) + && Objects.equals(chargingSchedule, that.chargingSchedule) + && Objects.equals(evseId, that.evseId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, timeBase, chargingSchedule, evseId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("timeBase", timeBase) + .add("chargingSchedule", chargingSchedule) + .add("evseId", evseId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingScheduleResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingScheduleResponse.java new file mode 100644 index 000000000..8be818fc5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEVChargingScheduleResponse.java @@ -0,0 +1,216 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEVChargingScheduleResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyEVChargingScheduleResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Returns whether the CSMS has been able to process the message successfully. It does not imply + * any approval of the charging schedule. + */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the NotifyEVChargingScheduleResponse class + * + * @param status Returns whether the CSMS has been able to process the message successfully. It + * does not imply any approval of the charging schedule. + */ + public NotifyEVChargingScheduleResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEVChargingScheduleResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets returns whether the CSMS has been able to process the message successfully. It does not + * imply any approval of the charging schedule. + * + * @return Returns whether the CSMS has been able to process the message successfully + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets returns whether the CSMS has been able to process the message successfully. It does not + * imply any approval of the charging schedule. + * + * @param status Returns whether the CSMS has been able to process the message successfully + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public NotifyEVChargingScheduleResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEVChargingScheduleResponse that = (NotifyEVChargingScheduleResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEventRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEventRequest.java new file mode 100644 index 000000000..b8b4e9934 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEventRequest.java @@ -0,0 +1,289 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.EventData; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEventRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyEventRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Timestamp of the moment this message was generated at the Charging Station. */ + private ZonedDateTime generatedAt; + + /** + * “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyEventRequest message. Default value when omitted is false. + */ + @Nullable private Boolean tbc; + + /** Sequence number of this message. First message starts at 0. */ + private Integer seqNo; + + /** Class to report an event notification for a component-variable. */ + private EventData[] eventData; + + /** + * Constructor for the NotifyEventRequest class + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param eventData Class to report an event notification for a component-variable. + */ + public NotifyEventRequest(ZonedDateTime generatedAt, Integer seqNo, EventData[] eventData) { + setGeneratedAt(generatedAt); + setSeqNo(seqNo); + setEventData(eventData); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEventRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets timestamp of the moment this message was generated at the Charging Station. + * + * @return Timestamp of the moment this message was generated at the Charging Station + */ + public ZonedDateTime getGeneratedAt() { + return generatedAt; + } + + /** + * Sets timestamp of the moment this message was generated at the Charging Station. + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station + */ + public void setGeneratedAt(ZonedDateTime generatedAt) { + if (!isValidGeneratedAt(generatedAt)) { + throw new PropertyConstraintException(generatedAt, "generatedAt is invalid"); + } + this.generatedAt = generatedAt; + } + + /** + * Returns whether the given generatedAt is valid + * + * @param generatedAt the generatedAt to check the validity of + * @return {@code true} if generatedAt is valid, {@code false} if not + */ + private boolean isValidGeneratedAt(ZonedDateTime generatedAt) { + return generatedAt != null; + } + + /** + * Gets “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyEventRequest message. Default value when omitted is false. + * + * @return “to be continued” indicator + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyEventRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyEventRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + * @return this + */ + public NotifyEventRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets sequence number of this message. First message starts at 0. + * + * @return Sequence number of this message + */ + public Integer getSeqNo() { + return seqNo; + } + + /** + * Sets sequence number of this message. First message starts at 0. + * + * @param seqNo Sequence number of this message + */ + public void setSeqNo(Integer seqNo) { + if (!isValidSeqNo(seqNo)) { + throw new PropertyConstraintException(seqNo, "seqNo is invalid"); + } + this.seqNo = seqNo; + } + + /** + * Returns whether the given seqNo is valid + * + * @param seqNo the seqNo to check the validity of + * @return {@code true} if seqNo is valid, {@code false} if not + */ + private boolean isValidSeqNo(Integer seqNo) { + return seqNo != null; + } + + /** + * Gets class to report an event notification for a component-variable. + * + * @return Class to report an event notification for a component-variable + */ + public EventData[] getEventData() { + return eventData; + } + + /** + * Sets class to report an event notification for a component-variable. + * + * @param eventData Class to report an event notification for a component-variable + */ + public void setEventData(EventData[] eventData) { + if (!isValidEventData(eventData)) { + throw new PropertyConstraintException(eventData, "eventData is invalid"); + } + this.eventData = eventData; + } + + /** + * Returns whether the given eventData is valid + * + * @param eventData the eventData to check the validity of + * @return {@code true} if eventData is valid, {@code false} if not + */ + private boolean isValidEventData(EventData[] eventData) { + return eventData != null + && eventData.length >= 1 + && Arrays.stream(eventData).allMatch(item -> item.validate()); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidGeneratedAt(generatedAt) + && isValidSeqNo(seqNo) + && isValidEventData(eventData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEventRequest that = (NotifyEventRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(generatedAt, that.generatedAt) + && Objects.equals(tbc, that.tbc) + && Objects.equals(seqNo, that.seqNo) + && Arrays.equals(eventData, that.eventData); + } + + @Override + public int hashCode() { + return Objects.hash(customData, generatedAt, tbc, seqNo, Arrays.hashCode(eventData)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("generatedAt", generatedAt) + .add("tbc", tbc) + .add("seqNo", seqNo) + .add("eventData", eventData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEventResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEventResponse.java new file mode 100644 index 000000000..e2de921da --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyEventResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyEventResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyEventResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyEventResponse class */ + public NotifyEventResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyEventResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyEventResponse that = (NotifyEventResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyMonitoringReportRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyMonitoringReportRequest.java new file mode 100644 index 000000000..192fa30d3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyMonitoringReportRequest.java @@ -0,0 +1,338 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.MonitoringData; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyMonitoringReportRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyMonitoringReportRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Class to hold parameters of SetVariableMonitoring request. */ + @Nullable private MonitoringData[] monitor; + + /** The id of the GetMonitoringRequest that requested this report. */ + private Integer requestId; + + /** + * “to be continued” indicator. Indicates whether another part of the monitoringData follows in an + * upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + */ + @Nullable private Boolean tbc; + + /** Sequence number of this message. First message starts at 0. */ + private Integer seqNo; + + /** Timestamp of the moment this message was generated at the Charging Station. */ + private ZonedDateTime generatedAt; + + /** + * Constructor for the NotifyMonitoringReportRequest class + * + * @param requestId The id of the GetMonitoringRequest that requested this report. + * @param seqNo Sequence number of this message. First message starts at 0. + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + */ + public NotifyMonitoringReportRequest( + Integer requestId, Integer seqNo, ZonedDateTime generatedAt) { + setRequestId(requestId); + setSeqNo(seqNo); + setGeneratedAt(generatedAt); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyMonitoringReportRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets class to hold parameters of SetVariableMonitoring request. + * + * @return Class to hold parameters of SetVariableMonitoring request + */ + @Nullable + public MonitoringData[] getMonitor() { + return monitor; + } + + /** + * Sets class to hold parameters of SetVariableMonitoring request. + * + * @param monitor Class to hold parameters of SetVariableMonitoring request + */ + public void setMonitor(@Nullable MonitoringData[] monitor) { + if (!isValidMonitor(monitor)) { + throw new PropertyConstraintException(monitor, "monitor is invalid"); + } + this.monitor = monitor; + } + + /** + * Returns whether the given monitor is valid + * + * @param monitor the monitor to check the validity of + * @return {@code true} if monitor is valid, {@code false} if not + */ + private boolean isValidMonitor(@Nullable MonitoringData[] monitor) { + return monitor == null + || (monitor.length >= 1 && Arrays.stream(monitor).allMatch(item -> item.validate())); + } + + /** + * Adds class to hold parameters of SetVariableMonitoring request. + * + * @param monitor Class to hold parameters of SetVariableMonitoring request + * @return this + */ + public NotifyMonitoringReportRequest withMonitor(@Nullable MonitoringData[] monitor) { + setMonitor(monitor); + return this; + } + + /** + * Gets the id of the GetMonitoringRequest that requested this report. + * + * @return The id of the GetMonitoringRequest that requested this report + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the id of the GetMonitoringRequest that requested this report. + * + * @param requestId The id of the GetMonitoringRequest that requested this report + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @return “to be continued” indicator + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds “to be continued” indicator. Indicates whether another part of the monitoringData follows + * in an upcoming notifyMonitoringReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + * @return this + */ + public NotifyMonitoringReportRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets sequence number of this message. First message starts at 0. + * + * @return Sequence number of this message + */ + public Integer getSeqNo() { + return seqNo; + } + + /** + * Sets sequence number of this message. First message starts at 0. + * + * @param seqNo Sequence number of this message + */ + public void setSeqNo(Integer seqNo) { + if (!isValidSeqNo(seqNo)) { + throw new PropertyConstraintException(seqNo, "seqNo is invalid"); + } + this.seqNo = seqNo; + } + + /** + * Returns whether the given seqNo is valid + * + * @param seqNo the seqNo to check the validity of + * @return {@code true} if seqNo is valid, {@code false} if not + */ + private boolean isValidSeqNo(Integer seqNo) { + return seqNo != null; + } + + /** + * Gets timestamp of the moment this message was generated at the Charging Station. + * + * @return Timestamp of the moment this message was generated at the Charging Station + */ + public ZonedDateTime getGeneratedAt() { + return generatedAt; + } + + /** + * Sets timestamp of the moment this message was generated at the Charging Station. + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station + */ + public void setGeneratedAt(ZonedDateTime generatedAt) { + if (!isValidGeneratedAt(generatedAt)) { + throw new PropertyConstraintException(generatedAt, "generatedAt is invalid"); + } + this.generatedAt = generatedAt; + } + + /** + * Returns whether the given generatedAt is valid + * + * @param generatedAt the generatedAt to check the validity of + * @return {@code true} if generatedAt is valid, {@code false} if not + */ + private boolean isValidGeneratedAt(ZonedDateTime generatedAt) { + return generatedAt != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidMonitor(monitor) + && isValidRequestId(requestId) + && isValidSeqNo(seqNo) + && isValidGeneratedAt(generatedAt); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyMonitoringReportRequest that = (NotifyMonitoringReportRequest) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(monitor, that.monitor) + && Objects.equals(requestId, that.requestId) + && Objects.equals(tbc, that.tbc) + && Objects.equals(seqNo, that.seqNo) + && Objects.equals(generatedAt, that.generatedAt); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(monitor), requestId, tbc, seqNo, generatedAt); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("monitor", monitor) + .add("requestId", requestId) + .add("tbc", tbc) + .add("seqNo", seqNo) + .add("generatedAt", generatedAt) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyMonitoringReportResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyMonitoringReportResponse.java new file mode 100644 index 000000000..90325f8d1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyMonitoringReportResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyMonitoringReportResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyMonitoringReportResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyMonitoringReportResponse class */ + public NotifyMonitoringReportResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyMonitoringReportResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyMonitoringReportResponse that = (NotifyMonitoringReportResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyReportRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyReportRequest.java new file mode 100644 index 000000000..86f396848 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyReportRequest.java @@ -0,0 +1,342 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.ReportData; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyReportRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyReportRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The id of the GetReportRequest or GetBaseReportRequest that requested this report */ + private Integer requestId; + + /** Timestamp of the moment this message was generated at the Charging Station. */ + private ZonedDateTime generatedAt; + + /** Class to report components, variables and variable attributes and characteristics. */ + @Nullable private ReportData[] reportData; + + /** + * “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyReportRequest message. Default value when omitted is false. + */ + @Nullable private Boolean tbc; + + /** Sequence number of this message. First message starts at 0. */ + private Integer seqNo; + + /** + * Constructor for the NotifyReportRequest class + * + * @param requestId The id of the GetReportRequest or GetBaseReportRequest that requested this + * report + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station. + * @param seqNo Sequence number of this message. First message starts at 0. + */ + public NotifyReportRequest(Integer requestId, ZonedDateTime generatedAt, Integer seqNo) { + setRequestId(requestId); + setGeneratedAt(generatedAt); + setSeqNo(seqNo); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyReportRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the id of the GetReportRequest or GetBaseReportRequest that requested this report + * + * @return The id of the GetReportRequest or GetBaseReportRequest that requested this report + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the id of the GetReportRequest or GetBaseReportRequest that requested this report + * + * @param requestId The id of the GetReportRequest or GetBaseReportRequest that requested this + * report + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets timestamp of the moment this message was generated at the Charging Station. + * + * @return Timestamp of the moment this message was generated at the Charging Station + */ + public ZonedDateTime getGeneratedAt() { + return generatedAt; + } + + /** + * Sets timestamp of the moment this message was generated at the Charging Station. + * + * @param generatedAt Timestamp of the moment this message was generated at the Charging Station + */ + public void setGeneratedAt(ZonedDateTime generatedAt) { + if (!isValidGeneratedAt(generatedAt)) { + throw new PropertyConstraintException(generatedAt, "generatedAt is invalid"); + } + this.generatedAt = generatedAt; + } + + /** + * Returns whether the given generatedAt is valid + * + * @param generatedAt the generatedAt to check the validity of + * @return {@code true} if generatedAt is valid, {@code false} if not + */ + private boolean isValidGeneratedAt(ZonedDateTime generatedAt) { + return generatedAt != null; + } + + /** + * Gets class to report components, variables and variable attributes and characteristics. + * + * @return Class to report components, variables and variable attributes and characteristics + */ + @Nullable + public ReportData[] getReportData() { + return reportData; + } + + /** + * Sets class to report components, variables and variable attributes and characteristics. + * + * @param reportData Class to report components, variables and variable attributes and + * characteristics + */ + public void setReportData(@Nullable ReportData[] reportData) { + if (!isValidReportData(reportData)) { + throw new PropertyConstraintException(reportData, "reportData is invalid"); + } + this.reportData = reportData; + } + + /** + * Returns whether the given reportData is valid + * + * @param reportData the reportData to check the validity of + * @return {@code true} if reportData is valid, {@code false} if not + */ + private boolean isValidReportData(@Nullable ReportData[] reportData) { + return reportData == null + || (reportData.length >= 1 && Arrays.stream(reportData).allMatch(item -> item.validate())); + } + + /** + * Adds class to report components, variables and variable attributes and characteristics. + * + * @param reportData Class to report components, variables and variable attributes and + * characteristics + * @return this + */ + public NotifyReportRequest withReportData(@Nullable ReportData[] reportData) { + setReportData(reportData); + return this; + } + + /** + * Gets “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyReportRequest message. Default value when omitted is false. + * + * @return “to be continued” indicator + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds “to be continued” indicator. Indicates whether another part of the report follows in an + * upcoming notifyReportRequest message. Default value when omitted is false. + * + * @param tbc “to be continued” indicator + * @return this + */ + public NotifyReportRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets sequence number of this message. First message starts at 0. + * + * @return Sequence number of this message + */ + public Integer getSeqNo() { + return seqNo; + } + + /** + * Sets sequence number of this message. First message starts at 0. + * + * @param seqNo Sequence number of this message + */ + public void setSeqNo(Integer seqNo) { + if (!isValidSeqNo(seqNo)) { + throw new PropertyConstraintException(seqNo, "seqNo is invalid"); + } + this.seqNo = seqNo; + } + + /** + * Returns whether the given seqNo is valid + * + * @param seqNo the seqNo to check the validity of + * @return {@code true} if seqNo is valid, {@code false} if not + */ + private boolean isValidSeqNo(Integer seqNo) { + return seqNo != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidRequestId(requestId) + && isValidGeneratedAt(generatedAt) + && isValidReportData(reportData) + && isValidSeqNo(seqNo); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyReportRequest that = (NotifyReportRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(requestId, that.requestId) + && Objects.equals(generatedAt, that.generatedAt) + && Arrays.equals(reportData, that.reportData) + && Objects.equals(tbc, that.tbc) + && Objects.equals(seqNo, that.seqNo); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, requestId, generatedAt, Arrays.hashCode(reportData), tbc, seqNo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("requestId", requestId) + .add("generatedAt", generatedAt) + .add("reportData", reportData) + .add("tbc", tbc) + .add("seqNo", seqNo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyReportResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyReportResponse.java new file mode 100644 index 000000000..7538a41da --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/NotifyReportResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * NotifyReportResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class NotifyReportResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the NotifyReportResponse class */ + public NotifyReportResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NotifyReportResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotifyReportResponse that = (NotifyReportResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareRequest.java new file mode 100644 index 000000000..03655c7f4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareRequest.java @@ -0,0 +1,336 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * PublishFirmwareRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class PublishFirmwareRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** A string containing a URI pointing to a location from which to retrieve the firmware. */ + private String location; + + /** + * How many times Charging Station must try to download the firmware before giving up. If this + * field is not present, it is left to Charging Station to decide how many times it wants to + * retry. + */ + @Nullable private Integer retries; + + /** The MD5 checksum over the entire firmware file as a hexadecimal string of length 32. */ + private String checksum; + + /** The Id of the request. */ + private Integer requestId; + + /** + * The interval in seconds after which a retry may be attempted. If this field is not present, it + * is left to Charging Station to decide how long to wait between attempts. + */ + @Nullable private Integer retryInterval; + + /** + * Constructor for the PublishFirmwareRequest class + * + * @param location A string containing a URI pointing to a location from which to retrieve the + * firmware. + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32. + * @param requestId The Id of the request. + */ + public PublishFirmwareRequest(String location, String checksum, Integer requestId) { + setLocation(location); + setChecksum(checksum); + setRequestId(requestId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PublishFirmwareRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets a string containing a URI pointing to a location from which to retrieve the firmware. + * + * @return A string containing a URI pointing to a location from which to retrieve the firmware + */ + public String getLocation() { + return location; + } + + /** + * Sets a string containing a URI pointing to a location from which to retrieve the firmware. + * + * @param location A string containing a URI pointing to a location from which to retrieve the + * firmware + */ + public void setLocation(String location) { + if (!isValidLocation(location)) { + throw new PropertyConstraintException(location, "location is invalid"); + } + this.location = location; + } + + /** + * Returns whether the given location is valid + * + * @param location the location to check the validity of + * @return {@code true} if location is valid, {@code false} if not + */ + private boolean isValidLocation(String location) { + return location != null && location.length() <= 512; + } + + /** + * Gets how many times Charging Station must try to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. + * + * @return How many times Charging Station must try to download the firmware before giving up + */ + @Nullable + public Integer getRetries() { + return retries; + } + + /** + * Sets how many times Charging Station must try to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. + * + * @param retries How many times Charging Station must try to download the firmware before giving + * up + */ + public void setRetries(@Nullable Integer retries) { + this.retries = retries; + } + + /** + * Adds how many times Charging Station must try to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. + * + * @param retries How many times Charging Station must try to download the firmware before giving + * up + * @return this + */ + public PublishFirmwareRequest withRetries(@Nullable Integer retries) { + setRetries(retries); + return this; + } + + /** + * Gets the MD5 checksum over the entire firmware file as a hexadecimal string of length 32. + * + * @return The MD5 checksum over the entire firmware file as a hexadecimal string of length 32 + */ + public String getChecksum() { + return checksum; + } + + /** + * Sets the MD5 checksum over the entire firmware file as a hexadecimal string of length 32. + * + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32 + */ + public void setChecksum(String checksum) { + if (!isValidChecksum(checksum)) { + throw new PropertyConstraintException(checksum, "checksum is invalid"); + } + this.checksum = checksum; + } + + /** + * Returns whether the given checksum is valid + * + * @param checksum the checksum to check the validity of + * @return {@code true} if checksum is valid, {@code false} if not + */ + private boolean isValidChecksum(String checksum) { + return checksum != null && checksum.length() <= 32; + } + + /** + * Gets the Id of the request. + * + * @return The Id of the request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of the request. + * + * @param requestId The Id of the request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @return The interval in seconds after which a retry may be attempted + */ + @Nullable + public Integer getRetryInterval() { + return retryInterval; + } + + /** + * Sets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + */ + public void setRetryInterval(@Nullable Integer retryInterval) { + this.retryInterval = retryInterval; + } + + /** + * Adds the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + * @return this + */ + public PublishFirmwareRequest withRetryInterval(@Nullable Integer retryInterval) { + setRetryInterval(retryInterval); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidLocation(location) + && isValidChecksum(checksum) + && isValidRequestId(requestId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PublishFirmwareRequest that = (PublishFirmwareRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(location, that.location) + && Objects.equals(retries, that.retries) + && Objects.equals(checksum, that.checksum) + && Objects.equals(requestId, that.requestId) + && Objects.equals(retryInterval, that.retryInterval); + } + + @Override + public int hashCode() { + return Objects.hash(customData, location, retries, checksum, requestId, retryInterval); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("location", location) + .add("retries", retries) + .add("checksum", checksum) + .add("requestId", requestId) + .add("retryInterval", retryInterval) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareResponse.java new file mode 100644 index 000000000..9d85a8e26 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * PublishFirmwareResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class PublishFirmwareResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the request was accepted. */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the PublishFirmwareResponse class + * + * @param status Whether the request was accepted. + */ + public PublishFirmwareResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PublishFirmwareResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the request was accepted. + * + * @return Whether the request was accepted + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the request was accepted. + * + * @param status Whether the request was accepted + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public PublishFirmwareResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PublishFirmwareResponse that = (PublishFirmwareResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareStatusNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareStatusNotificationRequest.java new file mode 100644 index 000000000..24f79aa94 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareStatusNotificationRequest.java @@ -0,0 +1,263 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.PublishFirmwareStatusEnum; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * PublishFirmwareStatusNotificationRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class PublishFirmwareStatusNotificationRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The progress status of the publishfirmware installation. */ + private PublishFirmwareStatusEnum status; + + /** + * Required if status is Published. Can be multiple URI’s, if the Local Controller supports e.g. + * HTTP, HTTPS, and FTP. + */ + @Nullable private String[] location; + + /** The request id that was provided in the PublishFirmwareRequest which triggered this action. */ + @Nullable private Integer requestId; + + /** + * Constructor for the PublishFirmwareStatusNotificationRequest class + * + * @param status The progress status of the publishfirmware installation. + */ + public PublishFirmwareStatusNotificationRequest(PublishFirmwareStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PublishFirmwareStatusNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the progress status of the publishfirmware installation. + * + * @return The progress status of the publishfirmware installation + */ + public PublishFirmwareStatusEnum getStatus() { + return status; + } + + /** + * Sets the progress status of the publishfirmware installation. + * + * @param status The progress status of the publishfirmware installation + */ + public void setStatus(PublishFirmwareStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(PublishFirmwareStatusEnum status) { + return status != null; + } + + /** + * Gets required if status is Published. Can be multiple URI’s, if the Local Controller supports + * e.g. HTTP, HTTPS, and FTP. + * + * @return Required if status is Published + */ + @Nullable + public String[] getLocation() { + return location; + } + + /** + * Sets required if status is Published. Can be multiple URI’s, if the Local Controller supports + * e.g. HTTP, HTTPS, and FTP. + * + * @param location Required if status is Published + */ + public void setLocation(@Nullable String[] location) { + if (!isValidLocation(location)) { + throw new PropertyConstraintException(location, "location is invalid"); + } + this.location = location; + } + + /** + * Returns whether the given location is valid + * + * @param location the location to check the validity of + * @return {@code true} if location is valid, {@code false} if not + */ + private boolean isValidLocation(@Nullable String[] location) { + return location == null + || (location.length >= 1 && Arrays.stream(location).allMatch(item -> item.length() <= 512)); + } + + /** + * Adds required if status is Published. Can be multiple URI’s, if the Local Controller supports + * e.g. HTTP, HTTPS, and FTP. + * + * @param location Required if status is Published + * @return this + */ + public PublishFirmwareStatusNotificationRequest withLocation(@Nullable String[] location) { + setLocation(location); + return this; + } + + /** + * Gets the request id that was provided in the PublishFirmwareRequest which triggered this + * action. + * + * @return The request id that was provided in the PublishFirmwareRequest which triggered this + * action + */ + @Nullable + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the request id that was provided in the PublishFirmwareRequest which triggered this + * action. + * + * @param requestId The request id that was provided in the PublishFirmwareRequest which triggered + * this action + */ + public void setRequestId(@Nullable Integer requestId) { + this.requestId = requestId; + } + + /** + * Adds the request id that was provided in the PublishFirmwareRequest which triggered this + * action. + * + * @param requestId The request id that was provided in the PublishFirmwareRequest which triggered + * this action + * @return this + */ + public PublishFirmwareStatusNotificationRequest withRequestId(@Nullable Integer requestId) { + setRequestId(requestId); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidLocation(location); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PublishFirmwareStatusNotificationRequest that = (PublishFirmwareStatusNotificationRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Arrays.equals(location, that.location) + && Objects.equals(requestId, that.requestId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, Arrays.hashCode(location), requestId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("location", location) + .add("requestId", requestId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareStatusNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareStatusNotificationResponse.java new file mode 100644 index 000000000..6152b6a45 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/PublishFirmwareStatusNotificationResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * PublishFirmwareStatusNotificationResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class PublishFirmwareStatusNotificationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the PublishFirmwareStatusNotificationResponse class */ + public PublishFirmwareStatusNotificationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public PublishFirmwareStatusNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PublishFirmwareStatusNotificationResponse that = (PublishFirmwareStatusNotificationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReportChargingProfilesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReportChargingProfilesRequest.java new file mode 100644 index 000000000..12925f05e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReportChargingProfilesRequest.java @@ -0,0 +1,361 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ChargingLimitSourceEnum; +import eu.chargetime.ocpp.v201.model.types.ChargingProfile; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReportChargingProfilesRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class ReportChargingProfilesRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the + * GetChargingProfilesRequest, this field SHALL contain the same value. + */ + private Integer requestId; + + /** Source that has installed this charging profile. */ + private ChargingLimitSourceEnum chargingLimitSource; + + /** + * Charging Profile + * + *

A ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + */ + private ChargingProfile[] chargingProfile; + + /** + * To Be Continued. Default value when omitted: false. false indicates that there are no further + * messages as part of this report. + */ + @Nullable private Boolean tbc; + + /** + * The evse to which the charging profile applies. If evseId = 0, the message contains an overall + * limit for the Charging Station. + */ + private Integer evseId; + + /** + * Constructor for the ReportChargingProfilesRequest class + * + * @param requestId Id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the + * GetChargingProfilesRequest, this field SHALL contain the same value. + * @param chargingLimitSource Source that has installed this charging profile. + * @param chargingProfile A ChargingProfile consists of ChargingSchedule, describing the amount of + * power or current that can be delivered per time interval. + * @param evseId The evse to which the charging profile applies. If evseId = 0, the message + * contains an overall limit for the Charging Station. + */ + public ReportChargingProfilesRequest( + Integer requestId, + ChargingLimitSourceEnum chargingLimitSource, + ChargingProfile[] chargingProfile, + Integer evseId) { + setRequestId(requestId); + setChargingLimitSource(chargingLimitSource); + setChargingProfile(chargingProfile); + setEvseId(evseId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReportChargingProfilesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the + * GetChargingProfilesRequest, this field SHALL contain the same value. + * + * @return Id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages. When the CSMS provided a requestId in the + * GetChargingProfilesRequest, this field SHALL contain the same value. + * + * @param requestId Id used to match the GetChargingProfilesRequest message with the resulting + * ReportChargingProfilesRequest messages + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets source that has installed this charging profile. + * + * @return Source that has installed this charging profile + */ + public ChargingLimitSourceEnum getChargingLimitSource() { + return chargingLimitSource; + } + + /** + * Sets source that has installed this charging profile. + * + * @param chargingLimitSource Source that has installed this charging profile + */ + public void setChargingLimitSource(ChargingLimitSourceEnum chargingLimitSource) { + if (!isValidChargingLimitSource(chargingLimitSource)) { + throw new PropertyConstraintException(chargingLimitSource, "chargingLimitSource is invalid"); + } + this.chargingLimitSource = chargingLimitSource; + } + + /** + * Returns whether the given chargingLimitSource is valid + * + * @param chargingLimitSource the chargingLimitSource to check the validity of + * @return {@code true} if chargingLimitSource is valid, {@code false} if not + */ + private boolean isValidChargingLimitSource(ChargingLimitSourceEnum chargingLimitSource) { + return chargingLimitSource != null; + } + + /** + * Gets a ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + * + * @return A ChargingProfile consists of ChargingSchedule, describing the amount of power or + * current that can be delivered per time interval + */ + public ChargingProfile[] getChargingProfile() { + return chargingProfile; + } + + /** + * Sets a ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + * + * @param chargingProfile A ChargingProfile consists of ChargingSchedule, describing the amount of + * power or current that can be delivered per time interval + */ + public void setChargingProfile(ChargingProfile[] chargingProfile) { + if (!isValidChargingProfile(chargingProfile)) { + throw new PropertyConstraintException(chargingProfile, "chargingProfile is invalid"); + } + this.chargingProfile = chargingProfile; + } + + /** + * Returns whether the given chargingProfile is valid + * + * @param chargingProfile the chargingProfile to check the validity of + * @return {@code true} if chargingProfile is valid, {@code false} if not + */ + private boolean isValidChargingProfile(ChargingProfile[] chargingProfile) { + return chargingProfile != null + && chargingProfile.length >= 1 + && Arrays.stream(chargingProfile).allMatch(item -> item.validate()); + } + + /** + * Gets to Be Continued. Default value when omitted: false. false indicates that there are no + * further messages as part of this report. + * + * @return To Be Continued + */ + public Boolean getTbc() { + return tbc != null ? tbc : false; + } + + /** + * Sets to Be Continued. Default value when omitted: false. false indicates that there are no + * further messages as part of this report. + * + * @param tbc To Be Continued + */ + public void setTbc(@Nullable Boolean tbc) { + this.tbc = tbc; + } + + /** + * Adds to Be Continued. Default value when omitted: false. false indicates that there are no + * further messages as part of this report. + * + * @param tbc To Be Continued + * @return this + */ + public ReportChargingProfilesRequest withTbc(@Nullable Boolean tbc) { + setTbc(tbc); + return this; + } + + /** + * Gets the evse to which the charging profile applies. If evseId = 0, the message contains an + * overall limit for the Charging Station. + * + * @return The evse to which the charging profile applies + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the evse to which the charging profile applies. If evseId = 0, the message contains an + * overall limit for the Charging Station. + * + * @param evseId The evse to which the charging profile applies + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidRequestId(requestId) + && isValidChargingLimitSource(chargingLimitSource) + && isValidChargingProfile(chargingProfile) + && isValidEvseId(evseId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReportChargingProfilesRequest that = (ReportChargingProfilesRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(requestId, that.requestId) + && Objects.equals(chargingLimitSource, that.chargingLimitSource) + && Arrays.equals(chargingProfile, that.chargingProfile) + && Objects.equals(tbc, that.tbc) + && Objects.equals(evseId, that.evseId); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, requestId, chargingLimitSource, Arrays.hashCode(chargingProfile), tbc, evseId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("requestId", requestId) + .add("chargingLimitSource", chargingLimitSource) + .add("chargingProfile", chargingProfile) + .add("tbc", tbc) + .add("evseId", evseId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReportChargingProfilesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReportChargingProfilesResponse.java new file mode 100644 index 000000000..947598a5f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReportChargingProfilesResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReportChargingProfilesResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class ReportChargingProfilesResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ReportChargingProfilesResponse class */ + public ReportChargingProfilesResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReportChargingProfilesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReportChargingProfilesResponse that = (ReportChargingProfilesResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStartTransactionRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStartTransactionRequest.java new file mode 100644 index 000000000..7208560d5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStartTransactionRequest.java @@ -0,0 +1,379 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ChargingProfile; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.IdToken; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * RequestStartTransactionRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class RequestStartTransactionRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Number of the EVSE on which to start the transaction. EvseId SHALL be greater than 0 */ + @Nullable private Integer evseId; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private IdToken groupIdToken; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + private IdToken idToken; + + /** + * Id given by the server to this start request. The Charging Station might return this in the + * TransactionEventRequest, letting the server know which transaction was started for this + * request. Use to start a transaction. + */ + private Integer remoteStartId; + + /** + * Charging Profile + * + *

A ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + */ + @Nullable private ChargingProfile chargingProfile; + + /** + * Constructor for the RequestStartTransactionRequest class + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + * @param remoteStartId Id given by the server to this start request. The Charging Station might + * return this in the TransactionEventRequest, letting the server know which transaction was + * started for this request. Use to start a transaction. + */ + public RequestStartTransactionRequest(IdToken idToken, Integer remoteStartId) { + setIdToken(idToken); + setRemoteStartId(remoteStartId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RequestStartTransactionRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets number of the EVSE on which to start the transaction. EvseId SHALL be greater than 0 + * + * @return Number of the EVSE on which to start the transaction + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets number of the EVSE on which to start the transaction. EvseId SHALL be greater than 0 + * + * @param evseId Number of the EVSE on which to start the transaction + */ + public void setEvseId(@Nullable Integer evseId) { + this.evseId = evseId; + } + + /** + * Adds number of the EVSE on which to start the transaction. EvseId SHALL be greater than 0 + * + * @param evseId Number of the EVSE on which to start the transaction + * @return this + */ + public RequestStartTransactionRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public IdToken getGroupIdToken() { + return groupIdToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setGroupIdToken(@Nullable IdToken groupIdToken) { + if (!isValidGroupIdToken(groupIdToken)) { + throw new PropertyConstraintException(groupIdToken, "groupIdToken is invalid"); + } + this.groupIdToken = groupIdToken; + } + + /** + * Returns whether the given groupIdToken is valid + * + * @param groupIdToken the groupIdToken to check the validity of + * @return {@code true} if groupIdToken is valid, {@code false} if not + */ + private boolean isValidGroupIdToken(@Nullable IdToken groupIdToken) { + return groupIdToken == null || groupIdToken.validate(); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + * @return this + */ + public RequestStartTransactionRequest withGroupIdToken(@Nullable IdToken groupIdToken) { + setGroupIdToken(groupIdToken); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(IdToken idToken) { + return idToken != null && idToken.validate(); + } + + /** + * Gets id given by the server to this start request. The Charging Station might return this in + * the TransactionEventRequest, letting the server know which transaction was started for this + * request. Use to start a transaction. + * + * @return Id given by the server to this start request + */ + public Integer getRemoteStartId() { + return remoteStartId; + } + + /** + * Sets id given by the server to this start request. The Charging Station might return this in + * the TransactionEventRequest, letting the server know which transaction was started for this + * request. Use to start a transaction. + * + * @param remoteStartId Id given by the server to this start request + */ + public void setRemoteStartId(Integer remoteStartId) { + if (!isValidRemoteStartId(remoteStartId)) { + throw new PropertyConstraintException(remoteStartId, "remoteStartId is invalid"); + } + this.remoteStartId = remoteStartId; + } + + /** + * Returns whether the given remoteStartId is valid + * + * @param remoteStartId the remoteStartId to check the validity of + * @return {@code true} if remoteStartId is valid, {@code false} if not + */ + private boolean isValidRemoteStartId(Integer remoteStartId) { + return remoteStartId != null; + } + + /** + * Gets a ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + * + * @return A ChargingProfile consists of ChargingSchedule, describing the amount of power or + * current that can be delivered per time interval + */ + @Nullable + public ChargingProfile getChargingProfile() { + return chargingProfile; + } + + /** + * Sets a ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + * + * @param chargingProfile A ChargingProfile consists of ChargingSchedule, describing the amount of + * power or current that can be delivered per time interval + */ + public void setChargingProfile(@Nullable ChargingProfile chargingProfile) { + if (!isValidChargingProfile(chargingProfile)) { + throw new PropertyConstraintException(chargingProfile, "chargingProfile is invalid"); + } + this.chargingProfile = chargingProfile; + } + + /** + * Returns whether the given chargingProfile is valid + * + * @param chargingProfile the chargingProfile to check the validity of + * @return {@code true} if chargingProfile is valid, {@code false} if not + */ + private boolean isValidChargingProfile(@Nullable ChargingProfile chargingProfile) { + return chargingProfile == null || chargingProfile.validate(); + } + + /** + * Adds a ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + * + * @param chargingProfile A ChargingProfile consists of ChargingSchedule, describing the amount of + * power or current that can be delivered per time interval + * @return this + */ + public RequestStartTransactionRequest withChargingProfile( + @Nullable ChargingProfile chargingProfile) { + setChargingProfile(chargingProfile); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidGroupIdToken(groupIdToken) + && isValidIdToken(idToken) + && isValidRemoteStartId(remoteStartId) + && isValidChargingProfile(chargingProfile); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequestStartTransactionRequest that = (RequestStartTransactionRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(evseId, that.evseId) + && Objects.equals(groupIdToken, that.groupIdToken) + && Objects.equals(idToken, that.idToken) + && Objects.equals(remoteStartId, that.remoteStartId) + && Objects.equals(chargingProfile, that.chargingProfile); + } + + @Override + public int hashCode() { + return Objects.hash(customData, evseId, groupIdToken, idToken, remoteStartId, chargingProfile); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("evseId", evseId) + .add("groupIdToken", groupIdToken) + .add("idToken", idToken) + .add("remoteStartId", remoteStartId) + .add("chargingProfile", chargingProfile) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStartTransactionResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStartTransactionResponse.java new file mode 100644 index 000000000..fe9bc5bff --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStartTransactionResponse.java @@ -0,0 +1,277 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.RequestStartStopStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * RequestStartTransactionResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class RequestStartTransactionResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Status indicating whether the Charging Station accepts the request to start a transaction. */ + private RequestStartStopStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * When the transaction was already started by the Charging Station before the + * RequestStartTransactionRequest was received, for example: cable plugged in first. This contains + * the transactionId of the already started transaction. + */ + @Nullable private String transactionId; + + /** + * Constructor for the RequestStartTransactionResponse class + * + * @param status Status indicating whether the Charging Station accepts the request to start a + * transaction. + */ + public RequestStartTransactionResponse(RequestStartStopStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RequestStartTransactionResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets status indicating whether the Charging Station accepts the request to start a transaction. + * + * @return Status indicating whether the Charging Station accepts the request to start a + * transaction + */ + public RequestStartStopStatusEnum getStatus() { + return status; + } + + /** + * Sets status indicating whether the Charging Station accepts the request to start a transaction. + * + * @param status Status indicating whether the Charging Station accepts the request to start a + * transaction + */ + public void setStatus(RequestStartStopStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(RequestStartStopStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public RequestStartTransactionResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets when the transaction was already started by the Charging Station before the + * RequestStartTransactionRequest was received, for example: cable plugged in first. This contains + * the transactionId of the already started transaction. + * + * @return When the transaction was already started by the Charging Station before the + * RequestStartTransactionRequest was received, for example: cable plugged in first + */ + @Nullable + public String getTransactionId() { + return transactionId; + } + + /** + * Sets when the transaction was already started by the Charging Station before the + * RequestStartTransactionRequest was received, for example: cable plugged in first. This contains + * the transactionId of the already started transaction. + * + * @param transactionId When the transaction was already started by the Charging Station before + * the RequestStartTransactionRequest was received, for example: cable plugged in first + */ + public void setTransactionId(@Nullable String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(@Nullable String transactionId) { + return transactionId == null || transactionId.length() <= 36; + } + + /** + * Adds when the transaction was already started by the Charging Station before the + * RequestStartTransactionRequest was received, for example: cable plugged in first. This contains + * the transactionId of the already started transaction. + * + * @param transactionId When the transaction was already started by the Charging Station before + * the RequestStartTransactionRequest was received, for example: cable plugged in first + * @return this + */ + public RequestStartTransactionResponse withTransactionId(@Nullable String transactionId) { + setTransactionId(transactionId); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidStatus(status) + && isValidStatusInfo(statusInfo) + && isValidTransactionId(transactionId); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequestStartTransactionResponse that = (RequestStartTransactionResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(transactionId, that.transactionId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo, transactionId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("transactionId", transactionId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStopTransactionRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStopTransactionRequest.java new file mode 100644 index 000000000..40881a62f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStopTransactionRequest.java @@ -0,0 +1,167 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * RequestStopTransactionRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class RequestStopTransactionRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The identifier of the transaction which the Charging Station is requested to stop. */ + private String transactionId; + + /** + * Constructor for the RequestStopTransactionRequest class + * + * @param transactionId The identifier of the transaction which the Charging Station is requested + * to stop. + */ + public RequestStopTransactionRequest(String transactionId) { + setTransactionId(transactionId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RequestStopTransactionRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the identifier of the transaction which the Charging Station is requested to stop. + * + * @return The identifier of the transaction which the Charging Station is requested to stop + */ + public String getTransactionId() { + return transactionId; + } + + /** + * Sets the identifier of the transaction which the Charging Station is requested to stop. + * + * @param transactionId The identifier of the transaction which the Charging Station is requested + * to stop + */ + public void setTransactionId(String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(String transactionId) { + return transactionId != null && transactionId.length() <= 36; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidTransactionId(transactionId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequestStopTransactionRequest that = (RequestStopTransactionRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(transactionId, that.transactionId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, transactionId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("transactionId", transactionId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStopTransactionResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStopTransactionResponse.java new file mode 100644 index 000000000..a076c2eac --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/RequestStopTransactionResponse.java @@ -0,0 +1,212 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.RequestStartStopStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * RequestStopTransactionResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class RequestStopTransactionResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Status indicating whether Charging Station accepts the request to stop a transaction. */ + private RequestStartStopStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the RequestStopTransactionResponse class + * + * @param status Status indicating whether Charging Station accepts the request to stop a + * transaction. + */ + public RequestStopTransactionResponse(RequestStartStopStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RequestStopTransactionResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets status indicating whether Charging Station accepts the request to stop a transaction. + * + * @return Status indicating whether Charging Station accepts the request to stop a transaction + */ + public RequestStartStopStatusEnum getStatus() { + return status; + } + + /** + * Sets status indicating whether Charging Station accepts the request to stop a transaction. + * + * @param status Status indicating whether Charging Station accepts the request to stop a + * transaction + */ + public void setStatus(RequestStartStopStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(RequestStartStopStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public RequestStopTransactionResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RequestStopTransactionResponse that = (RequestStopTransactionResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReservationStatusUpdateRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReservationStatusUpdateRequest.java new file mode 100644 index 000000000..ed0b26e5d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReservationStatusUpdateRequest.java @@ -0,0 +1,209 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.ReservationUpdateStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReservationStatusUpdateRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class ReservationStatusUpdateRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The ID of the reservation. */ + private Integer reservationId; + + /** The updated reservation status. */ + private ReservationUpdateStatusEnum reservationUpdateStatus; + + /** + * Constructor for the ReservationStatusUpdateRequest class + * + * @param reservationId The ID of the reservation. + * @param reservationUpdateStatus The updated reservation status. + */ + public ReservationStatusUpdateRequest( + Integer reservationId, ReservationUpdateStatusEnum reservationUpdateStatus) { + setReservationId(reservationId); + setReservationUpdateStatus(reservationUpdateStatus); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReservationStatusUpdateRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the ID of the reservation. + * + * @return The ID of the reservation + */ + public Integer getReservationId() { + return reservationId; + } + + /** + * Sets the ID of the reservation. + * + * @param reservationId The ID of the reservation + */ + public void setReservationId(Integer reservationId) { + if (!isValidReservationId(reservationId)) { + throw new PropertyConstraintException(reservationId, "reservationId is invalid"); + } + this.reservationId = reservationId; + } + + /** + * Returns whether the given reservationId is valid + * + * @param reservationId the reservationId to check the validity of + * @return {@code true} if reservationId is valid, {@code false} if not + */ + private boolean isValidReservationId(Integer reservationId) { + return reservationId != null; + } + + /** + * Gets the updated reservation status. + * + * @return The updated reservation status + */ + public ReservationUpdateStatusEnum getReservationUpdateStatus() { + return reservationUpdateStatus; + } + + /** + * Sets the updated reservation status. + * + * @param reservationUpdateStatus The updated reservation status + */ + public void setReservationUpdateStatus(ReservationUpdateStatusEnum reservationUpdateStatus) { + if (!isValidReservationUpdateStatus(reservationUpdateStatus)) { + throw new PropertyConstraintException( + reservationUpdateStatus, "reservationUpdateStatus is invalid"); + } + this.reservationUpdateStatus = reservationUpdateStatus; + } + + /** + * Returns whether the given reservationUpdateStatus is valid + * + * @param reservationUpdateStatus the reservationUpdateStatus to check the validity of + * @return {@code true} if reservationUpdateStatus is valid, {@code false} if not + */ + private boolean isValidReservationUpdateStatus( + ReservationUpdateStatusEnum reservationUpdateStatus) { + return reservationUpdateStatus != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidReservationId(reservationId) + && isValidReservationUpdateStatus(reservationUpdateStatus); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReservationStatusUpdateRequest that = (ReservationStatusUpdateRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(reservationId, that.reservationId) + && Objects.equals(reservationUpdateStatus, that.reservationUpdateStatus); + } + + @Override + public int hashCode() { + return Objects.hash(customData, reservationId, reservationUpdateStatus); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("reservationId", reservationId) + .add("reservationUpdateStatus", reservationUpdateStatus) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReservationStatusUpdateResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReservationStatusUpdateResponse.java new file mode 100644 index 000000000..74ee84d23 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReservationStatusUpdateResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReservationStatusUpdateResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class ReservationStatusUpdateResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the ReservationStatusUpdateResponse class */ + public ReservationStatusUpdateResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReservationStatusUpdateResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReservationStatusUpdateResponse that = (ReservationStatusUpdateResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReserveNowRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReserveNowRequest.java new file mode 100644 index 000000000..63847b8e3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReserveNowRequest.java @@ -0,0 +1,384 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ConnectorEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.IdToken; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReserveNowRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class ReserveNowRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Id of reservation. */ + private Integer id; + + /** Date and time at which the reservation expires. */ + private ZonedDateTime expiryDateTime; + + /** The connector type. */ + @Nullable private ConnectorEnum connectorType; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + private IdToken idToken; + + /** ID of the evse to be reserved. */ + @Nullable private Integer evseId; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private IdToken groupIdToken; + + /** + * Constructor for the ReserveNowRequest class + * + * @param id Id of reservation. + * @param expiryDateTime Date and time at which the reservation expires. + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + */ + public ReserveNowRequest(Integer id, ZonedDateTime expiryDateTime, IdToken idToken) { + setId(id); + setExpiryDateTime(expiryDateTime); + setIdToken(idToken); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReserveNowRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets id of reservation. + * + * @return Id of reservation + */ + public Integer getId() { + return id; + } + + /** + * Sets id of reservation. + * + * @param id Id of reservation + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null; + } + + /** + * Gets date and time at which the reservation expires. + * + * @return Date and time at which the reservation expires + */ + public ZonedDateTime getExpiryDateTime() { + return expiryDateTime; + } + + /** + * Sets date and time at which the reservation expires. + * + * @param expiryDateTime Date and time at which the reservation expires + */ + public void setExpiryDateTime(ZonedDateTime expiryDateTime) { + if (!isValidExpiryDateTime(expiryDateTime)) { + throw new PropertyConstraintException(expiryDateTime, "expiryDateTime is invalid"); + } + this.expiryDateTime = expiryDateTime; + } + + /** + * Returns whether the given expiryDateTime is valid + * + * @param expiryDateTime the expiryDateTime to check the validity of + * @return {@code true} if expiryDateTime is valid, {@code false} if not + */ + private boolean isValidExpiryDateTime(ZonedDateTime expiryDateTime) { + return expiryDateTime != null; + } + + /** + * Gets the connector type. + * + * @return The connector type + */ + @Nullable + public ConnectorEnum getConnectorType() { + return connectorType; + } + + /** + * Sets the connector type. + * + * @param connectorType The connector type + */ + public void setConnectorType(@Nullable ConnectorEnum connectorType) { + this.connectorType = connectorType; + } + + /** + * Adds the connector type. + * + * @param connectorType The connector type + * @return this + */ + public ReserveNowRequest withConnectorType(@Nullable ConnectorEnum connectorType) { + setConnectorType(connectorType); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(IdToken idToken) { + return idToken != null && idToken.validate(); + } + + /** + * Gets ID of the evse to be reserved. + * + * @return ID of the evse to be reserved + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets ID of the evse to be reserved. + * + * @param evseId ID of the evse to be reserved + */ + public void setEvseId(@Nullable Integer evseId) { + this.evseId = evseId; + } + + /** + * Adds ID of the evse to be reserved. + * + * @param evseId ID of the evse to be reserved + * @return this + */ + public ReserveNowRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public IdToken getGroupIdToken() { + return groupIdToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setGroupIdToken(@Nullable IdToken groupIdToken) { + if (!isValidGroupIdToken(groupIdToken)) { + throw new PropertyConstraintException(groupIdToken, "groupIdToken is invalid"); + } + this.groupIdToken = groupIdToken; + } + + /** + * Returns whether the given groupIdToken is valid + * + * @param groupIdToken the groupIdToken to check the validity of + * @return {@code true} if groupIdToken is valid, {@code false} if not + */ + private boolean isValidGroupIdToken(@Nullable IdToken groupIdToken) { + return groupIdToken == null || groupIdToken.validate(); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + * @return this + */ + public ReserveNowRequest withGroupIdToken(@Nullable IdToken groupIdToken) { + setGroupIdToken(groupIdToken); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidId(id) + && isValidExpiryDateTime(expiryDateTime) + && isValidIdToken(idToken) + && isValidGroupIdToken(groupIdToken); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReserveNowRequest that = (ReserveNowRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(id, that.id) + && Objects.equals(expiryDateTime, that.expiryDateTime) + && Objects.equals(connectorType, that.connectorType) + && Objects.equals(idToken, that.idToken) + && Objects.equals(evseId, that.evseId) + && Objects.equals(groupIdToken, that.groupIdToken); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, id, expiryDateTime, connectorType, idToken, evseId, groupIdToken); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("id", id) + .add("expiryDateTime", expiryDateTime) + .add("connectorType", connectorType) + .add("idToken", idToken) + .add("evseId", evseId) + .add("groupIdToken", groupIdToken) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReserveNowResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReserveNowResponse.java new file mode 100644 index 000000000..2f8b91210 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ReserveNowResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.ReserveNowStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ReserveNowResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class ReserveNowResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** The success or failure of the reservation. */ + private ReserveNowStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the ReserveNowResponse class + * + * @param status The success or failure of the reservation. + */ + public ReserveNowResponse(ReserveNowStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReserveNowResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the success or failure of the reservation. + * + * @return The success or failure of the reservation + */ + public ReserveNowStatusEnum getStatus() { + return status; + } + + /** + * Sets the success or failure of the reservation. + * + * @param status The success or failure of the reservation + */ + public void setStatus(ReserveNowStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ReserveNowStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ReserveNowResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReserveNowResponse that = (ReserveNowResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ResetRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ResetRequest.java new file mode 100644 index 000000000..52bcc552f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ResetRequest.java @@ -0,0 +1,204 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.ResetEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ResetRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class ResetRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The type of reset that the Charging Station or EVSE should perform. */ + private ResetEnum type; + + /** The ID of a specific EVSE that needs to be reset, instead of the entire Charging Station. */ + @Nullable private Integer evseId; + + /** + * Constructor for the ResetRequest class + * + * @param type The type of reset that the Charging Station or EVSE should perform. + */ + public ResetRequest(ResetEnum type) { + setType(type); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ResetRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the type of reset that the Charging Station or EVSE should perform. + * + * @return The type of reset that the Charging Station or EVSE should perform + */ + public ResetEnum getType() { + return type; + } + + /** + * Sets the type of reset that the Charging Station or EVSE should perform. + * + * @param type The type of reset that the Charging Station or EVSE should perform + */ + public void setType(ResetEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(ResetEnum type) { + return type != null; + } + + /** + * Gets the ID of a specific EVSE that needs to be reset, instead of the entire Charging Station. + * + * @return The ID of a specific EVSE that needs to be reset, instead of the entire Charging + * Station + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the ID of a specific EVSE that needs to be reset, instead of the entire Charging Station. + * + * @param evseId The ID of a specific EVSE that needs to be reset, instead of the entire Charging + * Station + */ + public void setEvseId(@Nullable Integer evseId) { + this.evseId = evseId; + } + + /** + * Adds the ID of a specific EVSE that needs to be reset, instead of the entire Charging Station. + * + * @param evseId The ID of a specific EVSE that needs to be reset, instead of the entire Charging + * Station + * @return this + */ + public ResetRequest withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidType(type); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResetRequest that = (ResetRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(type, that.type) + && Objects.equals(evseId, that.evseId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, type, evseId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("type", type) + .add("evseId", evseId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ResetResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ResetResponse.java new file mode 100644 index 000000000..c94a5f527 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/ResetResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.ResetStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ResetResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class ResetResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the Charging Station is able to perform the reset. */ + private ResetStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the ResetResponse class + * + * @param status Whether the Charging Station is able to perform the reset. + */ + public ResetResponse(ResetStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ResetResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station is able to perform the reset. + * + * @return Whether the Charging Station is able to perform the reset + */ + public ResetStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station is able to perform the reset. + * + * @param status Whether the Charging Station is able to perform the reset + */ + public void setStatus(ResetStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ResetStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ResetResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResetResponse that = (ResetResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SecurityEventNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SecurityEventNotificationRequest.java new file mode 100644 index 000000000..c2530000c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SecurityEventNotificationRequest.java @@ -0,0 +1,256 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SecurityEventNotificationRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class SecurityEventNotificationRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Type of the security event. This value should be taken from the Security events list. */ + private String type; + + /** Date and time at which the event occurred. */ + private ZonedDateTime timestamp; + + /** Additional information about the occurred security event. */ + @Nullable private String techInfo; + + /** + * Constructor for the SecurityEventNotificationRequest class + * + * @param type Type of the security event. This value should be taken from the Security events + * list. + * @param timestamp Date and time at which the event occurred. + */ + public SecurityEventNotificationRequest(String type, ZonedDateTime timestamp) { + setType(type); + setTimestamp(timestamp); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SecurityEventNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets type of the security event. This value should be taken from the Security events list. + * + * @return Type of the security event + */ + public String getType() { + return type; + } + + /** + * Sets type of the security event. This value should be taken from the Security events list. + * + * @param type Type of the security event + */ + public void setType(String type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(String type) { + return type != null && type.length() <= 50; + } + + /** + * Gets date and time at which the event occurred. + * + * @return Date and time at which the event occurred + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets date and time at which the event occurred. + * + * @param timestamp Date and time at which the event occurred + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets additional information about the occurred security event. + * + * @return Additional information about the occurred security event + */ + @Nullable + public String getTechInfo() { + return techInfo; + } + + /** + * Sets additional information about the occurred security event. + * + * @param techInfo Additional information about the occurred security event + */ + public void setTechInfo(@Nullable String techInfo) { + if (!isValidTechInfo(techInfo)) { + throw new PropertyConstraintException(techInfo, "techInfo is invalid"); + } + this.techInfo = techInfo; + } + + /** + * Returns whether the given techInfo is valid + * + * @param techInfo the techInfo to check the validity of + * @return {@code true} if techInfo is valid, {@code false} if not + */ + private boolean isValidTechInfo(@Nullable String techInfo) { + return techInfo == null || techInfo.length() <= 255; + } + + /** + * Adds additional information about the occurred security event. + * + * @param techInfo Additional information about the occurred security event + * @return this + */ + public SecurityEventNotificationRequest withTechInfo(@Nullable String techInfo) { + setTechInfo(techInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidType(type) + && isValidTimestamp(timestamp) + && isValidTechInfo(techInfo); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityEventNotificationRequest that = (SecurityEventNotificationRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(type, that.type) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(techInfo, that.techInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, type, timestamp, techInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("type", type) + .add("timestamp", timestamp) + .add("techInfo", techInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SecurityEventNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SecurityEventNotificationResponse.java new file mode 100644 index 000000000..68783c70c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SecurityEventNotificationResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SecurityEventNotificationResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class SecurityEventNotificationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the SecurityEventNotificationResponse class */ + public SecurityEventNotificationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SecurityEventNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityEventNotificationResponse that = (SecurityEventNotificationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SendLocalListRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SendLocalListRequest.java new file mode 100644 index 000000000..259ae59b9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SendLocalListRequest.java @@ -0,0 +1,270 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.AuthorizationData; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.UpdateEnum; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SendLocalListRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class SendLocalListRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The identifier to use for authorization. */ + @Nullable private AuthorizationData[] localAuthorizationList; + + /** + * In case of a full update this is the version number of the full list. In case of a differential + * update it is the version number of the list after the update has been applied. + */ + private Integer versionNumber; + + /** The type of update (full or differential) of this request. */ + private UpdateEnum updateType; + + /** + * Constructor for the SendLocalListRequest class + * + * @param versionNumber In case of a full update this is the version number of the full list. In + * case of a differential update it is the version number of the list after the update has + * been applied. + * @param updateType The type of update (full or differential) of this request. + */ + public SendLocalListRequest(Integer versionNumber, UpdateEnum updateType) { + setVersionNumber(versionNumber); + setUpdateType(updateType); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SendLocalListRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the identifier to use for authorization. + * + * @return The identifier to use for authorization + */ + @Nullable + public AuthorizationData[] getLocalAuthorizationList() { + return localAuthorizationList; + } + + /** + * Sets the identifier to use for authorization. + * + * @param localAuthorizationList The identifier to use for authorization + */ + public void setLocalAuthorizationList(@Nullable AuthorizationData[] localAuthorizationList) { + if (!isValidLocalAuthorizationList(localAuthorizationList)) { + throw new PropertyConstraintException( + localAuthorizationList, "localAuthorizationList is invalid"); + } + this.localAuthorizationList = localAuthorizationList; + } + + /** + * Returns whether the given localAuthorizationList is valid + * + * @param localAuthorizationList the localAuthorizationList to check the validity of + * @return {@code true} if localAuthorizationList is valid, {@code false} if not + */ + private boolean isValidLocalAuthorizationList( + @Nullable AuthorizationData[] localAuthorizationList) { + return localAuthorizationList == null + || (localAuthorizationList.length >= 1 + && Arrays.stream(localAuthorizationList).allMatch(item -> item.validate())); + } + + /** + * Adds the identifier to use for authorization. + * + * @param localAuthorizationList The identifier to use for authorization + * @return this + */ + public SendLocalListRequest withLocalAuthorizationList( + @Nullable AuthorizationData[] localAuthorizationList) { + setLocalAuthorizationList(localAuthorizationList); + return this; + } + + /** + * Gets in case of a full update this is the version number of the full list. In case of a + * differential update it is the version number of the list after the update has been applied. + * + * @return In case of a full update this is the version number of the full list + */ + public Integer getVersionNumber() { + return versionNumber; + } + + /** + * Sets in case of a full update this is the version number of the full list. In case of a + * differential update it is the version number of the list after the update has been applied. + * + * @param versionNumber In case of a full update this is the version number of the full list + */ + public void setVersionNumber(Integer versionNumber) { + if (!isValidVersionNumber(versionNumber)) { + throw new PropertyConstraintException(versionNumber, "versionNumber is invalid"); + } + this.versionNumber = versionNumber; + } + + /** + * Returns whether the given versionNumber is valid + * + * @param versionNumber the versionNumber to check the validity of + * @return {@code true} if versionNumber is valid, {@code false} if not + */ + private boolean isValidVersionNumber(Integer versionNumber) { + return versionNumber != null; + } + + /** + * Gets the type of update (full or differential) of this request. + * + * @return The type of update (full or differential) of this request + */ + public UpdateEnum getUpdateType() { + return updateType; + } + + /** + * Sets the type of update (full or differential) of this request. + * + * @param updateType The type of update (full or differential) of this request + */ + public void setUpdateType(UpdateEnum updateType) { + if (!isValidUpdateType(updateType)) { + throw new PropertyConstraintException(updateType, "updateType is invalid"); + } + this.updateType = updateType; + } + + /** + * Returns whether the given updateType is valid + * + * @param updateType the updateType to check the validity of + * @return {@code true} if updateType is valid, {@code false} if not + */ + private boolean isValidUpdateType(UpdateEnum updateType) { + return updateType != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidLocalAuthorizationList(localAuthorizationList) + && isValidVersionNumber(versionNumber) + && isValidUpdateType(updateType); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SendLocalListRequest that = (SendLocalListRequest) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(localAuthorizationList, that.localAuthorizationList) + && Objects.equals(versionNumber, that.versionNumber) + && Objects.equals(updateType, that.updateType); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, Arrays.hashCode(localAuthorizationList), versionNumber, updateType); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("localAuthorizationList", localAuthorizationList) + .add("versionNumber", versionNumber) + .add("updateType", updateType) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SendLocalListResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SendLocalListResponse.java new file mode 100644 index 000000000..473026b4f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SendLocalListResponse.java @@ -0,0 +1,218 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.SendLocalListStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SendLocalListResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class SendLocalListResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Whether the Charging Station has successfully received and applied the update of the Local + * Authorization List. + */ + private SendLocalListStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the SendLocalListResponse class + * + * @param status Whether the Charging Station has successfully received and applied the update of + * the Local Authorization List. + */ + public SendLocalListResponse(SendLocalListStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SendLocalListResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station has successfully received and applied the update of the Local + * Authorization List. + * + * @return Whether the Charging Station has successfully received and applied the update of the + * Local Authorization List + */ + public SendLocalListStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station has successfully received and applied the update of the Local + * Authorization List. + * + * @param status Whether the Charging Station has successfully received and applied the update of + * the Local Authorization List + */ + public void setStatus(SendLocalListStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(SendLocalListStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SendLocalListResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SendLocalListResponse that = (SendLocalListResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetChargingProfileRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetChargingProfileRequest.java new file mode 100644 index 000000000..4d295863f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetChargingProfileRequest.java @@ -0,0 +1,226 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ChargingProfile; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetChargingProfileRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class SetChargingProfileRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * For TxDefaultProfile an evseId=0 applies the profile to each individual evse. For + * ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an overal + * limit for the whole Charging Station. + */ + private Integer evseId; + + /** + * Charging Profile + * + *

A ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + */ + private ChargingProfile chargingProfile; + + /** + * Constructor for the SetChargingProfileRequest class + * + * @param evseId For TxDefaultProfile an evseId=0 applies the profile to each individual evse. For + * ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an + * overal limit for the whole Charging Station. + * @param chargingProfile A ChargingProfile consists of ChargingSchedule, describing the amount of + * power or current that can be delivered per time interval. + */ + public SetChargingProfileRequest(Integer evseId, ChargingProfile chargingProfile) { + setEvseId(evseId); + setChargingProfile(chargingProfile); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetChargingProfileRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets for TxDefaultProfile an evseId=0 applies the profile to each individual evse. For + * ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an overal + * limit for the whole Charging Station. + * + * @return For TxDefaultProfile an evseId=0 applies the profile to each individual evse + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets for TxDefaultProfile an evseId=0 applies the profile to each individual evse. For + * ChargingStationMaxProfile and ChargingStationExternalConstraints an evseId=0 contains an overal + * limit for the whole Charging Station. + * + * @param evseId For TxDefaultProfile an evseId=0 applies the profile to each individual evse + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null; + } + + /** + * Gets a ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + * + * @return A ChargingProfile consists of ChargingSchedule, describing the amount of power or + * current that can be delivered per time interval + */ + public ChargingProfile getChargingProfile() { + return chargingProfile; + } + + /** + * Sets a ChargingProfile consists of ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + * + * @param chargingProfile A ChargingProfile consists of ChargingSchedule, describing the amount of + * power or current that can be delivered per time interval + */ + public void setChargingProfile(ChargingProfile chargingProfile) { + if (!isValidChargingProfile(chargingProfile)) { + throw new PropertyConstraintException(chargingProfile, "chargingProfile is invalid"); + } + this.chargingProfile = chargingProfile; + } + + /** + * Returns whether the given chargingProfile is valid + * + * @param chargingProfile the chargingProfile to check the validity of + * @return {@code true} if chargingProfile is valid, {@code false} if not + */ + private boolean isValidChargingProfile(ChargingProfile chargingProfile) { + return chargingProfile != null && chargingProfile.validate(); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidEvseId(evseId) + && isValidChargingProfile(chargingProfile); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetChargingProfileRequest that = (SetChargingProfileRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(evseId, that.evseId) + && Objects.equals(chargingProfile, that.chargingProfile); + } + + @Override + public int hashCode() { + return Objects.hash(customData, evseId, chargingProfile); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("evseId", evseId) + .add("chargingProfile", chargingProfile) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetChargingProfileResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetChargingProfileResponse.java new file mode 100644 index 000000000..a8b29950a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetChargingProfileResponse.java @@ -0,0 +1,221 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ChargingProfileStatusEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetChargingProfileResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class SetChargingProfileResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Returns whether the Charging Station has been able to process the message successfully. This + * does not guarantee the schedule will be followed to the letter. There might be other + * constraints the Charging Station may need to take into account. + */ + private ChargingProfileStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the SetChargingProfileResponse class + * + * @param status Returns whether the Charging Station has been able to process the message + * successfully. This does not guarantee the schedule will be followed to the letter. There + * might be other constraints the Charging Station may need to take into account. + */ + public SetChargingProfileResponse(ChargingProfileStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetChargingProfileResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets returns whether the Charging Station has been able to process the message successfully. + * This does not guarantee the schedule will be followed to the letter. There might be other + * constraints the Charging Station may need to take into account. + * + * @return Returns whether the Charging Station has been able to process the message successfully + */ + public ChargingProfileStatusEnum getStatus() { + return status; + } + + /** + * Sets returns whether the Charging Station has been able to process the message successfully. + * This does not guarantee the schedule will be followed to the letter. There might be other + * constraints the Charging Station may need to take into account. + * + * @param status Returns whether the Charging Station has been able to process the message + * successfully + */ + public void setStatus(ChargingProfileStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ChargingProfileStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetChargingProfileResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetChargingProfileResponse that = (SetChargingProfileResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetDisplayMessageRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetDisplayMessageRequest.java new file mode 100644 index 000000000..5af7b5dbc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetDisplayMessageRequest.java @@ -0,0 +1,169 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.MessageInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetDisplayMessageRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class SetDisplayMessageRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Message Info + * + *

Message details, for a message to be displayed on a Charging Station. + */ + private MessageInfo message; + + /** + * Constructor for the SetDisplayMessageRequest class + * + * @param message Message details, for a message to be displayed on a Charging Station. + */ + public SetDisplayMessageRequest(MessageInfo message) { + setMessage(message); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetDisplayMessageRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + public MessageInfo getMessage() { + return message; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param message Message details, for a message to be displayed on a Charging Station + */ + public void setMessage(MessageInfo message) { + if (!isValidMessage(message)) { + throw new PropertyConstraintException(message, "message is invalid"); + } + this.message = message; + } + + /** + * Returns whether the given message is valid + * + * @param message the message to check the validity of + * @return {@code true} if message is valid, {@code false} if not + */ + private boolean isValidMessage(MessageInfo message) { + return message != null && message.validate(); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidMessage(message); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetDisplayMessageRequest that = (SetDisplayMessageRequest) o; + return Objects.equals(customData, that.customData) && Objects.equals(message, that.message); + } + + @Override + public int hashCode() { + return Objects.hash(customData, message); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("message", message) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetDisplayMessageResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetDisplayMessageResponse.java new file mode 100644 index 000000000..e9ad9a128 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetDisplayMessageResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.DisplayMessageStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetDisplayMessageResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class SetDisplayMessageResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the Charging Station is able to display the message. */ + private DisplayMessageStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the SetDisplayMessageResponse class + * + * @param status Whether the Charging Station is able to display the message. + */ + public SetDisplayMessageResponse(DisplayMessageStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetDisplayMessageResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station is able to display the message. + * + * @return Whether the Charging Station is able to display the message + */ + public DisplayMessageStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station is able to display the message. + * + * @param status Whether the Charging Station is able to display the message + */ + public void setStatus(DisplayMessageStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(DisplayMessageStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetDisplayMessageResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetDisplayMessageResponse that = (SetDisplayMessageResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringBaseRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringBaseRequest.java new file mode 100644 index 000000000..084251e14 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringBaseRequest.java @@ -0,0 +1,166 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.MonitoringBaseEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetMonitoringBaseRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class SetMonitoringBaseRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Specify which monitoring base will be set */ + private MonitoringBaseEnum monitoringBase; + + /** + * Constructor for the SetMonitoringBaseRequest class + * + * @param monitoringBase Specify which monitoring base will be set + */ + public SetMonitoringBaseRequest(MonitoringBaseEnum monitoringBase) { + setMonitoringBase(monitoringBase); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringBaseRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets specify which monitoring base will be set + * + * @return Specify which monitoring base will be set + */ + public MonitoringBaseEnum getMonitoringBase() { + return monitoringBase; + } + + /** + * Sets specify which monitoring base will be set + * + * @param monitoringBase Specify which monitoring base will be set + */ + public void setMonitoringBase(MonitoringBaseEnum monitoringBase) { + if (!isValidMonitoringBase(monitoringBase)) { + throw new PropertyConstraintException(monitoringBase, "monitoringBase is invalid"); + } + this.monitoringBase = monitoringBase; + } + + /** + * Returns whether the given monitoringBase is valid + * + * @param monitoringBase the monitoringBase to check the validity of + * @return {@code true} if monitoringBase is valid, {@code false} if not + */ + private boolean isValidMonitoringBase(MonitoringBaseEnum monitoringBase) { + return monitoringBase != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidMonitoringBase(monitoringBase); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringBaseRequest that = (SetMonitoringBaseRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(monitoringBase, that.monitoringBase); + } + + @Override + public int hashCode() { + return Objects.hash(customData, monitoringBase); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("monitoringBase", monitoringBase) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringBaseResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringBaseResponse.java new file mode 100644 index 000000000..ed786c309 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringBaseResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GenericDeviceModelStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetMonitoringBaseResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class SetMonitoringBaseResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the Charging Station was able to accept the request. */ + private GenericDeviceModelStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the SetMonitoringBaseResponse class + * + * @param status Whether the Charging Station was able to accept the request. + */ + public SetMonitoringBaseResponse(GenericDeviceModelStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringBaseResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station was able to accept the request. + * + * @return Whether the Charging Station was able to accept the request + */ + public GenericDeviceModelStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station was able to accept the request. + * + * @param status Whether the Charging Station was able to accept the request + */ + public void setStatus(GenericDeviceModelStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericDeviceModelStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetMonitoringBaseResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringBaseResponse that = (SetMonitoringBaseResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringLevelRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringLevelRequest.java new file mode 100644 index 000000000..4837a54f9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringLevelRequest.java @@ -0,0 +1,200 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetMonitoringLevelRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class SetMonitoringLevelRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * The Charging Station SHALL only report events with a severity number lower than or equal to + * this severity. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + * + *

+   * The severity levels have the following meaning: +
+   * *0-Danger* +
+   * Lives are potentially in danger. Urgent attention is needed and action should be taken immediately. +
+   * *1-Hardware Failure* +
+   * That the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. +
+   * *2-System Failure* +
+   * That the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. +
+   * *3-Critical* +
+   * A critical error. Action is required. +
+   * *4-Error* +
+   * A non-urgent error. Action is required. +
+   * *5-Alert* +
+   * An alert event. Default severity for any type of monitoring event. +
+   * *6-Warning* +
+   * A warning event. Action may be required. +
+   * *7-Notice* +
+   * An unusual event. No immediate action is required. +
+   * *8-Informational* +
+   * A regular operational event. May be used for reporting, measuring throughput, etc. No action is required. +
+   * *9-Debug* +
+   * Information useful to developers for debugging, not useful during operations.
+   * 
+ */ + private Integer severity; + + /** + * Constructor for the SetMonitoringLevelRequest class + * + * @param severity The Charging Station SHALL only report events with a severity number lower than + * or equal to this severity. The severity range is 0-9, with 0 as the highest and 9 as the + * lowest severity level. + */ + public SetMonitoringLevelRequest(Integer severity) { + setSeverity(severity); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringLevelRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the Charging Station SHALL only report events with a severity number lower than or equal + * to this severity. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + * + * @return The Charging Station SHALL only report events with a severity number lower than or + * equal to this severity + */ + public Integer getSeverity() { + return severity; + } + + /** + * Sets the Charging Station SHALL only report events with a severity number lower than or equal + * to this severity. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + * + * @param severity The Charging Station SHALL only report events with a severity number lower than + * or equal to this severity + */ + public void setSeverity(Integer severity) { + if (!isValidSeverity(severity)) { + throw new PropertyConstraintException(severity, "severity is invalid"); + } + this.severity = severity; + } + + /** + * Returns whether the given severity is valid + * + * @param severity the severity to check the validity of + * @return {@code true} if severity is valid, {@code false} if not + */ + private boolean isValidSeverity(Integer severity) { + return severity != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidSeverity(severity); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringLevelRequest that = (SetMonitoringLevelRequest) o; + return Objects.equals(customData, that.customData) && Objects.equals(severity, that.severity); + } + + @Override + public int hashCode() { + return Objects.hash(customData, severity); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("severity", severity) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringLevelResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringLevelResponse.java new file mode 100644 index 000000000..e32cf2e02 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetMonitoringLevelResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetMonitoringLevelResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class SetMonitoringLevelResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the Charging Station was able to accept the request. */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the SetMonitoringLevelResponse class + * + * @param status Whether the Charging Station was able to accept the request. + */ + public SetMonitoringLevelResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringLevelResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station was able to accept the request. + * + * @return Whether the Charging Station was able to accept the request + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station was able to accept the request. + * + * @param status Whether the Charging Station was able to accept the request + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetMonitoringLevelResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringLevelResponse that = (SetMonitoringLevelResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetNetworkProfileRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetNetworkProfileRequest.java new file mode 100644 index 000000000..aac374d9e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetNetworkProfileRequest.java @@ -0,0 +1,217 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.NetworkConnectionProfile; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetNetworkProfileRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class SetNetworkProfileRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Slot in which the configuration should be stored. */ + private Integer configurationSlot; + + /** + * Communication Function + * + *

The NetworkConnectionProfile defines the functional and technical parameters of a + * communication link. + */ + private NetworkConnectionProfile connectionData; + + /** + * Constructor for the SetNetworkProfileRequest class + * + * @param configurationSlot Slot in which the configuration should be stored. + * @param connectionData The NetworkConnectionProfile defines the functional and technical + * parameters of a communication link. + */ + public SetNetworkProfileRequest( + Integer configurationSlot, NetworkConnectionProfile connectionData) { + setConfigurationSlot(configurationSlot); + setConnectionData(connectionData); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetNetworkProfileRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets slot in which the configuration should be stored. + * + * @return Slot in which the configuration should be stored + */ + public Integer getConfigurationSlot() { + return configurationSlot; + } + + /** + * Sets slot in which the configuration should be stored. + * + * @param configurationSlot Slot in which the configuration should be stored + */ + public void setConfigurationSlot(Integer configurationSlot) { + if (!isValidConfigurationSlot(configurationSlot)) { + throw new PropertyConstraintException(configurationSlot, "configurationSlot is invalid"); + } + this.configurationSlot = configurationSlot; + } + + /** + * Returns whether the given configurationSlot is valid + * + * @param configurationSlot the configurationSlot to check the validity of + * @return {@code true} if configurationSlot is valid, {@code false} if not + */ + private boolean isValidConfigurationSlot(Integer configurationSlot) { + return configurationSlot != null; + } + + /** + * Gets the NetworkConnectionProfile defines the functional and technical parameters of a + * communication link. + * + * @return The NetworkConnectionProfile defines the functional and technical parameters of a + * communication link + */ + public NetworkConnectionProfile getConnectionData() { + return connectionData; + } + + /** + * Sets the NetworkConnectionProfile defines the functional and technical parameters of a + * communication link. + * + * @param connectionData The NetworkConnectionProfile defines the functional and technical + * parameters of a communication link + */ + public void setConnectionData(NetworkConnectionProfile connectionData) { + if (!isValidConnectionData(connectionData)) { + throw new PropertyConstraintException(connectionData, "connectionData is invalid"); + } + this.connectionData = connectionData; + } + + /** + * Returns whether the given connectionData is valid + * + * @param connectionData the connectionData to check the validity of + * @return {@code true} if connectionData is valid, {@code false} if not + */ + private boolean isValidConnectionData(NetworkConnectionProfile connectionData) { + return connectionData != null && connectionData.validate(); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidConfigurationSlot(configurationSlot) + && isValidConnectionData(connectionData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetNetworkProfileRequest that = (SetNetworkProfileRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(configurationSlot, that.configurationSlot) + && Objects.equals(connectionData, that.connectionData); + } + + @Override + public int hashCode() { + return Objects.hash(customData, configurationSlot, connectionData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("configurationSlot", configurationSlot) + .add("connectionData", connectionData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetNetworkProfileResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetNetworkProfileResponse.java new file mode 100644 index 000000000..a9a45fcb6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetNetworkProfileResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.SetNetworkProfileStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetNetworkProfileResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class SetNetworkProfileResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Result of operation. */ + private SetNetworkProfileStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the SetNetworkProfileResponse class + * + * @param status Result of operation. + */ + public SetNetworkProfileResponse(SetNetworkProfileStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetNetworkProfileResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets result of operation. + * + * @return Result of operation + */ + public SetNetworkProfileStatusEnum getStatus() { + return status; + } + + /** + * Sets result of operation. + * + * @param status Result of operation + */ + public void setStatus(SetNetworkProfileStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(SetNetworkProfileStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetNetworkProfileResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetNetworkProfileResponse that = (SetNetworkProfileResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariableMonitoringRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariableMonitoringRequest.java new file mode 100644 index 000000000..bed127e03 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariableMonitoringRequest.java @@ -0,0 +1,169 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.SetMonitoringData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetVariableMonitoringRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class SetVariableMonitoringRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** Class to hold parameters of SetVariableMonitoring request. */ + private SetMonitoringData[] setMonitoringData; + + /** + * Constructor for the SetVariableMonitoringRequest class + * + * @param setMonitoringData Class to hold parameters of SetVariableMonitoring request. + */ + public SetVariableMonitoringRequest(SetMonitoringData[] setMonitoringData) { + setSetMonitoringData(setMonitoringData); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariableMonitoringRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets class to hold parameters of SetVariableMonitoring request. + * + * @return Class to hold parameters of SetVariableMonitoring request + */ + public SetMonitoringData[] getSetMonitoringData() { + return setMonitoringData; + } + + /** + * Sets class to hold parameters of SetVariableMonitoring request. + * + * @param setMonitoringData Class to hold parameters of SetVariableMonitoring request + */ + public void setSetMonitoringData(SetMonitoringData[] setMonitoringData) { + if (!isValidSetMonitoringData(setMonitoringData)) { + throw new PropertyConstraintException(setMonitoringData, "setMonitoringData is invalid"); + } + this.setMonitoringData = setMonitoringData; + } + + /** + * Returns whether the given setMonitoringData is valid + * + * @param setMonitoringData the setMonitoringData to check the validity of + * @return {@code true} if setMonitoringData is valid, {@code false} if not + */ + private boolean isValidSetMonitoringData(SetMonitoringData[] setMonitoringData) { + return setMonitoringData != null + && setMonitoringData.length >= 1 + && Arrays.stream(setMonitoringData).allMatch(item -> item.validate()); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidSetMonitoringData(setMonitoringData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariableMonitoringRequest that = (SetVariableMonitoringRequest) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(setMonitoringData, that.setMonitoringData); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(setMonitoringData)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("setMonitoringData", setMonitoringData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariableMonitoringResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariableMonitoringResponse.java new file mode 100644 index 000000000..4cd581387 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariableMonitoringResponse.java @@ -0,0 +1,164 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.SetMonitoringResult; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetVariableMonitoringResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class SetVariableMonitoringResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Class to hold result of SetVariableMonitoring request. */ + private SetMonitoringResult[] setMonitoringResult; + + /** + * Constructor for the SetVariableMonitoringResponse class + * + * @param setMonitoringResult Class to hold result of SetVariableMonitoring request. + */ + public SetVariableMonitoringResponse(SetMonitoringResult[] setMonitoringResult) { + setSetMonitoringResult(setMonitoringResult); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariableMonitoringResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets class to hold result of SetVariableMonitoring request. + * + * @return Class to hold result of SetVariableMonitoring request + */ + public SetMonitoringResult[] getSetMonitoringResult() { + return setMonitoringResult; + } + + /** + * Sets class to hold result of SetVariableMonitoring request. + * + * @param setMonitoringResult Class to hold result of SetVariableMonitoring request + */ + public void setSetMonitoringResult(SetMonitoringResult[] setMonitoringResult) { + if (!isValidSetMonitoringResult(setMonitoringResult)) { + throw new PropertyConstraintException(setMonitoringResult, "setMonitoringResult is invalid"); + } + this.setMonitoringResult = setMonitoringResult; + } + + /** + * Returns whether the given setMonitoringResult is valid + * + * @param setMonitoringResult the setMonitoringResult to check the validity of + * @return {@code true} if setMonitoringResult is valid, {@code false} if not + */ + private boolean isValidSetMonitoringResult(SetMonitoringResult[] setMonitoringResult) { + return setMonitoringResult != null + && setMonitoringResult.length >= 1 + && Arrays.stream(setMonitoringResult).allMatch(item -> item.validate()); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidSetMonitoringResult(setMonitoringResult); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariableMonitoringResponse that = (SetVariableMonitoringResponse) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(setMonitoringResult, that.setMonitoringResult); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(setMonitoringResult)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("setMonitoringResult", setMonitoringResult) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariablesRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariablesRequest.java new file mode 100644 index 000000000..89785fdc5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariablesRequest.java @@ -0,0 +1,169 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.SetVariableData; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetVariablesRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class SetVariablesRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** setVariableData */ + private SetVariableData[] setVariableData; + + /** + * Constructor for the SetVariablesRequest class + * + * @param setVariableData setVariableData + */ + public SetVariablesRequest(SetVariableData[] setVariableData) { + setSetVariableData(setVariableData); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariablesRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets setVariableData + * + * @return setVariableData + */ + public SetVariableData[] getSetVariableData() { + return setVariableData; + } + + /** + * Sets setVariableData + * + * @param setVariableData setVariableData + */ + public void setSetVariableData(SetVariableData[] setVariableData) { + if (!isValidSetVariableData(setVariableData)) { + throw new PropertyConstraintException(setVariableData, "setVariableData is invalid"); + } + this.setVariableData = setVariableData; + } + + /** + * Returns whether the given setVariableData is valid + * + * @param setVariableData the setVariableData to check the validity of + * @return {@code true} if setVariableData is valid, {@code false} if not + */ + private boolean isValidSetVariableData(SetVariableData[] setVariableData) { + return setVariableData != null + && setVariableData.length >= 1 + && Arrays.stream(setVariableData).allMatch(item -> item.validate()); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidSetVariableData(setVariableData); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariablesRequest that = (SetVariablesRequest) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(setVariableData, that.setVariableData); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(setVariableData)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("setVariableData", setVariableData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariablesResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariablesResponse.java new file mode 100644 index 000000000..b2b37ea16 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SetVariablesResponse.java @@ -0,0 +1,164 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.SetVariableResult; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SetVariablesResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class SetVariablesResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** setVariableResult */ + private SetVariableResult[] setVariableResult; + + /** + * Constructor for the SetVariablesResponse class + * + * @param setVariableResult setVariableResult + */ + public SetVariablesResponse(SetVariableResult[] setVariableResult) { + setSetVariableResult(setVariableResult); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariablesResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets setVariableResult + * + * @return setVariableResult + */ + public SetVariableResult[] getSetVariableResult() { + return setVariableResult; + } + + /** + * Sets setVariableResult + * + * @param setVariableResult setVariableResult + */ + public void setSetVariableResult(SetVariableResult[] setVariableResult) { + if (!isValidSetVariableResult(setVariableResult)) { + throw new PropertyConstraintException(setVariableResult, "setVariableResult is invalid"); + } + this.setVariableResult = setVariableResult; + } + + /** + * Returns whether the given setVariableResult is valid + * + * @param setVariableResult the setVariableResult to check the validity of + * @return {@code true} if setVariableResult is valid, {@code false} if not + */ + private boolean isValidSetVariableResult(SetVariableResult[] setVariableResult) { + return setVariableResult != null + && setVariableResult.length >= 1 + && Arrays.stream(setVariableResult).allMatch(item -> item.validate()); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidSetVariableResult(setVariableResult); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariablesResponse that = (SetVariablesResponse) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(setVariableResult, that.setVariableResult); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(setVariableResult)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("setVariableResult", setVariableResult) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SignCertificateRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SignCertificateRequest.java new file mode 100644 index 000000000..e4233907e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SignCertificateRequest.java @@ -0,0 +1,221 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CertificateSigningUseEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SignCertificateRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class SignCertificateRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * The Charging Station SHALL send the public key in form of a Certificate Signing Request (CSR) + * as described in RFC 2986 [22] and then PEM encoded, using the SignCertificateRequest message. + */ + private String csr; + + /** + * The type of certificate that is to be signed. When omitted the certificate is to be used for + * both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + */ + @Nullable private CertificateSigningUseEnum certificateType; + + /** + * Constructor for the SignCertificateRequest class + * + * @param csr The Charging Station SHALL send the public key in form of a Certificate Signing + * Request (CSR) as described in RFC 2986 [22] and then PEM encoded, using the + * SignCertificateRequest message. + */ + public SignCertificateRequest(String csr) { + setCsr(csr); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SignCertificateRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the Charging Station SHALL send the public key in form of a Certificate Signing Request + * (CSR) as described in RFC 2986 [22] and then PEM encoded, using the SignCertificateRequest + * message. + * + * @return The Charging Station SHALL send the public key in form of a Certificate Signing Request + * (CSR) as described in RFC 2986 [22] and then PEM encoded, using the SignCertificateRequest + * message + */ + public String getCsr() { + return csr; + } + + /** + * Sets the Charging Station SHALL send the public key in form of a Certificate Signing Request + * (CSR) as described in RFC 2986 [22] and then PEM encoded, using the SignCertificateRequest + * message. + * + * @param csr The Charging Station SHALL send the public key in form of a Certificate Signing + * Request (CSR) as described in RFC 2986 [22] and then PEM encoded, using the + * SignCertificateRequest message + */ + public void setCsr(String csr) { + if (!isValidCsr(csr)) { + throw new PropertyConstraintException(csr, "csr is invalid"); + } + this.csr = csr; + } + + /** + * Returns whether the given csr is valid + * + * @param csr the csr to check the validity of + * @return {@code true} if csr is valid, {@code false} if not + */ + private boolean isValidCsr(String csr) { + return csr != null && csr.length() <= 5500; + } + + /** + * Gets the type of certificate that is to be signed. When omitted the certificate is to be used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * + * @return The type of certificate that is to be signed + */ + @Nullable + public CertificateSigningUseEnum getCertificateType() { + return certificateType; + } + + /** + * Sets the type of certificate that is to be signed. When omitted the certificate is to be used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * + * @param certificateType The type of certificate that is to be signed + */ + public void setCertificateType(@Nullable CertificateSigningUseEnum certificateType) { + this.certificateType = certificateType; + } + + /** + * Adds the type of certificate that is to be signed. When omitted the certificate is to be used + * for both the 15118 connection (if implemented) and the Charging Station to CSMS connection. + * + * @param certificateType The type of certificate that is to be signed + * @return this + */ + public SignCertificateRequest withCertificateType( + @Nullable CertificateSigningUseEnum certificateType) { + setCertificateType(certificateType); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidCsr(csr); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SignCertificateRequest that = (SignCertificateRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(csr, that.csr) + && Objects.equals(certificateType, that.certificateType); + } + + @Override + public int hashCode() { + return Objects.hash(customData, csr, certificateType); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("csr", csr) + .add("certificateType", certificateType) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SignCertificateResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SignCertificateResponse.java new file mode 100644 index 000000000..cea21f39e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/SignCertificateResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.GenericStatusEnum; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * SignCertificateResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class SignCertificateResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Specifies whether the CSMS can process the request. */ + private GenericStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the SignCertificateResponse class + * + * @param status Specifies whether the CSMS can process the request. + */ + public SignCertificateResponse(GenericStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SignCertificateResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets specifies whether the CSMS can process the request. + * + * @return Specifies whether the CSMS can process the request + */ + public GenericStatusEnum getStatus() { + return status; + } + + /** + * Sets specifies whether the CSMS can process the request. + * + * @param status Specifies whether the CSMS can process the request + */ + public void setStatus(GenericStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(GenericStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SignCertificateResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SignCertificateResponse that = (SignCertificateResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/StatusNotificationRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/StatusNotificationRequest.java new file mode 100644 index 000000000..2f2499028 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/StatusNotificationRequest.java @@ -0,0 +1,297 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.ConnectorStatusEnum; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * StatusNotificationRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class StatusNotificationRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * The time for which the status is reported. If absent time of receipt of the message will be + * assumed. + */ + private ZonedDateTime timestamp; + + /** The current status of the Connector. */ + private ConnectorStatusEnum connectorStatus; + + /** The id of the EVSE to which the connector belongs for which the the status is reported. */ + private Integer evseId; + + /** The id of the connector within the EVSE for which the status is reported. */ + private Integer connectorId; + + /** + * Constructor for the StatusNotificationRequest class + * + * @param timestamp The time for which the status is reported. If absent time of receipt of the + * message will be assumed. + * @param connectorStatus The current status of the Connector. + * @param evseId The id of the EVSE to which the connector belongs for which the the status is + * reported. + * @param connectorId The id of the connector within the EVSE for which the status is reported. + */ + public StatusNotificationRequest( + ZonedDateTime timestamp, + ConnectorStatusEnum connectorStatus, + Integer evseId, + Integer connectorId) { + setTimestamp(timestamp); + setConnectorStatus(connectorStatus); + setEvseId(evseId); + setConnectorId(connectorId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public StatusNotificationRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the time for which the status is reported. If absent time of receipt of the message will + * be assumed. + * + * @return The time for which the status is reported + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets the time for which the status is reported. If absent time of receipt of the message will + * be assumed. + * + * @param timestamp The time for which the status is reported + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets the current status of the Connector. + * + * @return The current status of the Connector + */ + public ConnectorStatusEnum getConnectorStatus() { + return connectorStatus; + } + + /** + * Sets the current status of the Connector. + * + * @param connectorStatus The current status of the Connector + */ + public void setConnectorStatus(ConnectorStatusEnum connectorStatus) { + if (!isValidConnectorStatus(connectorStatus)) { + throw new PropertyConstraintException(connectorStatus, "connectorStatus is invalid"); + } + this.connectorStatus = connectorStatus; + } + + /** + * Returns whether the given connectorStatus is valid + * + * @param connectorStatus the connectorStatus to check the validity of + * @return {@code true} if connectorStatus is valid, {@code false} if not + */ + private boolean isValidConnectorStatus(ConnectorStatusEnum connectorStatus) { + return connectorStatus != null; + } + + /** + * Gets the id of the EVSE to which the connector belongs for which the the status is reported. + * + * @return The id of the EVSE to which the connector belongs for which the the status is reported + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the id of the EVSE to which the connector belongs for which the the status is reported. + * + * @param evseId The id of the EVSE to which the connector belongs for which the the status is + * reported + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null; + } + + /** + * Gets the id of the connector within the EVSE for which the status is reported. + * + * @return The id of the connector within the EVSE for which the status is reported + */ + public Integer getConnectorId() { + return connectorId; + } + + /** + * Sets the id of the connector within the EVSE for which the status is reported. + * + * @param connectorId The id of the connector within the EVSE for which the status is reported + */ + public void setConnectorId(Integer connectorId) { + if (!isValidConnectorId(connectorId)) { + throw new PropertyConstraintException(connectorId, "connectorId is invalid"); + } + this.connectorId = connectorId; + } + + /** + * Returns whether the given connectorId is valid + * + * @param connectorId the connectorId to check the validity of + * @return {@code true} if connectorId is valid, {@code false} if not + */ + private boolean isValidConnectorId(Integer connectorId) { + return connectorId != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidTimestamp(timestamp) + && isValidConnectorStatus(connectorStatus) + && isValidEvseId(evseId) + && isValidConnectorId(connectorId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StatusNotificationRequest that = (StatusNotificationRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(connectorStatus, that.connectorStatus) + && Objects.equals(evseId, that.evseId) + && Objects.equals(connectorId, that.connectorId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, timestamp, connectorStatus, evseId, connectorId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("timestamp", timestamp) + .add("connectorStatus", connectorStatus) + .add("evseId", evseId) + .add("connectorId", connectorId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/StatusNotificationResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/StatusNotificationResponse.java new file mode 100644 index 000000000..13cba4921 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/StatusNotificationResponse.java @@ -0,0 +1,118 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * StatusNotificationResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class StatusNotificationResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Constructor for the StatusNotificationResponse class */ + public StatusNotificationResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public StatusNotificationResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StatusNotificationResponse that = (StatusNotificationResponse) o; + return Objects.equals(customData, that.customData); + } + + @Override + public int hashCode() { + return Objects.hash(customData); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TransactionEventRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TransactionEventRequest.java new file mode 100644 index 000000000..e09d0e4da --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TransactionEventRequest.java @@ -0,0 +1,696 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.EVSE; +import eu.chargetime.ocpp.v201.model.types.IdToken; +import eu.chargetime.ocpp.v201.model.types.MeterValue; +import eu.chargetime.ocpp.v201.model.types.Transaction; +import eu.chargetime.ocpp.v201.model.types.TransactionEventEnum; +import eu.chargetime.ocpp.v201.model.types.TriggerReasonEnum; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * TransactionEventRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class TransactionEventRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * The type of this event. The first TransactionEvent of a transaction SHALL contain: "Started" + * The last TransactionEvent of a transaction SHALL contain: "Ended" All others SHALL contain: + * "Updated" + */ + private TransactionEventEnum eventType; + + /** + * Meter Value + * + *

Collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + */ + @Nullable private MeterValue[] meterValue; + + /** The date and time at which this transaction event occurred. */ + private ZonedDateTime timestamp; + + /** Reason the Charging Station sends this message to the CSMS */ + private TriggerReasonEnum triggerReason; + + /** + * Incremental sequence number, helps with determining if all messages of a transaction have been + * received. + */ + private Integer seqNo; + + /** + * Indication that this transaction event happened when the Charging Station was offline. Default + * = false, meaning: the event occurred when the Charging Station was online. + */ + @Nullable private Boolean offline; + + /** + * If the Charging Station is able to report the number of phases used, then it SHALL provide it. + * When omitted the CSMS may be able to determine the number of phases used via device management. + */ + @Nullable private Integer numberOfPhasesUsed; + + /** The maximum current of the connected cable in Ampere (A). */ + @Nullable private Integer cableMaxCurrent; + + /** The Id of the reservation that terminates as a result of this transaction. */ + @Nullable private Integer reservationId; + + /** Transaction */ + private Transaction transactionInfo; + + /** + * EVSE + * + *

Electric Vehicle Supply Equipment + */ + @Nullable private EVSE evse; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private IdToken idToken; + + /** + * Constructor for the TransactionEventRequest class + * + * @param eventType The type of this event. The first TransactionEvent of a transaction SHALL + * contain: "Started" The last TransactionEvent of a transaction SHALL contain: "Ended" All + * others SHALL contain: "Updated" + * @param timestamp The date and time at which this transaction event occurred. + * @param triggerReason Reason the Charging Station sends this message to the CSMS + * @param seqNo Incremental sequence number, helps with determining if all messages of a + * transaction have been received. + * @param transactionInfo Transaction + */ + public TransactionEventRequest( + TransactionEventEnum eventType, + ZonedDateTime timestamp, + TriggerReasonEnum triggerReason, + Integer seqNo, + Transaction transactionInfo) { + setEventType(eventType); + setTimestamp(timestamp); + setTriggerReason(triggerReason); + setSeqNo(seqNo); + setTransactionInfo(transactionInfo); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TransactionEventRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the type of this event. The first TransactionEvent of a transaction SHALL contain: + * "Started" The last TransactionEvent of a transaction SHALL contain: "Ended" All others SHALL + * contain: "Updated" + * + * @return The type of this event + */ + public TransactionEventEnum getEventType() { + return eventType; + } + + /** + * Sets the type of this event. The first TransactionEvent of a transaction SHALL contain: + * "Started" The last TransactionEvent of a transaction SHALL contain: "Ended" All others SHALL + * contain: "Updated" + * + * @param eventType The type of this event + */ + public void setEventType(TransactionEventEnum eventType) { + if (!isValidEventType(eventType)) { + throw new PropertyConstraintException(eventType, "eventType is invalid"); + } + this.eventType = eventType; + } + + /** + * Returns whether the given eventType is valid + * + * @param eventType the eventType to check the validity of + * @return {@code true} if eventType is valid, {@code false} if not + */ + private boolean isValidEventType(TransactionEventEnum eventType) { + return eventType != null; + } + + /** + * Gets collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + * + * @return Collection of one or more sampled values in MeterValuesRequest and TransactionEvent + */ + @Nullable + public MeterValue[] getMeterValue() { + return meterValue; + } + + /** + * Sets collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + * + * @param meterValue Collection of one or more sampled values in MeterValuesRequest and + * TransactionEvent + */ + public void setMeterValue(@Nullable MeterValue[] meterValue) { + if (!isValidMeterValue(meterValue)) { + throw new PropertyConstraintException(meterValue, "meterValue is invalid"); + } + this.meterValue = meterValue; + } + + /** + * Returns whether the given meterValue is valid + * + * @param meterValue the meterValue to check the validity of + * @return {@code true} if meterValue is valid, {@code false} if not + */ + private boolean isValidMeterValue(@Nullable MeterValue[] meterValue) { + return meterValue == null + || (meterValue.length >= 1 && Arrays.stream(meterValue).allMatch(item -> item.validate())); + } + + /** + * Adds collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + * + * @param meterValue Collection of one or more sampled values in MeterValuesRequest and + * TransactionEvent + * @return this + */ + public TransactionEventRequest withMeterValue(@Nullable MeterValue[] meterValue) { + setMeterValue(meterValue); + return this; + } + + /** + * Gets the date and time at which this transaction event occurred. + * + * @return The date and time at which this transaction event occurred + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets the date and time at which this transaction event occurred. + * + * @param timestamp The date and time at which this transaction event occurred + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets reason the Charging Station sends this message to the CSMS + * + * @return Reason the Charging Station sends this message to the CSMS + */ + public TriggerReasonEnum getTriggerReason() { + return triggerReason; + } + + /** + * Sets reason the Charging Station sends this message to the CSMS + * + * @param triggerReason Reason the Charging Station sends this message to the CSMS + */ + public void setTriggerReason(TriggerReasonEnum triggerReason) { + if (!isValidTriggerReason(triggerReason)) { + throw new PropertyConstraintException(triggerReason, "triggerReason is invalid"); + } + this.triggerReason = triggerReason; + } + + /** + * Returns whether the given triggerReason is valid + * + * @param triggerReason the triggerReason to check the validity of + * @return {@code true} if triggerReason is valid, {@code false} if not + */ + private boolean isValidTriggerReason(TriggerReasonEnum triggerReason) { + return triggerReason != null; + } + + /** + * Gets incremental sequence number, helps with determining if all messages of a transaction have + * been received. + * + * @return Incremental sequence number, helps with determining if all messages of a transaction + * have been received + */ + public Integer getSeqNo() { + return seqNo; + } + + /** + * Sets incremental sequence number, helps with determining if all messages of a transaction have + * been received. + * + * @param seqNo Incremental sequence number, helps with determining if all messages of a + * transaction have been received + */ + public void setSeqNo(Integer seqNo) { + if (!isValidSeqNo(seqNo)) { + throw new PropertyConstraintException(seqNo, "seqNo is invalid"); + } + this.seqNo = seqNo; + } + + /** + * Returns whether the given seqNo is valid + * + * @param seqNo the seqNo to check the validity of + * @return {@code true} if seqNo is valid, {@code false} if not + */ + private boolean isValidSeqNo(Integer seqNo) { + return seqNo != null; + } + + /** + * Gets indication that this transaction event happened when the Charging Station was offline. + * Default = false, meaning: the event occurred when the Charging Station was online. + * + * @return Indication that this transaction event happened when the Charging Station was offline + */ + public Boolean getOffline() { + return offline != null ? offline : false; + } + + /** + * Sets indication that this transaction event happened when the Charging Station was offline. + * Default = false, meaning: the event occurred when the Charging Station was online. + * + * @param offline Indication that this transaction event happened when the Charging Station was + * offline + */ + public void setOffline(@Nullable Boolean offline) { + this.offline = offline; + } + + /** + * Adds indication that this transaction event happened when the Charging Station was offline. + * Default = false, meaning: the event occurred when the Charging Station was online. + * + * @param offline Indication that this transaction event happened when the Charging Station was + * offline + * @return this + */ + public TransactionEventRequest withOffline(@Nullable Boolean offline) { + setOffline(offline); + return this; + } + + /** + * Gets if the Charging Station is able to report the number of phases used, then it SHALL provide + * it. When omitted the CSMS may be able to determine the number of phases used via device + * management. + * + * @return If the Charging Station is able to report the number of phases used, then it SHALL + * provide it + */ + @Nullable + public Integer getNumberOfPhasesUsed() { + return numberOfPhasesUsed; + } + + /** + * Sets if the Charging Station is able to report the number of phases used, then it SHALL provide + * it. When omitted the CSMS may be able to determine the number of phases used via device + * management. + * + * @param numberOfPhasesUsed If the Charging Station is able to report the number of phases used, + * then it SHALL provide it + */ + public void setNumberOfPhasesUsed(@Nullable Integer numberOfPhasesUsed) { + this.numberOfPhasesUsed = numberOfPhasesUsed; + } + + /** + * Adds if the Charging Station is able to report the number of phases used, then it SHALL provide + * it. When omitted the CSMS may be able to determine the number of phases used via device + * management. + * + * @param numberOfPhasesUsed If the Charging Station is able to report the number of phases used, + * then it SHALL provide it + * @return this + */ + public TransactionEventRequest withNumberOfPhasesUsed(@Nullable Integer numberOfPhasesUsed) { + setNumberOfPhasesUsed(numberOfPhasesUsed); + return this; + } + + /** + * Gets the maximum current of the connected cable in Ampere (A). + * + * @return The maximum current of the connected cable in Ampere (A) + */ + @Nullable + public Integer getCableMaxCurrent() { + return cableMaxCurrent; + } + + /** + * Sets the maximum current of the connected cable in Ampere (A). + * + * @param cableMaxCurrent The maximum current of the connected cable in Ampere (A) + */ + public void setCableMaxCurrent(@Nullable Integer cableMaxCurrent) { + this.cableMaxCurrent = cableMaxCurrent; + } + + /** + * Adds the maximum current of the connected cable in Ampere (A). + * + * @param cableMaxCurrent The maximum current of the connected cable in Ampere (A) + * @return this + */ + public TransactionEventRequest withCableMaxCurrent(@Nullable Integer cableMaxCurrent) { + setCableMaxCurrent(cableMaxCurrent); + return this; + } + + /** + * Gets the Id of the reservation that terminates as a result of this transaction. + * + * @return The Id of the reservation that terminates as a result of this transaction + */ + @Nullable + public Integer getReservationId() { + return reservationId; + } + + /** + * Sets the Id of the reservation that terminates as a result of this transaction. + * + * @param reservationId The Id of the reservation that terminates as a result of this transaction + */ + public void setReservationId(@Nullable Integer reservationId) { + this.reservationId = reservationId; + } + + /** + * Adds the Id of the reservation that terminates as a result of this transaction. + * + * @param reservationId The Id of the reservation that terminates as a result of this transaction + * @return this + */ + public TransactionEventRequest withReservationId(@Nullable Integer reservationId) { + setReservationId(reservationId); + return this; + } + + /** + * Gets transaction + * + * @return Transaction + */ + public Transaction getTransactionInfo() { + return transactionInfo; + } + + /** + * Sets transaction + * + * @param transactionInfo Transaction + */ + public void setTransactionInfo(Transaction transactionInfo) { + if (!isValidTransactionInfo(transactionInfo)) { + throw new PropertyConstraintException(transactionInfo, "transactionInfo is invalid"); + } + this.transactionInfo = transactionInfo; + } + + /** + * Returns whether the given transactionInfo is valid + * + * @param transactionInfo the transactionInfo to check the validity of + * @return {@code true} if transactionInfo is valid, {@code false} if not + */ + private boolean isValidTransactionInfo(Transaction transactionInfo) { + return transactionInfo != null && transactionInfo.validate(); + } + + /** + * Gets electric Vehicle Supply Equipment + * + * @return Electric Vehicle Supply Equipment + */ + @Nullable + public EVSE getEvse() { + return evse; + } + + /** + * Sets electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + */ + public void setEvse(@Nullable EVSE evse) { + if (!isValidEvse(evse)) { + throw new PropertyConstraintException(evse, "evse is invalid"); + } + this.evse = evse; + } + + /** + * Returns whether the given evse is valid + * + * @param evse the evse to check the validity of + * @return {@code true} if evse is valid, {@code false} if not + */ + private boolean isValidEvse(@Nullable EVSE evse) { + return evse == null || evse.validate(); + } + + /** + * Adds electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + * @return this + */ + public TransactionEventRequest withEvse(@Nullable EVSE evse) { + setEvse(evse); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(@Nullable IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(@Nullable IdToken idToken) { + return idToken == null || idToken.validate(); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + * @return this + */ + public TransactionEventRequest withIdToken(@Nullable IdToken idToken) { + setIdToken(idToken); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidEventType(eventType) + && isValidMeterValue(meterValue) + && isValidTimestamp(timestamp) + && isValidTriggerReason(triggerReason) + && isValidSeqNo(seqNo) + && isValidTransactionInfo(transactionInfo) + && isValidEvse(evse) + && isValidIdToken(idToken); + } + + @Override + public boolean transactionRelated() { + return true; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TransactionEventRequest that = (TransactionEventRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(eventType, that.eventType) + && Arrays.equals(meterValue, that.meterValue) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(triggerReason, that.triggerReason) + && Objects.equals(seqNo, that.seqNo) + && Objects.equals(offline, that.offline) + && Objects.equals(numberOfPhasesUsed, that.numberOfPhasesUsed) + && Objects.equals(cableMaxCurrent, that.cableMaxCurrent) + && Objects.equals(reservationId, that.reservationId) + && Objects.equals(transactionInfo, that.transactionInfo) + && Objects.equals(evse, that.evse) + && Objects.equals(idToken, that.idToken); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + eventType, + Arrays.hashCode(meterValue), + timestamp, + triggerReason, + seqNo, + offline, + numberOfPhasesUsed, + cableMaxCurrent, + reservationId, + transactionInfo, + evse, + idToken); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("eventType", eventType) + .add("meterValue", meterValue) + .add("timestamp", timestamp) + .add("triggerReason", triggerReason) + .add("seqNo", seqNo) + .add("offline", offline) + .add("numberOfPhasesUsed", numberOfPhasesUsed) + .add("cableMaxCurrent", cableMaxCurrent) + .add("reservationId", reservationId) + .add("transactionInfo", transactionInfo) + .add("evse", evse) + .add("idToken", idToken) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TransactionEventResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TransactionEventResponse.java new file mode 100644 index 000000000..735df87f7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TransactionEventResponse.java @@ -0,0 +1,336 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.IdTokenInfo; +import eu.chargetime.ocpp.v201.model.types.MessageContent; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * TransactionEventResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class TransactionEventResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * SHALL only be sent when charging has ended. Final total cost of this transaction, including + * taxes. In the currency configured with the Configuration Variable: `Currency`. When omitted, + * the transaction was NOT free. To indicate a free transaction, the CSMS SHALL send 0.00. + */ + @Nullable private Double totalCost; + + /** + * Priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse is + * temporarily, so it may not be set in the IdTokenInfoType afterwards. Also the chargingPriority + * in TransactionEventResponse overrules the one in IdTokenInfoType. + */ + @Nullable private Integer chargingPriority; + + /** + * ID Token + * + *

Status information about an identifier. It is advised to not stop charging for a token that + * expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not + * given, the status has no end date. + */ + @Nullable private IdTokenInfo idTokenInfo; + + /** + * Message Content + * + *

Message details, for a message to be displayed on a Charging Station. + */ + @Nullable private MessageContent updatedPersonalMessage; + + /** Constructor for the TransactionEventResponse class */ + public TransactionEventResponse() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TransactionEventResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets SHALL only be sent when charging has ended. Final total cost of this transaction, + * including taxes. In the currency configured with the Configuration Variable: `Currency`. When + * omitted, the transaction was NOT free. To indicate a free transaction, the CSMS SHALL send + * 0.00. + * + * @return SHALL only be sent when charging has ended + */ + @Nullable + public Double getTotalCost() { + return totalCost; + } + + /** + * Sets SHALL only be sent when charging has ended. Final total cost of this transaction, + * including taxes. In the currency configured with the Configuration Variable: `Currency`. When + * omitted, the transaction was NOT free. To indicate a free transaction, the CSMS SHALL send + * 0.00. + * + * @param totalCost SHALL only be sent when charging has ended + */ + public void setTotalCost(@Nullable Double totalCost) { + this.totalCost = totalCost; + } + + /** + * Adds SHALL only be sent when charging has ended. Final total cost of this transaction, + * including taxes. In the currency configured with the Configuration Variable: `Currency`. When + * omitted, the transaction was NOT free. To indicate a free transaction, the CSMS SHALL send + * 0.00. + * + * @param totalCost SHALL only be sent when charging has ended + * @return this + */ + public TransactionEventResponse withTotalCost(@Nullable Double totalCost) { + setTotalCost(totalCost); + return this; + } + + /** + * Gets priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse is + * temporarily, so it may not be set in the IdTokenInfoType afterwards. Also the chargingPriority + * in TransactionEventResponse overrules the one in IdTokenInfoType. + * + * @return Priority from a business point of view + */ + @Nullable + public Integer getChargingPriority() { + return chargingPriority; + } + + /** + * Sets priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse is + * temporarily, so it may not be set in the IdTokenInfoType afterwards. Also the chargingPriority + * in TransactionEventResponse overrules the one in IdTokenInfoType. + * + * @param chargingPriority Priority from a business point of view + */ + public void setChargingPriority(@Nullable Integer chargingPriority) { + this.chargingPriority = chargingPriority; + } + + /** + * Adds priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse is + * temporarily, so it may not be set in the IdTokenInfoType afterwards. Also the chargingPriority + * in TransactionEventResponse overrules the one in IdTokenInfoType. + * + * @param chargingPriority Priority from a business point of view + * @return this + */ + public TransactionEventResponse withChargingPriority(@Nullable Integer chargingPriority) { + setChargingPriority(chargingPriority); + return this; + } + + /** + * Gets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @return Status information about an identifier + */ + @Nullable + public IdTokenInfo getIdTokenInfo() { + return idTokenInfo; + } + + /** + * Sets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @param idTokenInfo Status information about an identifier + */ + public void setIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + if (!isValidIdTokenInfo(idTokenInfo)) { + throw new PropertyConstraintException(idTokenInfo, "idTokenInfo is invalid"); + } + this.idTokenInfo = idTokenInfo; + } + + /** + * Returns whether the given idTokenInfo is valid + * + * @param idTokenInfo the idTokenInfo to check the validity of + * @return {@code true} if idTokenInfo is valid, {@code false} if not + */ + private boolean isValidIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + return idTokenInfo == null || idTokenInfo.validate(); + } + + /** + * Adds status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @param idTokenInfo Status information about an identifier + * @return this + */ + public TransactionEventResponse withIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + setIdTokenInfo(idTokenInfo); + return this; + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + @Nullable + public MessageContent getUpdatedPersonalMessage() { + return updatedPersonalMessage; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param updatedPersonalMessage Message details, for a message to be displayed on a Charging + * Station + */ + public void setUpdatedPersonalMessage(@Nullable MessageContent updatedPersonalMessage) { + if (!isValidUpdatedPersonalMessage(updatedPersonalMessage)) { + throw new PropertyConstraintException( + updatedPersonalMessage, "updatedPersonalMessage is invalid"); + } + this.updatedPersonalMessage = updatedPersonalMessage; + } + + /** + * Returns whether the given updatedPersonalMessage is valid + * + * @param updatedPersonalMessage the updatedPersonalMessage to check the validity of + * @return {@code true} if updatedPersonalMessage is valid, {@code false} if not + */ + private boolean isValidUpdatedPersonalMessage(@Nullable MessageContent updatedPersonalMessage) { + return updatedPersonalMessage == null || updatedPersonalMessage.validate(); + } + + /** + * Adds message details, for a message to be displayed on a Charging Station. + * + * @param updatedPersonalMessage Message details, for a message to be displayed on a Charging + * Station + * @return this + */ + public TransactionEventResponse withUpdatedPersonalMessage( + @Nullable MessageContent updatedPersonalMessage) { + setUpdatedPersonalMessage(updatedPersonalMessage); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidIdTokenInfo(idTokenInfo) + && isValidUpdatedPersonalMessage(updatedPersonalMessage); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TransactionEventResponse that = (TransactionEventResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(totalCost, that.totalCost) + && Objects.equals(chargingPriority, that.chargingPriority) + && Objects.equals(idTokenInfo, that.idTokenInfo) + && Objects.equals(updatedPersonalMessage, that.updatedPersonalMessage); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, totalCost, chargingPriority, idTokenInfo, updatedPersonalMessage); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("totalCost", totalCost) + .add("chargingPriority", chargingPriority) + .add("idTokenInfo", idTokenInfo) + .add("updatedPersonalMessage", updatedPersonalMessage) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TriggerMessageRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TriggerMessageRequest.java new file mode 100644 index 000000000..f67ec5466 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TriggerMessageRequest.java @@ -0,0 +1,221 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.EVSE; +import eu.chargetime.ocpp.v201.model.types.MessageTriggerEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * TriggerMessageRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class TriggerMessageRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * EVSE + * + *

Electric Vehicle Supply Equipment + */ + @Nullable private EVSE evse; + + /** Type of message to be triggered. */ + private MessageTriggerEnum requestedMessage; + + /** + * Constructor for the TriggerMessageRequest class + * + * @param requestedMessage Type of message to be triggered. + */ + public TriggerMessageRequest(MessageTriggerEnum requestedMessage) { + setRequestedMessage(requestedMessage); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TriggerMessageRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets electric Vehicle Supply Equipment + * + * @return Electric Vehicle Supply Equipment + */ + @Nullable + public EVSE getEvse() { + return evse; + } + + /** + * Sets electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + */ + public void setEvse(@Nullable EVSE evse) { + if (!isValidEvse(evse)) { + throw new PropertyConstraintException(evse, "evse is invalid"); + } + this.evse = evse; + } + + /** + * Returns whether the given evse is valid + * + * @param evse the evse to check the validity of + * @return {@code true} if evse is valid, {@code false} if not + */ + private boolean isValidEvse(@Nullable EVSE evse) { + return evse == null || evse.validate(); + } + + /** + * Adds electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + * @return this + */ + public TriggerMessageRequest withEvse(@Nullable EVSE evse) { + setEvse(evse); + return this; + } + + /** + * Gets type of message to be triggered. + * + * @return Type of message to be triggered + */ + public MessageTriggerEnum getRequestedMessage() { + return requestedMessage; + } + + /** + * Sets type of message to be triggered. + * + * @param requestedMessage Type of message to be triggered + */ + public void setRequestedMessage(MessageTriggerEnum requestedMessage) { + if (!isValidRequestedMessage(requestedMessage)) { + throw new PropertyConstraintException(requestedMessage, "requestedMessage is invalid"); + } + this.requestedMessage = requestedMessage; + } + + /** + * Returns whether the given requestedMessage is valid + * + * @param requestedMessage the requestedMessage to check the validity of + * @return {@code true} if requestedMessage is valid, {@code false} if not + */ + private boolean isValidRequestedMessage(MessageTriggerEnum requestedMessage) { + return requestedMessage != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidEvse(evse) + && isValidRequestedMessage(requestedMessage); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerMessageRequest that = (TriggerMessageRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(evse, that.evse) + && Objects.equals(requestedMessage, that.requestedMessage); + } + + @Override + public int hashCode() { + return Objects.hash(customData, evse, requestedMessage); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("evse", evse) + .add("requestedMessage", requestedMessage) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TriggerMessageResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TriggerMessageResponse.java new file mode 100644 index 000000000..f54a9f029 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/TriggerMessageResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import eu.chargetime.ocpp.v201.model.types.TriggerMessageStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * TriggerMessageResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class TriggerMessageResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the Charging Station will send the requested notification or not. */ + private TriggerMessageStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the TriggerMessageResponse class + * + * @param status Whether the Charging Station will send the requested notification or not. + */ + public TriggerMessageResponse(TriggerMessageStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public TriggerMessageResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station will send the requested notification or not. + * + * @return Whether the Charging Station will send the requested notification or not + */ + public TriggerMessageStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station will send the requested notification or not. + * + * @param status Whether the Charging Station will send the requested notification or not + */ + public void setStatus(TriggerMessageStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(TriggerMessageStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public TriggerMessageResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TriggerMessageResponse that = (TriggerMessageResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnlockConnectorRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnlockConnectorRequest.java new file mode 100644 index 000000000..4c1f7478a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnlockConnectorRequest.java @@ -0,0 +1,205 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UnlockConnectorRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class UnlockConnectorRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The identifier of the EVSE for which a connector needs to be unlocked. */ + private Integer evseId; + + /** The identifier of the connector that needs to be unlocked. */ + private Integer connectorId; + + /** + * Constructor for the UnlockConnectorRequest class + * + * @param evseId The identifier of the EVSE for which a connector needs to be unlocked. + * @param connectorId The identifier of the connector that needs to be unlocked. + */ + public UnlockConnectorRequest(Integer evseId, Integer connectorId) { + setEvseId(evseId); + setConnectorId(connectorId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UnlockConnectorRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the identifier of the EVSE for which a connector needs to be unlocked. + * + * @return The identifier of the EVSE for which a connector needs to be unlocked + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the identifier of the EVSE for which a connector needs to be unlocked. + * + * @param evseId The identifier of the EVSE for which a connector needs to be unlocked + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null; + } + + /** + * Gets the identifier of the connector that needs to be unlocked. + * + * @return The identifier of the connector that needs to be unlocked + */ + public Integer getConnectorId() { + return connectorId; + } + + /** + * Sets the identifier of the connector that needs to be unlocked. + * + * @param connectorId The identifier of the connector that needs to be unlocked + */ + public void setConnectorId(Integer connectorId) { + if (!isValidConnectorId(connectorId)) { + throw new PropertyConstraintException(connectorId, "connectorId is invalid"); + } + this.connectorId = connectorId; + } + + /** + * Returns whether the given connectorId is valid + * + * @param connectorId the connectorId to check the validity of + * @return {@code true} if connectorId is valid, {@code false} if not + */ + private boolean isValidConnectorId(Integer connectorId) { + return connectorId != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidEvseId(evseId) + && isValidConnectorId(connectorId); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnlockConnectorRequest that = (UnlockConnectorRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(evseId, that.evseId) + && Objects.equals(connectorId, that.connectorId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, evseId, connectorId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("evseId", evseId) + .add("connectorId", connectorId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnlockConnectorResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnlockConnectorResponse.java new file mode 100644 index 000000000..37b298683 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnlockConnectorResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import eu.chargetime.ocpp.v201.model.types.UnlockStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UnlockConnectorResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class UnlockConnectorResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the Charging Station has unlocked the connector. */ + private UnlockStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the UnlockConnectorResponse class + * + * @param status Whether the Charging Station has unlocked the connector. + */ + public UnlockConnectorResponse(UnlockStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UnlockConnectorResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Charging Station has unlocked the connector. + * + * @return Whether the Charging Station has unlocked the connector + */ + public UnlockStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Charging Station has unlocked the connector. + * + * @param status Whether the Charging Station has unlocked the connector + */ + public void setStatus(UnlockStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(UnlockStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public UnlockConnectorResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnlockConnectorResponse that = (UnlockConnectorResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnpublishFirmwareRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnpublishFirmwareRequest.java new file mode 100644 index 000000000..b689c17f7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnpublishFirmwareRequest.java @@ -0,0 +1,166 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UnpublishFirmwareRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class UnpublishFirmwareRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** The MD5 checksum over the entire firmware file as a hexadecimal string of length 32. */ + private String checksum; + + /** + * Constructor for the UnpublishFirmwareRequest class + * + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32. + */ + public UnpublishFirmwareRequest(String checksum) { + setChecksum(checksum); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UnpublishFirmwareRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the MD5 checksum over the entire firmware file as a hexadecimal string of length 32. + * + * @return The MD5 checksum over the entire firmware file as a hexadecimal string of length 32 + */ + public String getChecksum() { + return checksum; + } + + /** + * Sets the MD5 checksum over the entire firmware file as a hexadecimal string of length 32. + * + * @param checksum The MD5 checksum over the entire firmware file as a hexadecimal string of + * length 32 + */ + public void setChecksum(String checksum) { + if (!isValidChecksum(checksum)) { + throw new PropertyConstraintException(checksum, "checksum is invalid"); + } + this.checksum = checksum; + } + + /** + * Returns whether the given checksum is valid + * + * @param checksum the checksum to check the validity of + * @return {@code true} if checksum is valid, {@code false} if not + */ + private boolean isValidChecksum(String checksum) { + return checksum != null && checksum.length() <= 32; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidChecksum(checksum); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnpublishFirmwareRequest that = (UnpublishFirmwareRequest) o; + return Objects.equals(customData, that.customData) && Objects.equals(checksum, that.checksum); + } + + @Override + public int hashCode() { + return Objects.hash(customData, checksum); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("checksum", checksum) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnpublishFirmwareResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnpublishFirmwareResponse.java new file mode 100644 index 000000000..71a59da88 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UnpublishFirmwareResponse.java @@ -0,0 +1,160 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.UnpublishFirmwareStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UnpublishFirmwareResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class UnpublishFirmwareResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** Whether the Local Controller succeeded in unpublishing the firmware. */ + private UnpublishFirmwareStatusEnum status; + + /** + * Constructor for the UnpublishFirmwareResponse class + * + * @param status Whether the Local Controller succeeded in unpublishing the firmware. + */ + public UnpublishFirmwareResponse(UnpublishFirmwareStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UnpublishFirmwareResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets whether the Local Controller succeeded in unpublishing the firmware. + * + * @return Whether the Local Controller succeeded in unpublishing the firmware + */ + public UnpublishFirmwareStatusEnum getStatus() { + return status; + } + + /** + * Sets whether the Local Controller succeeded in unpublishing the firmware. + * + * @param status Whether the Local Controller succeeded in unpublishing the firmware + */ + public void setStatus(UnpublishFirmwareStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(UnpublishFirmwareStatusEnum status) { + return status != null; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnpublishFirmwareResponse that = (UnpublishFirmwareResponse) o; + return Objects.equals(customData, that.customData) && Objects.equals(status, that.status); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UpdateFirmwareRequest.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UpdateFirmwareRequest.java new file mode 100644 index 000000000..34cbf652e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UpdateFirmwareRequest.java @@ -0,0 +1,298 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.RequestWithId; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.Firmware; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UpdateFirmwareRequest + * + *

OCPP 2.0.1 FINAL + */ +public final class UpdateFirmwareRequest extends RequestWithId { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * How many times Charging Station must try to download the firmware before giving up. If this + * field is not present, it is left to Charging Station to decide how many times it wants to + * retry. + */ + @Nullable private Integer retries; + + /** + * The interval in seconds after which a retry may be attempted. If this field is not present, it + * is left to Charging Station to decide how long to wait between attempts. + */ + @Nullable private Integer retryInterval; + + /** The Id of this request */ + private Integer requestId; + + /** + * Firmware + * + *

A copy of the firmware that can be loaded/updated on the Charging Station. + */ + private Firmware firmware; + + /** + * Constructor for the UpdateFirmwareRequest class + * + * @param requestId The Id of this request + * @param firmware A copy of the firmware that can be loaded/updated on the Charging Station. + */ + public UpdateFirmwareRequest(Integer requestId, Firmware firmware) { + setRequestId(requestId); + setFirmware(firmware); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UpdateFirmwareRequest withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets how many times Charging Station must try to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. + * + * @return How many times Charging Station must try to download the firmware before giving up + */ + @Nullable + public Integer getRetries() { + return retries; + } + + /** + * Sets how many times Charging Station must try to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. + * + * @param retries How many times Charging Station must try to download the firmware before giving + * up + */ + public void setRetries(@Nullable Integer retries) { + this.retries = retries; + } + + /** + * Adds how many times Charging Station must try to download the firmware before giving up. If + * this field is not present, it is left to Charging Station to decide how many times it wants to + * retry. + * + * @param retries How many times Charging Station must try to download the firmware before giving + * up + * @return this + */ + public UpdateFirmwareRequest withRetries(@Nullable Integer retries) { + setRetries(retries); + return this; + } + + /** + * Gets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @return The interval in seconds after which a retry may be attempted + */ + @Nullable + public Integer getRetryInterval() { + return retryInterval; + } + + /** + * Sets the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + */ + public void setRetryInterval(@Nullable Integer retryInterval) { + this.retryInterval = retryInterval; + } + + /** + * Adds the interval in seconds after which a retry may be attempted. If this field is not + * present, it is left to Charging Station to decide how long to wait between attempts. + * + * @param retryInterval The interval in seconds after which a retry may be attempted + * @return this + */ + public UpdateFirmwareRequest withRetryInterval(@Nullable Integer retryInterval) { + setRetryInterval(retryInterval); + return this; + } + + /** + * Gets the Id of this request + * + * @return The Id of this request + */ + public Integer getRequestId() { + return requestId; + } + + /** + * Sets the Id of this request + * + * @param requestId The Id of this request + */ + public void setRequestId(Integer requestId) { + if (!isValidRequestId(requestId)) { + throw new PropertyConstraintException(requestId, "requestId is invalid"); + } + this.requestId = requestId; + } + + /** + * Returns whether the given requestId is valid + * + * @param requestId the requestId to check the validity of + * @return {@code true} if requestId is valid, {@code false} if not + */ + private boolean isValidRequestId(Integer requestId) { + return requestId != null; + } + + /** + * Gets a copy of the firmware that can be loaded/updated on the Charging Station. + * + * @return A copy of the firmware that can be loaded/updated on the Charging Station + */ + public Firmware getFirmware() { + return firmware; + } + + /** + * Sets a copy of the firmware that can be loaded/updated on the Charging Station. + * + * @param firmware A copy of the firmware that can be loaded/updated on the Charging Station + */ + public void setFirmware(Firmware firmware) { + if (!isValidFirmware(firmware)) { + throw new PropertyConstraintException(firmware, "firmware is invalid"); + } + this.firmware = firmware; + } + + /** + * Returns whether the given firmware is valid + * + * @param firmware the firmware to check the validity of + * @return {@code true} if firmware is valid, {@code false} if not + */ + private boolean isValidFirmware(Firmware firmware) { + return firmware != null && firmware.validate(); + } + + @Override + public boolean validate() { + return isValidCustomData(customData) + && isValidRequestId(requestId) + && isValidFirmware(firmware); + } + + @Override + public boolean transactionRelated() { + return false; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateFirmwareRequest that = (UpdateFirmwareRequest) o; + return Objects.equals(customData, that.customData) + && Objects.equals(retries, that.retries) + && Objects.equals(retryInterval, that.retryInterval) + && Objects.equals(requestId, that.requestId) + && Objects.equals(firmware, that.firmware); + } + + @Override + public int hashCode() { + return Objects.hash(customData, retries, retryInterval, requestId, firmware); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("retries", retries) + .add("retryInterval", retryInterval) + .add("requestId", requestId) + .add("firmware", firmware) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UpdateFirmwareResponse.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UpdateFirmwareResponse.java new file mode 100644 index 000000000..63b9b68a4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/messages/UpdateFirmwareResponse.java @@ -0,0 +1,210 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.messages; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.model.Confirmation; +import eu.chargetime.ocpp.utilities.MoreObjects; +import eu.chargetime.ocpp.v201.model.types.CustomData; +import eu.chargetime.ocpp.v201.model.types.StatusInfo; +import eu.chargetime.ocpp.v201.model.types.UpdateFirmwareStatusEnum; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * UpdateFirmwareResponse + * + *

OCPP 2.0.1 FINAL + */ +public final class UpdateFirmwareResponse extends Confirmation { + /** Custom data */ + @Nullable private CustomData customData; + + /** This field indicates whether the Charging Station was able to accept the request. */ + private UpdateFirmwareStatusEnum status; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the UpdateFirmwareResponse class + * + * @param status This field indicates whether the Charging Station was able to accept the request. + */ + public UpdateFirmwareResponse(UpdateFirmwareStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UpdateFirmwareResponse withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets this field indicates whether the Charging Station was able to accept the request. + * + * @return This field indicates whether the Charging Station was able to accept the request + */ + public UpdateFirmwareStatusEnum getStatus() { + return status; + } + + /** + * Sets this field indicates whether the Charging Station was able to accept the request. + * + * @param status This field indicates whether the Charging Station was able to accept the request + */ + public void setStatus(UpdateFirmwareStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(UpdateFirmwareStatusEnum status) { + return status != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public UpdateFirmwareResponse withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + @Override + public boolean validate() { + return isValidCustomData(customData) && isValidStatus(status) && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateFirmwareResponse that = (UpdateFirmwareResponse) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ACChargingParameters.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ACChargingParameters.java new file mode 100644 index 000000000..e271f536e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ACChargingParameters.java @@ -0,0 +1,297 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * AC Charging Parameters + * + *

EV AC charging parameters. + */ +public final class ACChargingParameters { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * AC Charging Parameters. Energy Amount. Energy Amount + * + *

Amount of energy requested (in Wh). This includes energy required for preconditioning. + */ + private Integer energyAmount; + + /** + * AC Charging Parameters. EV Min. Current + * + *

Minimum current (amps) supported by the electric vehicle (per phase). + */ + private Integer evMinCurrent; + + /** + * AC Charging Parameters. EV Max. Current + * + *

Maximum current (amps) supported by the electric vehicle (per phase). Includes cable + * capacity. + */ + private Integer evMaxCurrent; + + /** + * AC Charging Parameters. EV Max. Voltage + * + *

Maximum voltage supported by the electric vehicle + */ + private Integer evMaxVoltage; + + /** + * Constructor for the ACChargingParameters class + * + * @param energyAmount Amount of energy requested (in Wh). This includes energy required for + * preconditioning. + * @param evMinCurrent Minimum current (amps) supported by the electric vehicle (per phase). + * @param evMaxCurrent Maximum current (amps) supported by the electric vehicle (per phase). + * Includes cable capacity. + * @param evMaxVoltage Maximum voltage supported by the electric vehicle + */ + public ACChargingParameters( + Integer energyAmount, Integer evMinCurrent, Integer evMaxCurrent, Integer evMaxVoltage) { + setEnergyAmount(energyAmount); + setEvMinCurrent(evMinCurrent); + setEvMaxCurrent(evMaxCurrent); + setEvMaxVoltage(evMaxVoltage); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ACChargingParameters withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets amount of energy requested (in Wh). This includes energy required for preconditioning. + * + * @return Amount of energy requested (in Wh) + */ + public Integer getEnergyAmount() { + return energyAmount; + } + + /** + * Sets amount of energy requested (in Wh). This includes energy required for preconditioning. + * + * @param energyAmount Amount of energy requested (in Wh) + */ + public void setEnergyAmount(Integer energyAmount) { + if (!isValidEnergyAmount(energyAmount)) { + throw new PropertyConstraintException(energyAmount, "energyAmount is invalid"); + } + this.energyAmount = energyAmount; + } + + /** + * Returns whether the given energyAmount is valid + * + * @param energyAmount the energyAmount to check the validity of + * @return {@code true} if energyAmount is valid, {@code false} if not + */ + private boolean isValidEnergyAmount(Integer energyAmount) { + return energyAmount != null; + } + + /** + * Gets minimum current (amps) supported by the electric vehicle (per phase). + * + * @return Minimum current (amps) supported by the electric vehicle (per phase) + */ + public Integer getEvMinCurrent() { + return evMinCurrent; + } + + /** + * Sets minimum current (amps) supported by the electric vehicle (per phase). + * + * @param evMinCurrent Minimum current (amps) supported by the electric vehicle (per phase) + */ + public void setEvMinCurrent(Integer evMinCurrent) { + if (!isValidEvMinCurrent(evMinCurrent)) { + throw new PropertyConstraintException(evMinCurrent, "evMinCurrent is invalid"); + } + this.evMinCurrent = evMinCurrent; + } + + /** + * Returns whether the given evMinCurrent is valid + * + * @param evMinCurrent the evMinCurrent to check the validity of + * @return {@code true} if evMinCurrent is valid, {@code false} if not + */ + private boolean isValidEvMinCurrent(Integer evMinCurrent) { + return evMinCurrent != null; + } + + /** + * Gets maximum current (amps) supported by the electric vehicle (per phase). Includes cable + * capacity. + * + * @return Maximum current (amps) supported by the electric vehicle (per phase) + */ + public Integer getEvMaxCurrent() { + return evMaxCurrent; + } + + /** + * Sets maximum current (amps) supported by the electric vehicle (per phase). Includes cable + * capacity. + * + * @param evMaxCurrent Maximum current (amps) supported by the electric vehicle (per phase) + */ + public void setEvMaxCurrent(Integer evMaxCurrent) { + if (!isValidEvMaxCurrent(evMaxCurrent)) { + throw new PropertyConstraintException(evMaxCurrent, "evMaxCurrent is invalid"); + } + this.evMaxCurrent = evMaxCurrent; + } + + /** + * Returns whether the given evMaxCurrent is valid + * + * @param evMaxCurrent the evMaxCurrent to check the validity of + * @return {@code true} if evMaxCurrent is valid, {@code false} if not + */ + private boolean isValidEvMaxCurrent(Integer evMaxCurrent) { + return evMaxCurrent != null; + } + + /** + * Gets maximum voltage supported by the electric vehicle + * + * @return Maximum voltage supported by the electric vehicle + */ + public Integer getEvMaxVoltage() { + return evMaxVoltage; + } + + /** + * Sets maximum voltage supported by the electric vehicle + * + * @param evMaxVoltage Maximum voltage supported by the electric vehicle + */ + public void setEvMaxVoltage(Integer evMaxVoltage) { + if (!isValidEvMaxVoltage(evMaxVoltage)) { + throw new PropertyConstraintException(evMaxVoltage, "evMaxVoltage is invalid"); + } + this.evMaxVoltage = evMaxVoltage; + } + + /** + * Returns whether the given evMaxVoltage is valid + * + * @param evMaxVoltage the evMaxVoltage to check the validity of + * @return {@code true} if evMaxVoltage is valid, {@code false} if not + */ + private boolean isValidEvMaxVoltage(Integer evMaxVoltage) { + return evMaxVoltage != null; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidEnergyAmount(energyAmount) + && isValidEvMinCurrent(evMinCurrent) + && isValidEvMaxCurrent(evMaxCurrent) + && isValidEvMaxVoltage(evMaxVoltage); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ACChargingParameters that = (ACChargingParameters) o; + return Objects.equals(customData, that.customData) + && Objects.equals(energyAmount, that.energyAmount) + && Objects.equals(evMinCurrent, that.evMinCurrent) + && Objects.equals(evMaxCurrent, that.evMaxCurrent) + && Objects.equals(evMaxVoltage, that.evMaxVoltage); + } + + @Override + public int hashCode() { + return Objects.hash(customData, energyAmount, evMinCurrent, evMaxCurrent, evMaxVoltage); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("energyAmount", energyAmount) + .add("evMinCurrent", evMinCurrent) + .add("evMaxCurrent", evMaxCurrent) + .add("evMaxVoltage", evMaxVoltage) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/APN.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/APN.java new file mode 100644 index 000000000..74b4ea1dc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/APN.java @@ -0,0 +1,459 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * APN + * + *

Collection of configuration data needed to make a data-connection over a cellular network. + * + *

NOTE: When asking a GSM modem to dial in, it is possible to specify which mobile operator + * should be used. This can be done with the mobile country code (MCC) in combination with a mobile + * network code (MNC). Example: If your preferred network is Vodafone Netherlands, the MCC=204 and + * the MNC=04 which means the key PreferredNetwork = 20404 Some modems allows to specify a preferred + * network, which means, if this network is not available, a different network is used. If you + * specify UseOnlyPreferredNetwork and this network is not available, the modem will not dial in. + */ +public final class APN { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * APN. APN. URI + * + *

The Access Point Name as an URL. + */ + private String apn; + + /** + * APN. APN. User Name + * + *

APN username. + */ + @Nullable private String apnUserName; + + /** + * APN. APN. Password + * + *

APN Password. + */ + @Nullable private String apnPassword; + + /** + * APN. SIMPIN. PIN Code + * + *

SIM card pin code. + */ + @Nullable private Integer simPin; + + /** + * APN. Preferred Network. Mobile Network ID + * + *

Preferred network, written as MCC and MNC concatenated. See note. + */ + @Nullable private String preferredNetwork; + + /** + * APN. Use Only Preferred Network. Indicator + * + *

Default: false. Use only the preferred Network, do not dial in when not available. See Note. + */ + @Nullable private Boolean useOnlyPreferredNetwork; + + /** + * APN. APN Authentication. APN Authentication Code + * + *

Authentication method. + */ + private APNAuthenticationEnum apnAuthentication; + + /** + * Constructor for the APN class + * + * @param apn The Access Point Name as an URL. + * @param apnAuthentication Authentication method. + */ + public APN(String apn, APNAuthenticationEnum apnAuthentication) { + setApn(apn); + setApnAuthentication(apnAuthentication); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public APN withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the Access Point Name as an URL. + * + * @return The Access Point Name as an URL + */ + public String getApn() { + return apn; + } + + /** + * Sets the Access Point Name as an URL. + * + * @param apn The Access Point Name as an URL + */ + public void setApn(String apn) { + if (!isValidApn(apn)) { + throw new PropertyConstraintException(apn, "apn is invalid"); + } + this.apn = apn; + } + + /** + * Returns whether the given apn is valid + * + * @param apn the apn to check the validity of + * @return {@code true} if apn is valid, {@code false} if not + */ + private boolean isValidApn(String apn) { + return apn != null && apn.length() <= 512; + } + + /** + * Gets APN username. + * + * @return APN username + */ + @Nullable + public String getApnUserName() { + return apnUserName; + } + + /** + * Sets APN username. + * + * @param apnUserName APN username + */ + public void setApnUserName(@Nullable String apnUserName) { + if (!isValidApnUserName(apnUserName)) { + throw new PropertyConstraintException(apnUserName, "apnUserName is invalid"); + } + this.apnUserName = apnUserName; + } + + /** + * Returns whether the given apnUserName is valid + * + * @param apnUserName the apnUserName to check the validity of + * @return {@code true} if apnUserName is valid, {@code false} if not + */ + private boolean isValidApnUserName(@Nullable String apnUserName) { + return apnUserName == null || apnUserName.length() <= 20; + } + + /** + * Adds APN username. + * + * @param apnUserName APN username + * @return this + */ + public APN withApnUserName(@Nullable String apnUserName) { + setApnUserName(apnUserName); + return this; + } + + /** + * Gets APN Password. + * + * @return APN Password + */ + @Nullable + public String getApnPassword() { + return apnPassword; + } + + /** + * Sets APN Password. + * + * @param apnPassword APN Password + */ + public void setApnPassword(@Nullable String apnPassword) { + if (!isValidApnPassword(apnPassword)) { + throw new PropertyConstraintException(apnPassword, "apnPassword is invalid"); + } + this.apnPassword = apnPassword; + } + + /** + * Returns whether the given apnPassword is valid + * + * @param apnPassword the apnPassword to check the validity of + * @return {@code true} if apnPassword is valid, {@code false} if not + */ + private boolean isValidApnPassword(@Nullable String apnPassword) { + return apnPassword == null || apnPassword.length() <= 20; + } + + /** + * Adds APN Password. + * + * @param apnPassword APN Password + * @return this + */ + public APN withApnPassword(@Nullable String apnPassword) { + setApnPassword(apnPassword); + return this; + } + + /** + * Gets SIM card pin code. + * + * @return SIM card pin code + */ + @Nullable + public Integer getSimPin() { + return simPin; + } + + /** + * Sets SIM card pin code. + * + * @param simPin SIM card pin code + */ + public void setSimPin(@Nullable Integer simPin) { + this.simPin = simPin; + } + + /** + * Adds SIM card pin code. + * + * @param simPin SIM card pin code + * @return this + */ + public APN withSimPin(@Nullable Integer simPin) { + setSimPin(simPin); + return this; + } + + /** + * Gets preferred network, written as MCC and MNC concatenated. See note. + * + * @return Preferred network, written as MCC and MNC concatenated + */ + @Nullable + public String getPreferredNetwork() { + return preferredNetwork; + } + + /** + * Sets preferred network, written as MCC and MNC concatenated. See note. + * + * @param preferredNetwork Preferred network, written as MCC and MNC concatenated + */ + public void setPreferredNetwork(@Nullable String preferredNetwork) { + if (!isValidPreferredNetwork(preferredNetwork)) { + throw new PropertyConstraintException(preferredNetwork, "preferredNetwork is invalid"); + } + this.preferredNetwork = preferredNetwork; + } + + /** + * Returns whether the given preferredNetwork is valid + * + * @param preferredNetwork the preferredNetwork to check the validity of + * @return {@code true} if preferredNetwork is valid, {@code false} if not + */ + private boolean isValidPreferredNetwork(@Nullable String preferredNetwork) { + return preferredNetwork == null || preferredNetwork.length() <= 6; + } + + /** + * Adds preferred network, written as MCC and MNC concatenated. See note. + * + * @param preferredNetwork Preferred network, written as MCC and MNC concatenated + * @return this + */ + public APN withPreferredNetwork(@Nullable String preferredNetwork) { + setPreferredNetwork(preferredNetwork); + return this; + } + + /** + * Gets default: false. Use only the preferred Network, do not dial in when not available. See + * Note. + * + * @return Default: false + */ + public Boolean getUseOnlyPreferredNetwork() { + return useOnlyPreferredNetwork != null ? useOnlyPreferredNetwork : false; + } + + /** + * Sets default: false. Use only the preferred Network, do not dial in when not available. See + * Note. + * + * @param useOnlyPreferredNetwork Default: false + */ + public void setUseOnlyPreferredNetwork(@Nullable Boolean useOnlyPreferredNetwork) { + this.useOnlyPreferredNetwork = useOnlyPreferredNetwork; + } + + /** + * Adds default: false. Use only the preferred Network, do not dial in when not available. See + * Note. + * + * @param useOnlyPreferredNetwork Default: false + * @return this + */ + public APN withUseOnlyPreferredNetwork(@Nullable Boolean useOnlyPreferredNetwork) { + setUseOnlyPreferredNetwork(useOnlyPreferredNetwork); + return this; + } + + /** + * Gets authentication method. + * + * @return Authentication method + */ + public APNAuthenticationEnum getApnAuthentication() { + return apnAuthentication; + } + + /** + * Sets authentication method. + * + * @param apnAuthentication Authentication method + */ + public void setApnAuthentication(APNAuthenticationEnum apnAuthentication) { + if (!isValidApnAuthentication(apnAuthentication)) { + throw new PropertyConstraintException(apnAuthentication, "apnAuthentication is invalid"); + } + this.apnAuthentication = apnAuthentication; + } + + /** + * Returns whether the given apnAuthentication is valid + * + * @param apnAuthentication the apnAuthentication to check the validity of + * @return {@code true} if apnAuthentication is valid, {@code false} if not + */ + private boolean isValidApnAuthentication(APNAuthenticationEnum apnAuthentication) { + return apnAuthentication != null; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidApn(apn) + && isValidApnUserName(apnUserName) + && isValidApnPassword(apnPassword) + && isValidPreferredNetwork(preferredNetwork) + && isValidApnAuthentication(apnAuthentication); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APN that = (APN) o; + return Objects.equals(customData, that.customData) + && Objects.equals(apn, that.apn) + && Objects.equals(apnUserName, that.apnUserName) + && Objects.equals(apnPassword, that.apnPassword) + && Objects.equals(simPin, that.simPin) + && Objects.equals(preferredNetwork, that.preferredNetwork) + && Objects.equals(useOnlyPreferredNetwork, that.useOnlyPreferredNetwork) + && Objects.equals(apnAuthentication, that.apnAuthentication); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + apn, + apnUserName, + apnPassword, + simPin, + preferredNetwork, + useOnlyPreferredNetwork, + apnAuthentication); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("apn", apn) + .add("apnUserName", apnUserName) + .add("apnPassword", apnPassword) + .add("simPin", simPin) + .add("preferredNetwork", preferredNetwork) + .add("useOnlyPreferredNetwork", useOnlyPreferredNetwork) + .add("apnAuthentication", apnAuthentication) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/APNAuthenticationEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/APNAuthenticationEnum.java new file mode 100644 index 000000000..584696120 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/APNAuthenticationEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * APN. APN Authentication. APN Authentication Code + * + *

Authentication method. + */ +public enum APNAuthenticationEnum { + CHAP, + NONE, + PAP, + AUTO +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AdditionalInfo.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AdditionalInfo.java new file mode 100644 index 000000000..73a2a16fb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AdditionalInfo.java @@ -0,0 +1,202 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ +public final class AdditionalInfo { + /** Custom data */ + @Nullable private CustomData customData; + + /** The additional IdToken. */ + private String additionalIdToken; + + /** + * The type of the additionalIdToken. This is a custom type, so the implementation needs to be + * agreed upon by all involved parties. + */ + private String type; + + /** + * Constructor for the AdditionalInfo class + * + * @param additionalIdToken The additional IdToken. + * @param type The type of the additionalIdToken. This is a custom type, so the implementation + * needs to be agreed upon by all involved parties. + */ + public AdditionalInfo(String additionalIdToken, String type) { + setAdditionalIdToken(additionalIdToken); + setType(type); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AdditionalInfo withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the additional IdToken. + * + * @return The additional IdToken + */ + public String getAdditionalIdToken() { + return additionalIdToken; + } + + /** + * Sets the additional IdToken. + * + * @param additionalIdToken The additional IdToken + */ + public void setAdditionalIdToken(String additionalIdToken) { + if (!isValidAdditionalIdToken(additionalIdToken)) { + throw new PropertyConstraintException(additionalIdToken, "additionalIdToken is invalid"); + } + this.additionalIdToken = additionalIdToken; + } + + /** + * Returns whether the given additionalIdToken is valid + * + * @param additionalIdToken the additionalIdToken to check the validity of + * @return {@code true} if additionalIdToken is valid, {@code false} if not + */ + private boolean isValidAdditionalIdToken(String additionalIdToken) { + return additionalIdToken != null && additionalIdToken.length() <= 36; + } + + /** + * Gets the type of the additionalIdToken. This is a custom type, so the implementation needs to + * be agreed upon by all involved parties. + * + * @return The type of the additionalIdToken + */ + public String getType() { + return type; + } + + /** + * Sets the type of the additionalIdToken. This is a custom type, so the implementation needs to + * be agreed upon by all involved parties. + * + * @param type The type of the additionalIdToken + */ + public void setType(String type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(String type) { + return type != null && type.length() <= 50; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidAdditionalIdToken(additionalIdToken) + && isValidType(type); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalInfo that = (AdditionalInfo) o; + return Objects.equals(customData, that.customData) + && Objects.equals(additionalIdToken, that.additionalIdToken) + && Objects.equals(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hash(customData, additionalIdToken, type); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("additionalIdToken", additionalIdToken) + .add("type", type) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AttributeEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AttributeEnum.java new file mode 100644 index 000000000..ba4c57c7a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AttributeEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. */ +public enum AttributeEnum { + Actual, + Target, + MinSet, + MaxSet +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AuthorizationData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AuthorizationData.java new file mode 100644 index 000000000..c3b49ad23 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AuthorizationData.java @@ -0,0 +1,223 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** The identifier to use for authorization. */ +public final class AuthorizationData { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + private IdToken idToken; + + /** + * ID Token + * + *

Status information about an identifier. It is advised to not stop charging for a token that + * expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not + * given, the status has no end date. + */ + @Nullable private IdTokenInfo idTokenInfo; + + /** + * Constructor for the AuthorizationData class + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers. + */ + public AuthorizationData(IdToken idToken) { + setIdToken(idToken); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public AuthorizationData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public IdToken getIdToken() { + return idToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param idToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setIdToken(IdToken idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(IdToken idToken) { + return idToken != null && idToken.validate(); + } + + /** + * Gets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @return Status information about an identifier + */ + @Nullable + public IdTokenInfo getIdTokenInfo() { + return idTokenInfo; + } + + /** + * Sets status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @param idTokenInfo Status information about an identifier + */ + public void setIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + if (!isValidIdTokenInfo(idTokenInfo)) { + throw new PropertyConstraintException(idTokenInfo, "idTokenInfo is invalid"); + } + this.idTokenInfo = idTokenInfo; + } + + /** + * Returns whether the given idTokenInfo is valid + * + * @param idTokenInfo the idTokenInfo to check the validity of + * @return {@code true} if idTokenInfo is valid, {@code false} if not + */ + private boolean isValidIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + return idTokenInfo == null || idTokenInfo.validate(); + } + + /** + * Adds status information about an identifier. It is advised to not stop charging for a token + * that expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is + * not given, the status has no end date. + * + * @param idTokenInfo Status information about an identifier + * @return this + */ + public AuthorizationData withIdTokenInfo(@Nullable IdTokenInfo idTokenInfo) { + setIdTokenInfo(idTokenInfo); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidIdToken(idToken) + && isValidIdTokenInfo(idTokenInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AuthorizationData that = (AuthorizationData) o; + return Objects.equals(customData, that.customData) + && Objects.equals(idToken, that.idToken) + && Objects.equals(idTokenInfo, that.idTokenInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, idToken, idTokenInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("idToken", idToken) + .add("idTokenInfo", idTokenInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AuthorizationStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AuthorizationStatusEnum.java new file mode 100644 index 000000000..3c97e77c1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AuthorizationStatusEnum.java @@ -0,0 +1,43 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * ID Token. Status. Authorization Status + * + *

Current status of the ID Token. + */ +public enum AuthorizationStatusEnum { + Accepted, + Blocked, + ConcurrentTx, + Expired, + Invalid, + NoCredit, + NotAllowedTypeEVSE, + NotAtThisLocation, + NotAtThisTime, + Unknown +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AuthorizeCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AuthorizeCertificateStatusEnum.java new file mode 100644 index 000000000..e27bc5055 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/AuthorizeCertificateStatusEnum.java @@ -0,0 +1,43 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Certificate status information. + * + *

+ * - if all certificates are valid: return 'Accepted'.
+ * - if one of the certificates was revoked, return 'CertificateRevoked'.
+ * 
+ */ +public enum AuthorizeCertificateStatusEnum { + Accepted, + SignatureError, + CertificateExpired, + CertificateRevoked, + NoCertificateAvailable, + CertChainError, + ContractCancelled +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/BootReasonEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/BootReasonEnum.java new file mode 100644 index 000000000..a6181b73b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/BootReasonEnum.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The reason for sending this message to the CSMS. */ +public enum BootReasonEnum { + ApplicationReset, + FirmwareUpdate, + LocalReset, + PowerUp, + RemoteReset, + ScheduledReset, + Triggered, + Unknown, + Watchdog +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CancelReservationStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CancelReservationStatusEnum.java new file mode 100644 index 000000000..e8a995687 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CancelReservationStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The success or failure of the canceling of a reservation by CSMS. */ +public enum CancelReservationStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateActionEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateActionEnum.java new file mode 100644 index 000000000..93fcf327e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateActionEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether certificate needs to be installed or updated. */ +public enum CertificateActionEnum { + Install, + Update +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateHashData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateHashData.java new file mode 100644 index 000000000..421b48016 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateHashData.java @@ -0,0 +1,275 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** CertificateHashDataType */ +public final class CertificateHashData { + /** Custom data */ + @Nullable private CustomData customData; + + /** Used algorithms for the hashes provided. */ + private HashAlgorithmEnum hashAlgorithm; + + /** Hashed value of the Issuer DN (Distinguished Name). */ + private String issuerNameHash; + + /** Hashed value of the issuers public key */ + private String issuerKeyHash; + + /** The serial number of the certificate. */ + private String serialNumber; + + /** + * Constructor for the CertificateHashData class + * + * @param hashAlgorithm Used algorithms for the hashes provided. + * @param issuerNameHash Hashed value of the Issuer DN (Distinguished Name). + * @param issuerKeyHash Hashed value of the issuers public key + * @param serialNumber The serial number of the certificate. + */ + public CertificateHashData( + HashAlgorithmEnum hashAlgorithm, + String issuerNameHash, + String issuerKeyHash, + String serialNumber) { + setHashAlgorithm(hashAlgorithm); + setIssuerNameHash(issuerNameHash); + setIssuerKeyHash(issuerKeyHash); + setSerialNumber(serialNumber); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CertificateHashData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets used algorithms for the hashes provided. + * + * @return Used algorithms for the hashes provided + */ + public HashAlgorithmEnum getHashAlgorithm() { + return hashAlgorithm; + } + + /** + * Sets used algorithms for the hashes provided. + * + * @param hashAlgorithm Used algorithms for the hashes provided + */ + public void setHashAlgorithm(HashAlgorithmEnum hashAlgorithm) { + if (!isValidHashAlgorithm(hashAlgorithm)) { + throw new PropertyConstraintException(hashAlgorithm, "hashAlgorithm is invalid"); + } + this.hashAlgorithm = hashAlgorithm; + } + + /** + * Returns whether the given hashAlgorithm is valid + * + * @param hashAlgorithm the hashAlgorithm to check the validity of + * @return {@code true} if hashAlgorithm is valid, {@code false} if not + */ + private boolean isValidHashAlgorithm(HashAlgorithmEnum hashAlgorithm) { + return hashAlgorithm != null; + } + + /** + * Gets hashed value of the Issuer DN (Distinguished Name). + * + * @return Hashed value of the Issuer DN (Distinguished Name) + */ + public String getIssuerNameHash() { + return issuerNameHash; + } + + /** + * Sets hashed value of the Issuer DN (Distinguished Name). + * + * @param issuerNameHash Hashed value of the Issuer DN (Distinguished Name) + */ + public void setIssuerNameHash(String issuerNameHash) { + if (!isValidIssuerNameHash(issuerNameHash)) { + throw new PropertyConstraintException(issuerNameHash, "issuerNameHash is invalid"); + } + this.issuerNameHash = issuerNameHash; + } + + /** + * Returns whether the given issuerNameHash is valid + * + * @param issuerNameHash the issuerNameHash to check the validity of + * @return {@code true} if issuerNameHash is valid, {@code false} if not + */ + private boolean isValidIssuerNameHash(String issuerNameHash) { + return issuerNameHash != null && issuerNameHash.length() <= 128; + } + + /** + * Gets hashed value of the issuers public key + * + * @return Hashed value of the issuers public key + */ + public String getIssuerKeyHash() { + return issuerKeyHash; + } + + /** + * Sets hashed value of the issuers public key + * + * @param issuerKeyHash Hashed value of the issuers public key + */ + public void setIssuerKeyHash(String issuerKeyHash) { + if (!isValidIssuerKeyHash(issuerKeyHash)) { + throw new PropertyConstraintException(issuerKeyHash, "issuerKeyHash is invalid"); + } + this.issuerKeyHash = issuerKeyHash; + } + + /** + * Returns whether the given issuerKeyHash is valid + * + * @param issuerKeyHash the issuerKeyHash to check the validity of + * @return {@code true} if issuerKeyHash is valid, {@code false} if not + */ + private boolean isValidIssuerKeyHash(String issuerKeyHash) { + return issuerKeyHash != null && issuerKeyHash.length() <= 128; + } + + /** + * Gets the serial number of the certificate. + * + * @return The serial number of the certificate + */ + public String getSerialNumber() { + return serialNumber; + } + + /** + * Sets the serial number of the certificate. + * + * @param serialNumber The serial number of the certificate + */ + public void setSerialNumber(String serialNumber) { + if (!isValidSerialNumber(serialNumber)) { + throw new PropertyConstraintException(serialNumber, "serialNumber is invalid"); + } + this.serialNumber = serialNumber; + } + + /** + * Returns whether the given serialNumber is valid + * + * @param serialNumber the serialNumber to check the validity of + * @return {@code true} if serialNumber is valid, {@code false} if not + */ + private boolean isValidSerialNumber(String serialNumber) { + return serialNumber != null && serialNumber.length() <= 40; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidHashAlgorithm(hashAlgorithm) + && isValidIssuerNameHash(issuerNameHash) + && isValidIssuerKeyHash(issuerKeyHash) + && isValidSerialNumber(serialNumber); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CertificateHashData that = (CertificateHashData) o; + return Objects.equals(customData, that.customData) + && Objects.equals(hashAlgorithm, that.hashAlgorithm) + && Objects.equals(issuerNameHash, that.issuerNameHash) + && Objects.equals(issuerKeyHash, that.issuerKeyHash) + && Objects.equals(serialNumber, that.serialNumber); + } + + @Override + public int hashCode() { + return Objects.hash(customData, hashAlgorithm, issuerNameHash, issuerKeyHash, serialNumber); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("hashAlgorithm", hashAlgorithm) + .add("issuerNameHash", issuerNameHash) + .add("issuerKeyHash", issuerKeyHash) + .add("serialNumber", serialNumber) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateHashDataChain.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateHashDataChain.java new file mode 100644 index 000000000..aa1155a95 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateHashDataChain.java @@ -0,0 +1,255 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** CertificateHashDataChainType */ +public final class CertificateHashDataChain { + /** Custom data */ + @Nullable private CustomData customData; + + /** certificateHashData */ + private CertificateHashData certificateHashData; + + /** The type of the requested certificate(s). */ + private GetCertificateIdUseEnum certificateType; + + /** childCertificateHashData */ + @Nullable private CertificateHashData[] childCertificateHashData; + + /** + * Constructor for the CertificateHashDataChain class + * + * @param certificateHashData certificateHashData + * @param certificateType The type of the requested certificate(s). + */ + public CertificateHashDataChain( + CertificateHashData certificateHashData, GetCertificateIdUseEnum certificateType) { + setCertificateHashData(certificateHashData); + setCertificateType(certificateType); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CertificateHashDataChain withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets certificateHashData + * + * @return certificateHashData + */ + public CertificateHashData getCertificateHashData() { + return certificateHashData; + } + + /** + * Sets certificateHashData + * + * @param certificateHashData certificateHashData + */ + public void setCertificateHashData(CertificateHashData certificateHashData) { + if (!isValidCertificateHashData(certificateHashData)) { + throw new PropertyConstraintException(certificateHashData, "certificateHashData is invalid"); + } + this.certificateHashData = certificateHashData; + } + + /** + * Returns whether the given certificateHashData is valid + * + * @param certificateHashData the certificateHashData to check the validity of + * @return {@code true} if certificateHashData is valid, {@code false} if not + */ + private boolean isValidCertificateHashData(CertificateHashData certificateHashData) { + return certificateHashData != null && certificateHashData.validate(); + } + + /** + * Gets the type of the requested certificate(s). + * + * @return The type of the requested certificate(s) + */ + public GetCertificateIdUseEnum getCertificateType() { + return certificateType; + } + + /** + * Sets the type of the requested certificate(s). + * + * @param certificateType The type of the requested certificate(s) + */ + public void setCertificateType(GetCertificateIdUseEnum certificateType) { + if (!isValidCertificateType(certificateType)) { + throw new PropertyConstraintException(certificateType, "certificateType is invalid"); + } + this.certificateType = certificateType; + } + + /** + * Returns whether the given certificateType is valid + * + * @param certificateType the certificateType to check the validity of + * @return {@code true} if certificateType is valid, {@code false} if not + */ + private boolean isValidCertificateType(GetCertificateIdUseEnum certificateType) { + return certificateType != null; + } + + /** + * Gets childCertificateHashData + * + * @return childCertificateHashData + */ + @Nullable + public CertificateHashData[] getChildCertificateHashData() { + return childCertificateHashData; + } + + /** + * Sets childCertificateHashData + * + * @param childCertificateHashData childCertificateHashData + */ + public void setChildCertificateHashData( + @Nullable CertificateHashData[] childCertificateHashData) { + if (!isValidChildCertificateHashData(childCertificateHashData)) { + throw new PropertyConstraintException( + childCertificateHashData, "childCertificateHashData is invalid"); + } + this.childCertificateHashData = childCertificateHashData; + } + + /** + * Returns whether the given childCertificateHashData is valid + * + * @param childCertificateHashData the childCertificateHashData to check the validity of + * @return {@code true} if childCertificateHashData is valid, {@code false} if not + */ + private boolean isValidChildCertificateHashData( + @Nullable CertificateHashData[] childCertificateHashData) { + return childCertificateHashData == null + || (childCertificateHashData.length >= 1 + && childCertificateHashData.length <= 4 + && Arrays.stream(childCertificateHashData).allMatch(item -> item.validate())); + } + + /** + * Adds childCertificateHashData + * + * @param childCertificateHashData childCertificateHashData + * @return this + */ + public CertificateHashDataChain withChildCertificateHashData( + @Nullable CertificateHashData[] childCertificateHashData) { + setChildCertificateHashData(childCertificateHashData); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidCertificateHashData(certificateHashData) + && isValidCertificateType(certificateType) + && isValidChildCertificateHashData(childCertificateHashData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CertificateHashDataChain that = (CertificateHashDataChain) o; + return Objects.equals(customData, that.customData) + && Objects.equals(certificateHashData, that.certificateHashData) + && Objects.equals(certificateType, that.certificateType) + && Arrays.equals(childCertificateHashData, that.childCertificateHashData); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + certificateHashData, + certificateType, + Arrays.hashCode(childCertificateHashData)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("certificateHashData", certificateHashData) + .add("certificateType", certificateType) + .add("childCertificateHashData", childCertificateHashData) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateSignedStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateSignedStatusEnum.java new file mode 100644 index 000000000..c1fb84195 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateSignedStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Returns whether certificate signing has been accepted, otherwise rejected. */ +public enum CertificateSignedStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateSigningUseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateSigningUseEnum.java new file mode 100644 index 000000000..557711316 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CertificateSigningUseEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * The type of certificate that is to be signed. When omitted the certificate is to be used for both + * the 15118 connection (if implemented) and the Charging Station to CSMS connection. + */ +public enum CertificateSigningUseEnum { + ChargingStationCertificate, + V2GCertificate +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChangeAvailabilityStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChangeAvailabilityStatusEnum.java new file mode 100644 index 000000000..0da34bc6b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChangeAvailabilityStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the Charging Station is able to perform the availability change. */ +public enum ChangeAvailabilityStatusEnum { + Accepted, + Rejected, + Scheduled +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingLimit.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingLimit.java new file mode 100644 index 000000000..44b418f52 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingLimit.java @@ -0,0 +1,196 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Charging Limit */ +public final class ChargingLimit { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Charging Limit. Charging Limit Source. Charging Limit Source Code + * + *

The source of the charging limit. + */ + private ChargingLimitSourceEnum chargingLimitSource; + + /** + * Charging Limit. Is Grid Critical. Indicator + * + *

Whether the charging limit is critical for the grid. + */ + @Nullable private Boolean isGridCritical; + + /** + * Constructor for the ChargingLimit class + * + * @param chargingLimitSource The source of the charging limit. + */ + public ChargingLimit(ChargingLimitSourceEnum chargingLimitSource) { + setChargingLimitSource(chargingLimitSource); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingLimit withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the source of the charging limit. + * + * @return The source of the charging limit + */ + public ChargingLimitSourceEnum getChargingLimitSource() { + return chargingLimitSource; + } + + /** + * Sets the source of the charging limit. + * + * @param chargingLimitSource The source of the charging limit + */ + public void setChargingLimitSource(ChargingLimitSourceEnum chargingLimitSource) { + if (!isValidChargingLimitSource(chargingLimitSource)) { + throw new PropertyConstraintException(chargingLimitSource, "chargingLimitSource is invalid"); + } + this.chargingLimitSource = chargingLimitSource; + } + + /** + * Returns whether the given chargingLimitSource is valid + * + * @param chargingLimitSource the chargingLimitSource to check the validity of + * @return {@code true} if chargingLimitSource is valid, {@code false} if not + */ + private boolean isValidChargingLimitSource(ChargingLimitSourceEnum chargingLimitSource) { + return chargingLimitSource != null; + } + + /** + * Gets whether the charging limit is critical for the grid. + * + * @return Whether the charging limit is critical for the grid + */ + @Nullable + public Boolean getIsGridCritical() { + return isGridCritical; + } + + /** + * Sets whether the charging limit is critical for the grid. + * + * @param isGridCritical Whether the charging limit is critical for the grid + */ + public void setIsGridCritical(@Nullable Boolean isGridCritical) { + this.isGridCritical = isGridCritical; + } + + /** + * Adds whether the charging limit is critical for the grid. + * + * @param isGridCritical Whether the charging limit is critical for the grid + * @return this + */ + public ChargingLimit withIsGridCritical(@Nullable Boolean isGridCritical) { + setIsGridCritical(isGridCritical); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) && isValidChargingLimitSource(chargingLimitSource); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingLimit that = (ChargingLimit) o; + return Objects.equals(customData, that.customData) + && Objects.equals(chargingLimitSource, that.chargingLimitSource) + && Objects.equals(isGridCritical, that.isGridCritical); + } + + @Override + public int hashCode() { + return Objects.hash(customData, chargingLimitSource, isGridCritical); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("chargingLimitSource", chargingLimitSource) + .add("isGridCritical", isGridCritical) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingLimitSourceEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingLimitSourceEnum.java new file mode 100644 index 000000000..602f72518 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingLimitSourceEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Source that has installed this charging profile. */ +public enum ChargingLimitSourceEnum { + EMS, + Other, + SO, + CSO +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingNeeds.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingNeeds.java new file mode 100644 index 000000000..a3eb94b25 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingNeeds.java @@ -0,0 +1,314 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Charging Needs */ +public final class ChargingNeeds { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * AC Charging Parameters + * + *

EV AC charging parameters. + */ + @Nullable private ACChargingParameters acChargingParameters; + + /** + * DC Charging Parameters + * + *

EV DC charging parameters + */ + @Nullable private DCChargingParameters dcChargingParameters; + + /** + * Charging Needs. Requested. Energy Transfer Mode Code + * + *

Mode of energy transfer requested by the EV. + */ + private EnergyTransferModeEnum requestedEnergyTransfer; + + /** + * Charging Needs. Departure Time. Date Time + * + *

Estimated departure time of the EV. + */ + @Nullable private ZonedDateTime departureTime; + + /** + * Constructor for the ChargingNeeds class + * + * @param requestedEnergyTransfer Mode of energy transfer requested by the EV. + */ + public ChargingNeeds(EnergyTransferModeEnum requestedEnergyTransfer) { + setRequestedEnergyTransfer(requestedEnergyTransfer); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingNeeds withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets EV AC charging parameters. + * + * @return EV AC charging parameters + */ + @Nullable + public ACChargingParameters getAcChargingParameters() { + return acChargingParameters; + } + + /** + * Sets EV AC charging parameters. + * + * @param acChargingParameters EV AC charging parameters + */ + public void setAcChargingParameters(@Nullable ACChargingParameters acChargingParameters) { + if (!isValidAcChargingParameters(acChargingParameters)) { + throw new PropertyConstraintException( + acChargingParameters, "acChargingParameters is invalid"); + } + this.acChargingParameters = acChargingParameters; + } + + /** + * Returns whether the given acChargingParameters is valid + * + * @param acChargingParameters the acChargingParameters to check the validity of + * @return {@code true} if acChargingParameters is valid, {@code false} if not + */ + private boolean isValidAcChargingParameters(@Nullable ACChargingParameters acChargingParameters) { + return acChargingParameters == null || acChargingParameters.validate(); + } + + /** + * Adds EV AC charging parameters. + * + * @param acChargingParameters EV AC charging parameters + * @return this + */ + public ChargingNeeds withAcChargingParameters( + @Nullable ACChargingParameters acChargingParameters) { + setAcChargingParameters(acChargingParameters); + return this; + } + + /** + * Gets EV DC charging parameters + * + * @return EV DC charging parameters + */ + @Nullable + public DCChargingParameters getDcChargingParameters() { + return dcChargingParameters; + } + + /** + * Sets EV DC charging parameters + * + * @param dcChargingParameters EV DC charging parameters + */ + public void setDcChargingParameters(@Nullable DCChargingParameters dcChargingParameters) { + if (!isValidDcChargingParameters(dcChargingParameters)) { + throw new PropertyConstraintException( + dcChargingParameters, "dcChargingParameters is invalid"); + } + this.dcChargingParameters = dcChargingParameters; + } + + /** + * Returns whether the given dcChargingParameters is valid + * + * @param dcChargingParameters the dcChargingParameters to check the validity of + * @return {@code true} if dcChargingParameters is valid, {@code false} if not + */ + private boolean isValidDcChargingParameters(@Nullable DCChargingParameters dcChargingParameters) { + return dcChargingParameters == null || dcChargingParameters.validate(); + } + + /** + * Adds EV DC charging parameters + * + * @param dcChargingParameters EV DC charging parameters + * @return this + */ + public ChargingNeeds withDcChargingParameters( + @Nullable DCChargingParameters dcChargingParameters) { + setDcChargingParameters(dcChargingParameters); + return this; + } + + /** + * Gets mode of energy transfer requested by the EV. + * + * @return Mode of energy transfer requested by the EV + */ + public EnergyTransferModeEnum getRequestedEnergyTransfer() { + return requestedEnergyTransfer; + } + + /** + * Sets mode of energy transfer requested by the EV. + * + * @param requestedEnergyTransfer Mode of energy transfer requested by the EV + */ + public void setRequestedEnergyTransfer(EnergyTransferModeEnum requestedEnergyTransfer) { + if (!isValidRequestedEnergyTransfer(requestedEnergyTransfer)) { + throw new PropertyConstraintException( + requestedEnergyTransfer, "requestedEnergyTransfer is invalid"); + } + this.requestedEnergyTransfer = requestedEnergyTransfer; + } + + /** + * Returns whether the given requestedEnergyTransfer is valid + * + * @param requestedEnergyTransfer the requestedEnergyTransfer to check the validity of + * @return {@code true} if requestedEnergyTransfer is valid, {@code false} if not + */ + private boolean isValidRequestedEnergyTransfer(EnergyTransferModeEnum requestedEnergyTransfer) { + return requestedEnergyTransfer != null; + } + + /** + * Gets estimated departure time of the EV. + * + * @return Estimated departure time of the EV + */ + @Nullable + public ZonedDateTime getDepartureTime() { + return departureTime; + } + + /** + * Sets estimated departure time of the EV. + * + * @param departureTime Estimated departure time of the EV + */ + public void setDepartureTime(@Nullable ZonedDateTime departureTime) { + this.departureTime = departureTime; + } + + /** + * Adds estimated departure time of the EV. + * + * @param departureTime Estimated departure time of the EV + * @return this + */ + public ChargingNeeds withDepartureTime(@Nullable ZonedDateTime departureTime) { + setDepartureTime(departureTime); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidAcChargingParameters(acChargingParameters) + && isValidDcChargingParameters(dcChargingParameters) + && isValidRequestedEnergyTransfer(requestedEnergyTransfer); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingNeeds that = (ChargingNeeds) o; + return Objects.equals(customData, that.customData) + && Objects.equals(acChargingParameters, that.acChargingParameters) + && Objects.equals(dcChargingParameters, that.dcChargingParameters) + && Objects.equals(requestedEnergyTransfer, that.requestedEnergyTransfer) + && Objects.equals(departureTime, that.departureTime); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + acChargingParameters, + dcChargingParameters, + requestedEnergyTransfer, + departureTime); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("acChargingParameters", acChargingParameters) + .add("dcChargingParameters", dcChargingParameters) + .add("requestedEnergyTransfer", requestedEnergyTransfer) + .add("departureTime", departureTime) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfile.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfile.java new file mode 100644 index 000000000..d4c9c14d2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfile.java @@ -0,0 +1,546 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Charging Profile + * + *

A ChargingProfile consists of ChargingSchedule, describing the amount of power or current that + * can be delivered per time interval. + */ +public final class ChargingProfile { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Identified Object. MRID. Numeric Identifier + * + *

Id of ChargingProfile. + */ + private Integer id; + + /** + * Charging Profile. Stack Level. Counter + * + *

Value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + */ + private Integer stackLevel; + + /** + * Charging Profile. Charging Profile Purpose. Charging Profile Purpose Code + * + *

The purpose of the schedule transferred by this profile + */ + private ChargingProfilePurposeEnum chargingProfilePurpose; + + /** + * Charging Profile. Charging Profile Kind. Charging Profile Kind Code + * + *

The kind of schedule. + */ + private ChargingProfileKindEnum chargingProfileKind; + + /** + * Charging Profile. Recurrency Kind. Recurrency Kind Code + * + *

The start point of a recurrence. + */ + @Nullable private RecurrencyKindEnum recurrencyKind; + + /** + * Charging Profile. Valid From. Date Time + * + *

Point in time at which the profile starts to be valid. If absent, the profile is valid as + * soon as it is received by the Charging Station. + */ + @Nullable private ZonedDateTime validFrom; + + /** + * Charging Profile. Valid To. Date Time + * + *

Point in time at which the profile stops to be valid. If absent, the profile is valid until + * it is replaced by another profile. + */ + @Nullable private ZonedDateTime validTo; + + /** + * Charging Schedule + * + *

Charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile. + */ + private ChargingSchedule[] chargingSchedule; + + /** + * SHALL only be included if ChargingProfilePurpose is set to TxProfile. The transactionId is used + * to match the profile to a specific transaction. + */ + @Nullable private String transactionId; + + /** + * Constructor for the ChargingProfile class + * + * @param id Id of ChargingProfile. + * @param stackLevel Value determining level in hierarchy stack of profiles. Higher values have + * precedence over lower values. Lowest level is 0. + * @param chargingProfilePurpose The purpose of the schedule transferred by this profile + * @param chargingProfileKind The kind of schedule. + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: GetCompositeSchedule.conf and ChargingProfile. + */ + public ChargingProfile( + Integer id, + Integer stackLevel, + ChargingProfilePurposeEnum chargingProfilePurpose, + ChargingProfileKindEnum chargingProfileKind, + ChargingSchedule[] chargingSchedule) { + setId(id); + setStackLevel(stackLevel); + setChargingProfilePurpose(chargingProfilePurpose); + setChargingProfileKind(chargingProfileKind); + setChargingSchedule(chargingSchedule); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingProfile withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets id of ChargingProfile. + * + * @return Id of ChargingProfile + */ + public Integer getId() { + return id; + } + + /** + * Sets id of ChargingProfile. + * + * @param id Id of ChargingProfile + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null; + } + + /** + * Gets value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + * + * @return Value determining level in hierarchy stack of profiles + */ + public Integer getStackLevel() { + return stackLevel; + } + + /** + * Sets value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + * + * @param stackLevel Value determining level in hierarchy stack of profiles + */ + public void setStackLevel(Integer stackLevel) { + if (!isValidStackLevel(stackLevel)) { + throw new PropertyConstraintException(stackLevel, "stackLevel is invalid"); + } + this.stackLevel = stackLevel; + } + + /** + * Returns whether the given stackLevel is valid + * + * @param stackLevel the stackLevel to check the validity of + * @return {@code true} if stackLevel is valid, {@code false} if not + */ + private boolean isValidStackLevel(Integer stackLevel) { + return stackLevel != null; + } + + /** + * Gets the purpose of the schedule transferred by this profile + * + * @return The purpose of the schedule transferred by this profile + */ + public ChargingProfilePurposeEnum getChargingProfilePurpose() { + return chargingProfilePurpose; + } + + /** + * Sets the purpose of the schedule transferred by this profile + * + * @param chargingProfilePurpose The purpose of the schedule transferred by this profile + */ + public void setChargingProfilePurpose(ChargingProfilePurposeEnum chargingProfilePurpose) { + if (!isValidChargingProfilePurpose(chargingProfilePurpose)) { + throw new PropertyConstraintException( + chargingProfilePurpose, "chargingProfilePurpose is invalid"); + } + this.chargingProfilePurpose = chargingProfilePurpose; + } + + /** + * Returns whether the given chargingProfilePurpose is valid + * + * @param chargingProfilePurpose the chargingProfilePurpose to check the validity of + * @return {@code true} if chargingProfilePurpose is valid, {@code false} if not + */ + private boolean isValidChargingProfilePurpose(ChargingProfilePurposeEnum chargingProfilePurpose) { + return chargingProfilePurpose != null; + } + + /** + * Gets the kind of schedule. + * + * @return The kind of schedule + */ + public ChargingProfileKindEnum getChargingProfileKind() { + return chargingProfileKind; + } + + /** + * Sets the kind of schedule. + * + * @param chargingProfileKind The kind of schedule + */ + public void setChargingProfileKind(ChargingProfileKindEnum chargingProfileKind) { + if (!isValidChargingProfileKind(chargingProfileKind)) { + throw new PropertyConstraintException(chargingProfileKind, "chargingProfileKind is invalid"); + } + this.chargingProfileKind = chargingProfileKind; + } + + /** + * Returns whether the given chargingProfileKind is valid + * + * @param chargingProfileKind the chargingProfileKind to check the validity of + * @return {@code true} if chargingProfileKind is valid, {@code false} if not + */ + private boolean isValidChargingProfileKind(ChargingProfileKindEnum chargingProfileKind) { + return chargingProfileKind != null; + } + + /** + * Gets the start point of a recurrence. + * + * @return The start point of a recurrence + */ + @Nullable + public RecurrencyKindEnum getRecurrencyKind() { + return recurrencyKind; + } + + /** + * Sets the start point of a recurrence. + * + * @param recurrencyKind The start point of a recurrence + */ + public void setRecurrencyKind(@Nullable RecurrencyKindEnum recurrencyKind) { + this.recurrencyKind = recurrencyKind; + } + + /** + * Adds the start point of a recurrence. + * + * @param recurrencyKind The start point of a recurrence + * @return this + */ + public ChargingProfile withRecurrencyKind(@Nullable RecurrencyKindEnum recurrencyKind) { + setRecurrencyKind(recurrencyKind); + return this; + } + + /** + * Gets point in time at which the profile starts to be valid. If absent, the profile is valid as + * soon as it is received by the Charging Station. + * + * @return Point in time at which the profile starts to be valid + */ + @Nullable + public ZonedDateTime getValidFrom() { + return validFrom; + } + + /** + * Sets point in time at which the profile starts to be valid. If absent, the profile is valid as + * soon as it is received by the Charging Station. + * + * @param validFrom Point in time at which the profile starts to be valid + */ + public void setValidFrom(@Nullable ZonedDateTime validFrom) { + this.validFrom = validFrom; + } + + /** + * Adds point in time at which the profile starts to be valid. If absent, the profile is valid as + * soon as it is received by the Charging Station. + * + * @param validFrom Point in time at which the profile starts to be valid + * @return this + */ + public ChargingProfile withValidFrom(@Nullable ZonedDateTime validFrom) { + setValidFrom(validFrom); + return this; + } + + /** + * Gets point in time at which the profile stops to be valid. If absent, the profile is valid + * until it is replaced by another profile. + * + * @return Point in time at which the profile stops to be valid + */ + @Nullable + public ZonedDateTime getValidTo() { + return validTo; + } + + /** + * Sets point in time at which the profile stops to be valid. If absent, the profile is valid + * until it is replaced by another profile. + * + * @param validTo Point in time at which the profile stops to be valid + */ + public void setValidTo(@Nullable ZonedDateTime validTo) { + this.validTo = validTo; + } + + /** + * Adds point in time at which the profile stops to be valid. If absent, the profile is valid + * until it is replaced by another profile. + * + * @param validTo Point in time at which the profile stops to be valid + * @return this + */ + public ChargingProfile withValidTo(@Nullable ZonedDateTime validTo) { + setValidTo(validTo); + return this; + } + + /** + * Gets charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile. + * + * @return Charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile + */ + public ChargingSchedule[] getChargingSchedule() { + return chargingSchedule; + } + + /** + * Sets charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile. + * + * @param chargingSchedule Charging schedule structure defines a list of charging periods, as used + * in: GetCompositeSchedule.conf and ChargingProfile + */ + public void setChargingSchedule(ChargingSchedule[] chargingSchedule) { + if (!isValidChargingSchedule(chargingSchedule)) { + throw new PropertyConstraintException(chargingSchedule, "chargingSchedule is invalid"); + } + this.chargingSchedule = chargingSchedule; + } + + /** + * Returns whether the given chargingSchedule is valid + * + * @param chargingSchedule the chargingSchedule to check the validity of + * @return {@code true} if chargingSchedule is valid, {@code false} if not + */ + private boolean isValidChargingSchedule(ChargingSchedule[] chargingSchedule) { + return chargingSchedule != null + && chargingSchedule.length >= 1 + && chargingSchedule.length <= 3 + && Arrays.stream(chargingSchedule).allMatch(item -> item.validate()); + } + + /** + * Gets SHALL only be included if ChargingProfilePurpose is set to TxProfile. The transactionId is + * used to match the profile to a specific transaction. + * + * @return SHALL only be included if ChargingProfilePurpose is set to TxProfile + */ + @Nullable + public String getTransactionId() { + return transactionId; + } + + /** + * Sets SHALL only be included if ChargingProfilePurpose is set to TxProfile. The transactionId is + * used to match the profile to a specific transaction. + * + * @param transactionId SHALL only be included if ChargingProfilePurpose is set to TxProfile + */ + public void setTransactionId(@Nullable String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(@Nullable String transactionId) { + return transactionId == null || transactionId.length() <= 36; + } + + /** + * Adds SHALL only be included if ChargingProfilePurpose is set to TxProfile. The transactionId is + * used to match the profile to a specific transaction. + * + * @param transactionId SHALL only be included if ChargingProfilePurpose is set to TxProfile + * @return this + */ + public ChargingProfile withTransactionId(@Nullable String transactionId) { + setTransactionId(transactionId); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidId(id) + && isValidStackLevel(stackLevel) + && isValidChargingProfilePurpose(chargingProfilePurpose) + && isValidChargingProfileKind(chargingProfileKind) + && isValidChargingSchedule(chargingSchedule) + && isValidTransactionId(transactionId); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingProfile that = (ChargingProfile) o; + return Objects.equals(customData, that.customData) + && Objects.equals(id, that.id) + && Objects.equals(stackLevel, that.stackLevel) + && Objects.equals(chargingProfilePurpose, that.chargingProfilePurpose) + && Objects.equals(chargingProfileKind, that.chargingProfileKind) + && Objects.equals(recurrencyKind, that.recurrencyKind) + && Objects.equals(validFrom, that.validFrom) + && Objects.equals(validTo, that.validTo) + && Arrays.equals(chargingSchedule, that.chargingSchedule) + && Objects.equals(transactionId, that.transactionId); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + id, + stackLevel, + chargingProfilePurpose, + chargingProfileKind, + recurrencyKind, + validFrom, + validTo, + Arrays.hashCode(chargingSchedule), + transactionId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("id", id) + .add("stackLevel", stackLevel) + .add("chargingProfilePurpose", chargingProfilePurpose) + .add("chargingProfileKind", chargingProfileKind) + .add("recurrencyKind", recurrencyKind) + .add("validFrom", validFrom) + .add("validTo", validTo) + .add("chargingSchedule", chargingSchedule) + .add("transactionId", transactionId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfileCriterion.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfileCriterion.java new file mode 100644 index 000000000..9b0553a30 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfileCriterion.java @@ -0,0 +1,329 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Charging Profile + * + *

A ChargingProfile consists of ChargingSchedule, describing the amount of power or current that + * can be delivered per time interval. + */ +public final class ChargingProfileCriterion { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Charging Profile. Charging Profile Purpose. Charging Profile Purpose Code + * + *

The purpose of the schedule transferred by this profile + */ + @Nullable private ChargingProfilePurposeEnum chargingProfilePurpose; + + /** + * Charging Profile. Stack Level. Counter + * + *

Value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + */ + @Nullable private Integer stackLevel; + + /** + * List of all the chargingProfileIds requested. Any ChargingProfile that matches one of these + * profiles will be reported. If omitted, the Charging Station SHALL not filter on + * chargingProfileId. This field SHALL NOT contain more ids than set in + * ChargingProfileEntries.maxLimit + */ + @Nullable private Integer[] chargingProfileId; + + /** + * For which charging limit sources, charging profiles SHALL be reported. If omitted, the Charging + * Station SHALL not filter on chargingLimitSource. + */ + @Nullable private ChargingLimitSourceEnum[] chargingLimitSource; + + /** Constructor for the ChargingProfileCriterion class */ + public ChargingProfileCriterion() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingProfileCriterion withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the purpose of the schedule transferred by this profile + * + * @return The purpose of the schedule transferred by this profile + */ + @Nullable + public ChargingProfilePurposeEnum getChargingProfilePurpose() { + return chargingProfilePurpose; + } + + /** + * Sets the purpose of the schedule transferred by this profile + * + * @param chargingProfilePurpose The purpose of the schedule transferred by this profile + */ + public void setChargingProfilePurpose( + @Nullable ChargingProfilePurposeEnum chargingProfilePurpose) { + this.chargingProfilePurpose = chargingProfilePurpose; + } + + /** + * Adds the purpose of the schedule transferred by this profile + * + * @param chargingProfilePurpose The purpose of the schedule transferred by this profile + * @return this + */ + public ChargingProfileCriterion withChargingProfilePurpose( + @Nullable ChargingProfilePurposeEnum chargingProfilePurpose) { + setChargingProfilePurpose(chargingProfilePurpose); + return this; + } + + /** + * Gets value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + * + * @return Value determining level in hierarchy stack of profiles + */ + @Nullable + public Integer getStackLevel() { + return stackLevel; + } + + /** + * Sets value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + * + * @param stackLevel Value determining level in hierarchy stack of profiles + */ + public void setStackLevel(@Nullable Integer stackLevel) { + this.stackLevel = stackLevel; + } + + /** + * Adds value determining level in hierarchy stack of profiles. Higher values have precedence over + * lower values. Lowest level is 0. + * + * @param stackLevel Value determining level in hierarchy stack of profiles + * @return this + */ + public ChargingProfileCriterion withStackLevel(@Nullable Integer stackLevel) { + setStackLevel(stackLevel); + return this; + } + + /** + * Gets list of all the chargingProfileIds requested. Any ChargingProfile that matches one of + * these profiles will be reported. If omitted, the Charging Station SHALL not filter on + * chargingProfileId. This field SHALL NOT contain more ids than set in + * ChargingProfileEntries.maxLimit + * + * @return List of all the chargingProfileIds requested + */ + @Nullable + public Integer[] getChargingProfileId() { + return chargingProfileId; + } + + /** + * Sets list of all the chargingProfileIds requested. Any ChargingProfile that matches one of + * these profiles will be reported. If omitted, the Charging Station SHALL not filter on + * chargingProfileId. This field SHALL NOT contain more ids than set in + * ChargingProfileEntries.maxLimit + * + * @param chargingProfileId List of all the chargingProfileIds requested + */ + public void setChargingProfileId(@Nullable Integer[] chargingProfileId) { + if (!isValidChargingProfileId(chargingProfileId)) { + throw new PropertyConstraintException(chargingProfileId, "chargingProfileId is invalid"); + } + this.chargingProfileId = chargingProfileId; + } + + /** + * Returns whether the given chargingProfileId is valid + * + * @param chargingProfileId the chargingProfileId to check the validity of + * @return {@code true} if chargingProfileId is valid, {@code false} if not + */ + private boolean isValidChargingProfileId(@Nullable Integer[] chargingProfileId) { + return chargingProfileId == null || (chargingProfileId.length >= 1); + } + + /** + * Adds list of all the chargingProfileIds requested. Any ChargingProfile that matches one of + * these profiles will be reported. If omitted, the Charging Station SHALL not filter on + * chargingProfileId. This field SHALL NOT contain more ids than set in + * ChargingProfileEntries.maxLimit + * + * @param chargingProfileId List of all the chargingProfileIds requested + * @return this + */ + public ChargingProfileCriterion withChargingProfileId(@Nullable Integer[] chargingProfileId) { + setChargingProfileId(chargingProfileId); + return this; + } + + /** + * Gets for which charging limit sources, charging profiles SHALL be reported. If omitted, the + * Charging Station SHALL not filter on chargingLimitSource. + * + * @return For which charging limit sources, charging profiles SHALL be reported + */ + @Nullable + public ChargingLimitSourceEnum[] getChargingLimitSource() { + return chargingLimitSource; + } + + /** + * Sets for which charging limit sources, charging profiles SHALL be reported. If omitted, the + * Charging Station SHALL not filter on chargingLimitSource. + * + * @param chargingLimitSource For which charging limit sources, charging profiles SHALL be + * reported + */ + public void setChargingLimitSource(@Nullable ChargingLimitSourceEnum[] chargingLimitSource) { + if (!isValidChargingLimitSource(chargingLimitSource)) { + throw new PropertyConstraintException(chargingLimitSource, "chargingLimitSource is invalid"); + } + this.chargingLimitSource = chargingLimitSource; + } + + /** + * Returns whether the given chargingLimitSource is valid + * + * @param chargingLimitSource the chargingLimitSource to check the validity of + * @return {@code true} if chargingLimitSource is valid, {@code false} if not + */ + private boolean isValidChargingLimitSource( + @Nullable ChargingLimitSourceEnum[] chargingLimitSource) { + return chargingLimitSource == null + || (chargingLimitSource.length >= 1 && chargingLimitSource.length <= 4); + } + + /** + * Adds for which charging limit sources, charging profiles SHALL be reported. If omitted, the + * Charging Station SHALL not filter on chargingLimitSource. + * + * @param chargingLimitSource For which charging limit sources, charging profiles SHALL be + * reported + * @return this + */ + public ChargingProfileCriterion withChargingLimitSource( + @Nullable ChargingLimitSourceEnum[] chargingLimitSource) { + setChargingLimitSource(chargingLimitSource); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidChargingProfileId(chargingProfileId) + && isValidChargingLimitSource(chargingLimitSource); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingProfileCriterion that = (ChargingProfileCriterion) o; + return Objects.equals(customData, that.customData) + && Objects.equals(chargingProfilePurpose, that.chargingProfilePurpose) + && Objects.equals(stackLevel, that.stackLevel) + && Arrays.equals(chargingProfileId, that.chargingProfileId) + && Arrays.equals(chargingLimitSource, that.chargingLimitSource); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + chargingProfilePurpose, + stackLevel, + Arrays.hashCode(chargingProfileId), + Arrays.hashCode(chargingLimitSource)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("chargingProfilePurpose", chargingProfilePurpose) + .add("stackLevel", stackLevel) + .add("chargingProfileId", chargingProfileId) + .add("chargingLimitSource", chargingLimitSource) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfileKindEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfileKindEnum.java new file mode 100644 index 000000000..cd1bc44af --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfileKindEnum.java @@ -0,0 +1,36 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Charging Profile. Charging Profile Kind. Charging Profile Kind Code + * + *

The kind of schedule. + */ +public enum ChargingProfileKindEnum { + Absolute, + Recurring, + Relative +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfilePurposeEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfilePurposeEnum.java new file mode 100644 index 000000000..62942ec88 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfilePurposeEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Charging Profile. Charging Profile Purpose. Charging Profile Purpose Code + * + *

The purpose of the schedule transferred by this profile + */ +public enum ChargingProfilePurposeEnum { + ChargingStationExternalConstraints, + ChargingStationMaxProfile, + TxDefaultProfile, + TxProfile +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfileStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfileStatusEnum.java new file mode 100644 index 000000000..19775ec89 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingProfileStatusEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Returns whether the Charging Station has been able to process the message successfully. This does + * not guarantee the schedule will be followed to the letter. There might be other constraints the + * Charging Station may need to take into account. + */ +public enum ChargingProfileStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingRateUnitEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingRateUnitEnum.java new file mode 100644 index 000000000..7ae9885b4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingRateUnitEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Charging Schedule. Charging Rate Unit. Charging Rate Unit Code + * + *

The unit of measure Limit is expressed in. + */ +public enum ChargingRateUnitEnum { + W, + A +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingSchedule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingSchedule.java new file mode 100644 index 000000000..49a04c63f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingSchedule.java @@ -0,0 +1,458 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Charging Schedule + * + *

Charging schedule structure defines a list of charging periods, as used in: + * GetCompositeSchedule.conf and ChargingProfile. + */ +public final class ChargingSchedule { + /** Custom data */ + @Nullable private CustomData customData; + + /** The identifier of the ChargingSchedule. */ + private Integer id; + + /** + * Charging Schedule. Start Schedule. Date Time + * + *

Starting point of an absolute schedule. If absent the schedule will be relative to start of + * charging. + */ + @Nullable private ZonedDateTime startSchedule; + + /** + * Charging Schedule. Duration. Elapsed Time + * + *

Duration of the charging schedule in seconds. If the duration is left empty, the last period + * will continue indefinitely or until end of the transaction if chargingProfilePurpose = + * TxProfile. + */ + @Nullable private Integer duration; + + /** + * Charging Schedule. Charging Rate Unit. Charging Rate Unit Code + * + *

The unit of measure Limit is expressed in. + */ + private ChargingRateUnitEnum chargingRateUnit; + + /** + * Charging Schedule Period + * + *

Charging schedule period structure defines a time period in a charging schedule. + */ + private ChargingSchedulePeriod[] chargingSchedulePeriod; + + /** + * Charging Schedule. Min Charging Rate. Numeric + * + *

Minimum charging rate supported by the EV. The unit of measure is defined by the + * chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to + * optimize the power allocation for in the case a charging process is inefficient at lower + * charging rates. Accepts at most one digit fraction (e.g. 8.1) + */ + @Nullable private Double minChargingRate; + + /** + * Sales Tariff + * + *

NOTE: This dataType is based on dataTypes from ISO 15118-2. + */ + @Nullable private SalesTariff salesTariff; + + /** + * Constructor for the ChargingSchedule class + * + * @param id The identifier of the ChargingSchedule. + * @param chargingRateUnit The unit of measure Limit is expressed in. + * @param chargingSchedulePeriod Charging schedule period structure defines a time period in a + * charging schedule. + */ + public ChargingSchedule( + Integer id, + ChargingRateUnitEnum chargingRateUnit, + ChargingSchedulePeriod[] chargingSchedulePeriod) { + setId(id); + setChargingRateUnit(chargingRateUnit); + setChargingSchedulePeriod(chargingSchedulePeriod); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingSchedule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the identifier of the ChargingSchedule. + * + * @return The identifier of the ChargingSchedule + */ + public Integer getId() { + return id; + } + + /** + * Sets the identifier of the ChargingSchedule. + * + * @param id The identifier of the ChargingSchedule + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null; + } + + /** + * Gets starting point of an absolute schedule. If absent the schedule will be relative to start + * of charging. + * + * @return Starting point of an absolute schedule + */ + @Nullable + public ZonedDateTime getStartSchedule() { + return startSchedule; + } + + /** + * Sets starting point of an absolute schedule. If absent the schedule will be relative to start + * of charging. + * + * @param startSchedule Starting point of an absolute schedule + */ + public void setStartSchedule(@Nullable ZonedDateTime startSchedule) { + this.startSchedule = startSchedule; + } + + /** + * Adds starting point of an absolute schedule. If absent the schedule will be relative to start + * of charging. + * + * @param startSchedule Starting point of an absolute schedule + * @return this + */ + public ChargingSchedule withStartSchedule(@Nullable ZonedDateTime startSchedule) { + setStartSchedule(startSchedule); + return this; + } + + /** + * Gets duration of the charging schedule in seconds. If the duration is left empty, the last + * period will continue indefinitely or until end of the transaction if chargingProfilePurpose = + * TxProfile. + * + * @return Duration of the charging schedule in seconds + */ + @Nullable + public Integer getDuration() { + return duration; + } + + /** + * Sets duration of the charging schedule in seconds. If the duration is left empty, the last + * period will continue indefinitely or until end of the transaction if chargingProfilePurpose = + * TxProfile. + * + * @param duration Duration of the charging schedule in seconds + */ + public void setDuration(@Nullable Integer duration) { + this.duration = duration; + } + + /** + * Adds duration of the charging schedule in seconds. If the duration is left empty, the last + * period will continue indefinitely or until end of the transaction if chargingProfilePurpose = + * TxProfile. + * + * @param duration Duration of the charging schedule in seconds + * @return this + */ + public ChargingSchedule withDuration(@Nullable Integer duration) { + setDuration(duration); + return this; + } + + /** + * Gets the unit of measure Limit is expressed in. + * + * @return The unit of measure Limit is expressed in + */ + public ChargingRateUnitEnum getChargingRateUnit() { + return chargingRateUnit; + } + + /** + * Sets the unit of measure Limit is expressed in. + * + * @param chargingRateUnit The unit of measure Limit is expressed in + */ + public void setChargingRateUnit(ChargingRateUnitEnum chargingRateUnit) { + if (!isValidChargingRateUnit(chargingRateUnit)) { + throw new PropertyConstraintException(chargingRateUnit, "chargingRateUnit is invalid"); + } + this.chargingRateUnit = chargingRateUnit; + } + + /** + * Returns whether the given chargingRateUnit is valid + * + * @param chargingRateUnit the chargingRateUnit to check the validity of + * @return {@code true} if chargingRateUnit is valid, {@code false} if not + */ + private boolean isValidChargingRateUnit(ChargingRateUnitEnum chargingRateUnit) { + return chargingRateUnit != null; + } + + /** + * Gets charging schedule period structure defines a time period in a charging schedule. + * + * @return Charging schedule period structure defines a time period in a charging schedule + */ + public ChargingSchedulePeriod[] getChargingSchedulePeriod() { + return chargingSchedulePeriod; + } + + /** + * Sets charging schedule period structure defines a time period in a charging schedule. + * + * @param chargingSchedulePeriod Charging schedule period structure defines a time period in a + * charging schedule + */ + public void setChargingSchedulePeriod(ChargingSchedulePeriod[] chargingSchedulePeriod) { + if (!isValidChargingSchedulePeriod(chargingSchedulePeriod)) { + throw new PropertyConstraintException( + chargingSchedulePeriod, "chargingSchedulePeriod is invalid"); + } + this.chargingSchedulePeriod = chargingSchedulePeriod; + } + + /** + * Returns whether the given chargingSchedulePeriod is valid + * + * @param chargingSchedulePeriod the chargingSchedulePeriod to check the validity of + * @return {@code true} if chargingSchedulePeriod is valid, {@code false} if not + */ + private boolean isValidChargingSchedulePeriod(ChargingSchedulePeriod[] chargingSchedulePeriod) { + return chargingSchedulePeriod != null + && chargingSchedulePeriod.length >= 1 + && chargingSchedulePeriod.length <= 1024 + && Arrays.stream(chargingSchedulePeriod).allMatch(item -> item.validate()); + } + + /** + * Gets minimum charging rate supported by the EV. The unit of measure is defined by the + * chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to + * optimize the power allocation for in the case a charging process is inefficient at lower + * charging rates. Accepts at most one digit fraction (e.g. 8.1) + * + * @return Minimum charging rate supported by the EV + */ + @Nullable + public Double getMinChargingRate() { + return minChargingRate; + } + + /** + * Sets minimum charging rate supported by the EV. The unit of measure is defined by the + * chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to + * optimize the power allocation for in the case a charging process is inefficient at lower + * charging rates. Accepts at most one digit fraction (e.g. 8.1) + * + * @param minChargingRate Minimum charging rate supported by the EV + */ + public void setMinChargingRate(@Nullable Double minChargingRate) { + this.minChargingRate = minChargingRate; + } + + /** + * Adds minimum charging rate supported by the EV. The unit of measure is defined by the + * chargingRateUnit. This parameter is intended to be used by a local smart charging algorithm to + * optimize the power allocation for in the case a charging process is inefficient at lower + * charging rates. Accepts at most one digit fraction (e.g. 8.1) + * + * @param minChargingRate Minimum charging rate supported by the EV + * @return this + */ + public ChargingSchedule withMinChargingRate(@Nullable Double minChargingRate) { + setMinChargingRate(minChargingRate); + return this; + } + + /** + * Gets NOTE: This dataType is based on dataTypes from ISO 15118-2. + * + * @return NOTE: This dataType is based on dataTypes from ISO 15118-2 + */ + @Nullable + public SalesTariff getSalesTariff() { + return salesTariff; + } + + /** + * Sets NOTE: This dataType is based on dataTypes from ISO 15118-2. + * + * @param salesTariff NOTE: This dataType is based on dataTypes from ISO 15118-2 + */ + public void setSalesTariff(@Nullable SalesTariff salesTariff) { + if (!isValidSalesTariff(salesTariff)) { + throw new PropertyConstraintException(salesTariff, "salesTariff is invalid"); + } + this.salesTariff = salesTariff; + } + + /** + * Returns whether the given salesTariff is valid + * + * @param salesTariff the salesTariff to check the validity of + * @return {@code true} if salesTariff is valid, {@code false} if not + */ + private boolean isValidSalesTariff(@Nullable SalesTariff salesTariff) { + return salesTariff == null || salesTariff.validate(); + } + + /** + * Adds NOTE: This dataType is based on dataTypes from ISO 15118-2. + * + * @param salesTariff NOTE: This dataType is based on dataTypes from ISO 15118-2 + * @return this + */ + public ChargingSchedule withSalesTariff(@Nullable SalesTariff salesTariff) { + setSalesTariff(salesTariff); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidId(id) + && isValidChargingRateUnit(chargingRateUnit) + && isValidChargingSchedulePeriod(chargingSchedulePeriod) + && isValidSalesTariff(salesTariff); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingSchedule that = (ChargingSchedule) o; + return Objects.equals(customData, that.customData) + && Objects.equals(id, that.id) + && Objects.equals(startSchedule, that.startSchedule) + && Objects.equals(duration, that.duration) + && Objects.equals(chargingRateUnit, that.chargingRateUnit) + && Arrays.equals(chargingSchedulePeriod, that.chargingSchedulePeriod) + && Objects.equals(minChargingRate, that.minChargingRate) + && Objects.equals(salesTariff, that.salesTariff); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + id, + startSchedule, + duration, + chargingRateUnit, + Arrays.hashCode(chargingSchedulePeriod), + minChargingRate, + salesTariff); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("id", id) + .add("startSchedule", startSchedule) + .add("duration", duration) + .add("chargingRateUnit", chargingRateUnit) + .add("chargingSchedulePeriod", chargingSchedulePeriod) + .add("minChargingRate", minChargingRate) + .add("salesTariff", salesTariff) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingSchedulePeriod.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingSchedulePeriod.java new file mode 100644 index 000000000..4cafac04b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingSchedulePeriod.java @@ -0,0 +1,309 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Charging Schedule Period + * + *

Charging schedule period structure defines a time period in a charging schedule. + */ +public final class ChargingSchedulePeriod { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Charging Schedule Period. Start Period. Elapsed Time + * + *

Start of the period, in seconds from the start of schedule. The value of StartPeriod also + * defines the stop time of the previous period. + */ + private Integer startPeriod; + + /** + * Charging Schedule Period. Limit. Measure + * + *

Charging rate limit during the schedule period, in the applicable chargingRateUnit, for + * example in Amperes (A) or Watts (W). Accepts at most one digit fraction (e.g. 8.1). + */ + private Double limit; + + /** + * Charging Schedule Period. Number Phases. Counter + * + *

The number of phases that can be used for charging. If a number of phases is needed, + * numberPhases=3 will be assumed unless another number is given. + */ + @Nullable private Integer numberPhases; + + /** + * Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase + * connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed + * unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, + * the Charging Station / EVSE will make the selection on its own. + */ + @Nullable private Integer phaseToUse; + + /** + * Constructor for the ChargingSchedulePeriod class + * + * @param startPeriod Start of the period, in seconds from the start of schedule. The value of + * StartPeriod also defines the stop time of the previous period. + * @param limit Charging rate limit during the schedule period, in the applicable + * chargingRateUnit, for example in Amperes (A) or Watts (W). Accepts at most one digit + * fraction (e.g. 8.1). + */ + public ChargingSchedulePeriod(Integer startPeriod, Double limit) { + setStartPeriod(startPeriod); + setLimit(limit); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingSchedulePeriod withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets start of the period, in seconds from the start of schedule. The value of StartPeriod also + * defines the stop time of the previous period. + * + * @return Start of the period, in seconds from the start of schedule + */ + public Integer getStartPeriod() { + return startPeriod; + } + + /** + * Sets start of the period, in seconds from the start of schedule. The value of StartPeriod also + * defines the stop time of the previous period. + * + * @param startPeriod Start of the period, in seconds from the start of schedule + */ + public void setStartPeriod(Integer startPeriod) { + if (!isValidStartPeriod(startPeriod)) { + throw new PropertyConstraintException(startPeriod, "startPeriod is invalid"); + } + this.startPeriod = startPeriod; + } + + /** + * Returns whether the given startPeriod is valid + * + * @param startPeriod the startPeriod to check the validity of + * @return {@code true} if startPeriod is valid, {@code false} if not + */ + private boolean isValidStartPeriod(Integer startPeriod) { + return startPeriod != null; + } + + /** + * Gets charging rate limit during the schedule period, in the applicable chargingRateUnit, for + * example in Amperes (A) or Watts (W). Accepts at most one digit fraction (e.g. 8.1). + * + * @return Charging rate limit during the schedule period, in the applicable chargingRateUnit, for + * example in Amperes (A) or Watts (W) + */ + public Double getLimit() { + return limit; + } + + /** + * Sets charging rate limit during the schedule period, in the applicable chargingRateUnit, for + * example in Amperes (A) or Watts (W). Accepts at most one digit fraction (e.g. 8.1). + * + * @param limit Charging rate limit during the schedule period, in the applicable + * chargingRateUnit, for example in Amperes (A) or Watts (W) + */ + public void setLimit(Double limit) { + if (!isValidLimit(limit)) { + throw new PropertyConstraintException(limit, "limit is invalid"); + } + this.limit = limit; + } + + /** + * Returns whether the given limit is valid + * + * @param limit the limit to check the validity of + * @return {@code true} if limit is valid, {@code false} if not + */ + private boolean isValidLimit(Double limit) { + return limit != null; + } + + /** + * Gets the number of phases that can be used for charging. If a number of phases is needed, + * numberPhases=3 will be assumed unless another number is given. + * + * @return The number of phases that can be used for charging + */ + @Nullable + public Integer getNumberPhases() { + return numberPhases; + } + + /** + * Sets the number of phases that can be used for charging. If a number of phases is needed, + * numberPhases=3 will be assumed unless another number is given. + * + * @param numberPhases The number of phases that can be used for charging + */ + public void setNumberPhases(@Nullable Integer numberPhases) { + this.numberPhases = numberPhases; + } + + /** + * Adds the number of phases that can be used for charging. If a number of phases is needed, + * numberPhases=3 will be assumed unless another number is given. + * + * @param numberPhases The number of phases that can be used for charging + * @return this + */ + public ChargingSchedulePeriod withNumberPhases(@Nullable Integer numberPhases) { + setNumberPhases(numberPhases); + return this; + } + + /** + * Gets values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase + * connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed + * unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, + * the Charging Station / EVSE will make the selection on its own. + * + * @return Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase + * connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true + */ + @Nullable + public Integer getPhaseToUse() { + return phaseToUse; + } + + /** + * Sets values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase + * connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed + * unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, + * the Charging Station / EVSE will make the selection on its own. + * + * @param phaseToUse Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching + * the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true + */ + public void setPhaseToUse(@Nullable Integer phaseToUse) { + this.phaseToUse = phaseToUse; + } + + /** + * Adds values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching the phase + * connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true. It’s not allowed + * unless both conditions above are true. If both conditions are true, and phaseToUse is omitted, + * the Charging Station / EVSE will make the selection on its own. + * + * @param phaseToUse Values: 1..3, Used if numberPhases=1 and if the EVSE is capable of switching + * the phase connected to the EV, i.e. ACPhaseSwitchingSupported is defined and true + * @return this + */ + public ChargingSchedulePeriod withPhaseToUse(@Nullable Integer phaseToUse) { + setPhaseToUse(phaseToUse); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) && isValidStartPeriod(startPeriod) && isValidLimit(limit); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingSchedulePeriod that = (ChargingSchedulePeriod) o; + return Objects.equals(customData, that.customData) + && Objects.equals(startPeriod, that.startPeriod) + && Objects.equals(limit, that.limit) + && Objects.equals(numberPhases, that.numberPhases) + && Objects.equals(phaseToUse, that.phaseToUse); + } + + @Override + public int hashCode() { + return Objects.hash(customData, startPeriod, limit, numberPhases, phaseToUse); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("startPeriod", startPeriod) + .add("limit", limit) + .add("numberPhases", numberPhases) + .add("phaseToUse", phaseToUse) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingStateEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingStateEnum.java new file mode 100644 index 000000000..1ab1aa79e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingStateEnum.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Transaction. State. Transaction State Code + * + *

Current charging state, is required when state has changed. + */ +public enum ChargingStateEnum { + Charging, + EVConnected, + SuspendedEV, + SuspendedEVSE, + Idle +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingStation.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingStation.java new file mode 100644 index 000000000..35af9b62f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ChargingStation.java @@ -0,0 +1,363 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Charge Point + * + *

The physical system where an Electrical Vehicle (EV) can be charged. + */ +public final class ChargingStation { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Device. Serial Number. Serial Number + * + *

Vendor-specific device identifier. + */ + @Nullable private String serialNumber; + + /** + * Device. Model. CI20 Text + * + *

The model of the device. + */ + private String model; + + /** + * Wireless Communication Module + * + *

Parameters required for initiating and maintaining wireless communication with other + * devices. + */ + @Nullable private Modem modem; + + /** The identifier of the vendor (not necessarily in a unique manner). */ + private String vendorName; + + /** The firmware version of the Charging Station. */ + @Nullable private String firmwareVersion; + + /** + * Constructor for the ChargingStation class + * + * @param model The model of the device. + * @param vendorName The identifier of the vendor (not necessarily in a unique manner). + */ + public ChargingStation(String model, String vendorName) { + setModel(model); + setVendorName(vendorName); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ChargingStation withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets vendor-specific device identifier. + * + * @return Vendor-specific device identifier + */ + @Nullable + public String getSerialNumber() { + return serialNumber; + } + + /** + * Sets vendor-specific device identifier. + * + * @param serialNumber Vendor-specific device identifier + */ + public void setSerialNumber(@Nullable String serialNumber) { + if (!isValidSerialNumber(serialNumber)) { + throw new PropertyConstraintException(serialNumber, "serialNumber is invalid"); + } + this.serialNumber = serialNumber; + } + + /** + * Returns whether the given serialNumber is valid + * + * @param serialNumber the serialNumber to check the validity of + * @return {@code true} if serialNumber is valid, {@code false} if not + */ + private boolean isValidSerialNumber(@Nullable String serialNumber) { + return serialNumber == null || serialNumber.length() <= 25; + } + + /** + * Adds vendor-specific device identifier. + * + * @param serialNumber Vendor-specific device identifier + * @return this + */ + public ChargingStation withSerialNumber(@Nullable String serialNumber) { + setSerialNumber(serialNumber); + return this; + } + + /** + * Gets the model of the device. + * + * @return The model of the device + */ + public String getModel() { + return model; + } + + /** + * Sets the model of the device. + * + * @param model The model of the device + */ + public void setModel(String model) { + if (!isValidModel(model)) { + throw new PropertyConstraintException(model, "model is invalid"); + } + this.model = model; + } + + /** + * Returns whether the given model is valid + * + * @param model the model to check the validity of + * @return {@code true} if model is valid, {@code false} if not + */ + private boolean isValidModel(String model) { + return model != null && model.length() <= 20; + } + + /** + * Gets parameters required for initiating and maintaining wireless communication with other + * devices. + * + * @return Parameters required for initiating and maintaining wireless communication with other + * devices + */ + @Nullable + public Modem getModem() { + return modem; + } + + /** + * Sets parameters required for initiating and maintaining wireless communication with other + * devices. + * + * @param modem Parameters required for initiating and maintaining wireless communication with + * other devices + */ + public void setModem(@Nullable Modem modem) { + if (!isValidModem(modem)) { + throw new PropertyConstraintException(modem, "modem is invalid"); + } + this.modem = modem; + } + + /** + * Returns whether the given modem is valid + * + * @param modem the modem to check the validity of + * @return {@code true} if modem is valid, {@code false} if not + */ + private boolean isValidModem(@Nullable Modem modem) { + return modem == null || modem.validate(); + } + + /** + * Adds parameters required for initiating and maintaining wireless communication with other + * devices. + * + * @param modem Parameters required for initiating and maintaining wireless communication with + * other devices + * @return this + */ + public ChargingStation withModem(@Nullable Modem modem) { + setModem(modem); + return this; + } + + /** + * Gets the identifier of the vendor (not necessarily in a unique manner). + * + * @return The identifier of the vendor (not necessarily in a unique manner) + */ + public String getVendorName() { + return vendorName; + } + + /** + * Sets the identifier of the vendor (not necessarily in a unique manner). + * + * @param vendorName The identifier of the vendor (not necessarily in a unique manner) + */ + public void setVendorName(String vendorName) { + if (!isValidVendorName(vendorName)) { + throw new PropertyConstraintException(vendorName, "vendorName is invalid"); + } + this.vendorName = vendorName; + } + + /** + * Returns whether the given vendorName is valid + * + * @param vendorName the vendorName to check the validity of + * @return {@code true} if vendorName is valid, {@code false} if not + */ + private boolean isValidVendorName(String vendorName) { + return vendorName != null && vendorName.length() <= 50; + } + + /** + * Gets the firmware version of the Charging Station. + * + * @return The firmware version of the Charging Station + */ + @Nullable + public String getFirmwareVersion() { + return firmwareVersion; + } + + /** + * Sets the firmware version of the Charging Station. + * + * @param firmwareVersion The firmware version of the Charging Station + */ + public void setFirmwareVersion(@Nullable String firmwareVersion) { + if (!isValidFirmwareVersion(firmwareVersion)) { + throw new PropertyConstraintException(firmwareVersion, "firmwareVersion is invalid"); + } + this.firmwareVersion = firmwareVersion; + } + + /** + * Returns whether the given firmwareVersion is valid + * + * @param firmwareVersion the firmwareVersion to check the validity of + * @return {@code true} if firmwareVersion is valid, {@code false} if not + */ + private boolean isValidFirmwareVersion(@Nullable String firmwareVersion) { + return firmwareVersion == null || firmwareVersion.length() <= 50; + } + + /** + * Adds the firmware version of the Charging Station. + * + * @param firmwareVersion The firmware version of the Charging Station + * @return this + */ + public ChargingStation withFirmwareVersion(@Nullable String firmwareVersion) { + setFirmwareVersion(firmwareVersion); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidSerialNumber(serialNumber) + && isValidModel(model) + && isValidModem(modem) + && isValidVendorName(vendorName) + && isValidFirmwareVersion(firmwareVersion); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChargingStation that = (ChargingStation) o; + return Objects.equals(customData, that.customData) + && Objects.equals(serialNumber, that.serialNumber) + && Objects.equals(model, that.model) + && Objects.equals(modem, that.modem) + && Objects.equals(vendorName, that.vendorName) + && Objects.equals(firmwareVersion, that.firmwareVersion); + } + + @Override + public int hashCode() { + return Objects.hash(customData, serialNumber, model, modem, vendorName, firmwareVersion); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("serialNumber", serialNumber) + .add("model", model) + .add("modem", modem) + .add("vendorName", vendorName) + .add("firmwareVersion", firmwareVersion) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearCacheStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearCacheStatusEnum.java new file mode 100644 index 000000000..6bd03656e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearCacheStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Accepted if the Charging Station has executed the request, otherwise rejected. */ +public enum ClearCacheStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearChargingProfile.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearChargingProfile.java new file mode 100644 index 000000000..8a68c8d6e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearChargingProfile.java @@ -0,0 +1,261 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Charging Profile + * + *

A ChargingProfile consists of a ChargingSchedule, describing the amount of power or current + * that can be delivered per time interval. + */ +public final class ClearChargingProfile { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Identified Object. MRID. Numeric Identifier + * + *

Specifies the id of the EVSE for which to clear charging profiles. An evseId of zero (0) + * specifies the charging profile for the overall Charging Station. Absence of this parameter + * means the clearing applies to all charging profiles that match the other criteria in the + * request. + */ + @Nullable private Integer evseId; + + /** + * Charging Profile. Charging Profile Purpose. Charging Profile Purpose Code + * + *

Specifies to purpose of the charging profiles that will be cleared, if they meet the other + * criteria in the request. + */ + @Nullable private ChargingProfilePurposeEnum chargingProfilePurpose; + + /** + * Charging Profile. Stack Level. Counter + * + *

Specifies the stackLevel for which charging profiles will be cleared, if they meet the other + * criteria in the request. + */ + @Nullable private Integer stackLevel; + + /** Constructor for the ClearChargingProfile class */ + public ClearChargingProfile() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearChargingProfile withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets specifies the id of the EVSE for which to clear charging profiles. An evseId of zero (0) + * specifies the charging profile for the overall Charging Station. Absence of this parameter + * means the clearing applies to all charging profiles that match the other criteria in the + * request. + * + * @return Specifies the id of the EVSE for which to clear charging profiles + */ + @Nullable + public Integer getEvseId() { + return evseId; + } + + /** + * Sets specifies the id of the EVSE for which to clear charging profiles. An evseId of zero (0) + * specifies the charging profile for the overall Charging Station. Absence of this parameter + * means the clearing applies to all charging profiles that match the other criteria in the + * request. + * + * @param evseId Specifies the id of the EVSE for which to clear charging profiles + */ + public void setEvseId(@Nullable Integer evseId) { + this.evseId = evseId; + } + + /** + * Adds specifies the id of the EVSE for which to clear charging profiles. An evseId of zero (0) + * specifies the charging profile for the overall Charging Station. Absence of this parameter + * means the clearing applies to all charging profiles that match the other criteria in the + * request. + * + * @param evseId Specifies the id of the EVSE for which to clear charging profiles + * @return this + */ + public ClearChargingProfile withEvseId(@Nullable Integer evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets specifies to purpose of the charging profiles that will be cleared, if they meet the other + * criteria in the request. + * + * @return Specifies to purpose of the charging profiles that will be cleared, if they meet the + * other criteria in the request + */ + @Nullable + public ChargingProfilePurposeEnum getChargingProfilePurpose() { + return chargingProfilePurpose; + } + + /** + * Sets specifies to purpose of the charging profiles that will be cleared, if they meet the other + * criteria in the request. + * + * @param chargingProfilePurpose Specifies to purpose of the charging profiles that will be + * cleared, if they meet the other criteria in the request + */ + public void setChargingProfilePurpose( + @Nullable ChargingProfilePurposeEnum chargingProfilePurpose) { + this.chargingProfilePurpose = chargingProfilePurpose; + } + + /** + * Adds specifies to purpose of the charging profiles that will be cleared, if they meet the other + * criteria in the request. + * + * @param chargingProfilePurpose Specifies to purpose of the charging profiles that will be + * cleared, if they meet the other criteria in the request + * @return this + */ + public ClearChargingProfile withChargingProfilePurpose( + @Nullable ChargingProfilePurposeEnum chargingProfilePurpose) { + setChargingProfilePurpose(chargingProfilePurpose); + return this; + } + + /** + * Gets specifies the stackLevel for which charging profiles will be cleared, if they meet the + * other criteria in the request. + * + * @return Specifies the stackLevel for which charging profiles will be cleared, if they meet the + * other criteria in the request + */ + @Nullable + public Integer getStackLevel() { + return stackLevel; + } + + /** + * Sets specifies the stackLevel for which charging profiles will be cleared, if they meet the + * other criteria in the request. + * + * @param stackLevel Specifies the stackLevel for which charging profiles will be cleared, if they + * meet the other criteria in the request + */ + public void setStackLevel(@Nullable Integer stackLevel) { + this.stackLevel = stackLevel; + } + + /** + * Adds specifies the stackLevel for which charging profiles will be cleared, if they meet the + * other criteria in the request. + * + * @param stackLevel Specifies the stackLevel for which charging profiles will be cleared, if they + * meet the other criteria in the request + * @return this + */ + public ClearChargingProfile withStackLevel(@Nullable Integer stackLevel) { + setStackLevel(stackLevel); + return this; + } + + public boolean validate() { + return isValidCustomData(customData); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearChargingProfile that = (ClearChargingProfile) o; + return Objects.equals(customData, that.customData) + && Objects.equals(evseId, that.evseId) + && Objects.equals(chargingProfilePurpose, that.chargingProfilePurpose) + && Objects.equals(stackLevel, that.stackLevel); + } + + @Override + public int hashCode() { + return Objects.hash(customData, evseId, chargingProfilePurpose, stackLevel); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("evseId", evseId) + .add("chargingProfilePurpose", chargingProfilePurpose) + .add("stackLevel", stackLevel) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearChargingProfileStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearChargingProfileStatusEnum.java new file mode 100644 index 000000000..2ac6334a1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearChargingProfileStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the Charging Station was able to execute the request. */ +public enum ClearChargingProfileStatusEnum { + Accepted, + Unknown +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearMessageStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearMessageStatusEnum.java new file mode 100644 index 000000000..f8c7fc103 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearMessageStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Returns whether the Charging Station has been able to remove the message. */ +public enum ClearMessageStatusEnum { + Accepted, + Unknown +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearMonitoringResult.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearMonitoringResult.java new file mode 100644 index 000000000..ba7362232 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearMonitoringResult.java @@ -0,0 +1,242 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** ClearMonitoringResultType */ +public final class ClearMonitoringResult { + /** Custom data */ + @Nullable private CustomData customData; + + /** Result of the clear request for this monitor, identified by its Id. */ + private ClearMonitoringStatusEnum status; + + /** Id of the monitor of which a clear was requested. */ + private Integer id; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Constructor for the ClearMonitoringResult class + * + * @param status Result of the clear request for this monitor, identified by its Id. + * @param id Id of the monitor of which a clear was requested. + */ + public ClearMonitoringResult(ClearMonitoringStatusEnum status, Integer id) { + setStatus(status); + setId(id); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ClearMonitoringResult withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets result of the clear request for this monitor, identified by its Id. + * + * @return Result of the clear request for this monitor, identified by its Id + */ + public ClearMonitoringStatusEnum getStatus() { + return status; + } + + /** + * Sets result of the clear request for this monitor, identified by its Id. + * + * @param status Result of the clear request for this monitor, identified by its Id + */ + public void setStatus(ClearMonitoringStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(ClearMonitoringStatusEnum status) { + return status != null; + } + + /** + * Gets id of the monitor of which a clear was requested. + * + * @return Id of the monitor of which a clear was requested + */ + public Integer getId() { + return id; + } + + /** + * Sets id of the monitor of which a clear was requested. + * + * @param id Id of the monitor of which a clear was requested + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public ClearMonitoringResult withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidStatus(status) + && isValidId(id) + && isValidStatusInfo(statusInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearMonitoringResult that = (ClearMonitoringResult) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(id, that.id) + && Objects.equals(statusInfo, that.statusInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, status, id, statusInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("id", id) + .add("statusInfo", statusInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearMonitoringStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearMonitoringStatusEnum.java new file mode 100644 index 000000000..bf36f9011 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ClearMonitoringStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Result of the clear request for this monitor, identified by its Id. */ +public enum ClearMonitoringStatusEnum { + Accepted, + Rejected, + NotFound +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Component.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Component.java new file mode 100644 index 000000000..6e2cfa3b8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Component.java @@ -0,0 +1,268 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A physical or logical component */ +public final class Component { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * EVSE + * + *

Electric Vehicle Supply Equipment + */ + @Nullable private EVSE evse; + + /** + * Name of the component. Name should be taken from the list of standardized component names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + */ + private String name; + + /** + * Name of instance in case the component exists as multiple instances. Case Insensitive. strongly + * advised to use Camel Case. + */ + @Nullable private String instance; + + /** + * Constructor for the Component class + * + * @param name Name of the component. Name should be taken from the list of standardized component + * names whenever possible. Case Insensitive. strongly advised to use Camel Case. + */ + public Component(String name) { + setName(name); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Component withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets electric Vehicle Supply Equipment + * + * @return Electric Vehicle Supply Equipment + */ + @Nullable + public EVSE getEvse() { + return evse; + } + + /** + * Sets electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + */ + public void setEvse(@Nullable EVSE evse) { + if (!isValidEvse(evse)) { + throw new PropertyConstraintException(evse, "evse is invalid"); + } + this.evse = evse; + } + + /** + * Returns whether the given evse is valid + * + * @param evse the evse to check the validity of + * @return {@code true} if evse is valid, {@code false} if not + */ + private boolean isValidEvse(@Nullable EVSE evse) { + return evse == null || evse.validate(); + } + + /** + * Adds electric Vehicle Supply Equipment + * + * @param evse Electric Vehicle Supply Equipment + * @return this + */ + public Component withEvse(@Nullable EVSE evse) { + setEvse(evse); + return this; + } + + /** + * Gets name of the component. Name should be taken from the list of standardized component names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + * + * @return Name of the component + */ + public String getName() { + return name; + } + + /** + * Sets name of the component. Name should be taken from the list of standardized component names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + * + * @param name Name of the component + */ + public void setName(String name) { + if (!isValidName(name)) { + throw new PropertyConstraintException(name, "name is invalid"); + } + this.name = name; + } + + /** + * Returns whether the given name is valid + * + * @param name the name to check the validity of + * @return {@code true} if name is valid, {@code false} if not + */ + private boolean isValidName(String name) { + return name != null && name.length() <= 50; + } + + /** + * Gets name of instance in case the component exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @return Name of instance in case the component exists as multiple instances + */ + @Nullable + public String getInstance() { + return instance; + } + + /** + * Sets name of instance in case the component exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @param instance Name of instance in case the component exists as multiple instances + */ + public void setInstance(@Nullable String instance) { + if (!isValidInstance(instance)) { + throw new PropertyConstraintException(instance, "instance is invalid"); + } + this.instance = instance; + } + + /** + * Returns whether the given instance is valid + * + * @param instance the instance to check the validity of + * @return {@code true} if instance is valid, {@code false} if not + */ + private boolean isValidInstance(@Nullable String instance) { + return instance == null || instance.length() <= 50; + } + + /** + * Adds name of instance in case the component exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @param instance Name of instance in case the component exists as multiple instances + * @return this + */ + public Component withInstance(@Nullable String instance) { + setInstance(instance); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidEvse(evse) + && isValidName(name) + && isValidInstance(instance); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Component that = (Component) o; + return Objects.equals(customData, that.customData) + && Objects.equals(evse, that.evse) + && Objects.equals(name, that.name) + && Objects.equals(instance, that.instance); + } + + @Override + public int hashCode() { + return Objects.hash(customData, evse, name, instance); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("evse", evse) + .add("name", name) + .add("instance", instance) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ComponentCriterionEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ComponentCriterionEnum.java new file mode 100644 index 000000000..acbcc9016 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ComponentCriterionEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** ComponentCriterionEnumType */ +public enum ComponentCriterionEnum { + Active, + Available, + Enabled, + Problem +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ComponentVariable.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ComponentVariable.java new file mode 100644 index 000000000..191465536 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ComponentVariable.java @@ -0,0 +1,203 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to report components, variables and variable attributes and characteristics. */ +public final class ComponentVariable { + /** Custom data */ + @Nullable private CustomData customData; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + @Nullable private Variable variable; + + /** + * Constructor for the ComponentVariable class + * + * @param component A physical or logical component + */ + public ComponentVariable(Component component) { + setComponent(component); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ComponentVariable withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + @Nullable + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(@Nullable Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(@Nullable Variable variable) { + return variable == null || variable.validate(); + } + + /** + * Adds reference key to a component-variable. + * + * @param variable Reference key to a component-variable + * @return this + */ + public ComponentVariable withVariable(@Nullable Variable variable) { + setVariable(variable); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidComponent(component) + && isValidVariable(variable); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ComponentVariable that = (ComponentVariable) o; + return Objects.equals(customData, that.customData) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable); + } + + @Override + public int hashCode() { + return Objects.hash(customData, component, variable); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("component", component) + .add("variable", variable) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CompositeSchedule.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CompositeSchedule.java new file mode 100644 index 000000000..74305075b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CompositeSchedule.java @@ -0,0 +1,346 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Composite Schedule */ +public final class CompositeSchedule { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Charging Schedule Period + * + *

Charging schedule period structure defines a time period in a charging schedule. + */ + private ChargingSchedulePeriod[] chargingSchedulePeriod; + + /** + * The ID of the EVSE for which the schedule is requested. When evseid=0, the Charging Station + * calculated the expected consumption for the grid connection. + */ + private Integer evseId; + + /** Duration of the schedule in seconds. */ + private Integer duration; + + /** + * Composite Schedule. Start. Date Time + * + *

Date and time at which the schedule becomes active. All time measurements within the + * schedule are relative to this timestamp. + */ + private ZonedDateTime scheduleStart; + + /** The unit of measure Limit is expressed in. */ + private ChargingRateUnitEnum chargingRateUnit; + + /** + * Constructor for the CompositeSchedule class + * + * @param chargingSchedulePeriod Charging schedule period structure defines a time period in a + * charging schedule. + * @param evseId The ID of the EVSE for which the schedule is requested. When evseid=0, the + * Charging Station calculated the expected consumption for the grid connection. + * @param duration Duration of the schedule in seconds. + * @param scheduleStart Date and time at which the schedule becomes active. All time measurements + * within the schedule are relative to this timestamp. + * @param chargingRateUnit The unit of measure Limit is expressed in. + */ + public CompositeSchedule( + ChargingSchedulePeriod[] chargingSchedulePeriod, + Integer evseId, + Integer duration, + ZonedDateTime scheduleStart, + ChargingRateUnitEnum chargingRateUnit) { + setChargingSchedulePeriod(chargingSchedulePeriod); + setEvseId(evseId); + setDuration(duration); + setScheduleStart(scheduleStart); + setChargingRateUnit(chargingRateUnit); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public CompositeSchedule withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets charging schedule period structure defines a time period in a charging schedule. + * + * @return Charging schedule period structure defines a time period in a charging schedule + */ + public ChargingSchedulePeriod[] getChargingSchedulePeriod() { + return chargingSchedulePeriod; + } + + /** + * Sets charging schedule period structure defines a time period in a charging schedule. + * + * @param chargingSchedulePeriod Charging schedule period structure defines a time period in a + * charging schedule + */ + public void setChargingSchedulePeriod(ChargingSchedulePeriod[] chargingSchedulePeriod) { + if (!isValidChargingSchedulePeriod(chargingSchedulePeriod)) { + throw new PropertyConstraintException( + chargingSchedulePeriod, "chargingSchedulePeriod is invalid"); + } + this.chargingSchedulePeriod = chargingSchedulePeriod; + } + + /** + * Returns whether the given chargingSchedulePeriod is valid + * + * @param chargingSchedulePeriod the chargingSchedulePeriod to check the validity of + * @return {@code true} if chargingSchedulePeriod is valid, {@code false} if not + */ + private boolean isValidChargingSchedulePeriod(ChargingSchedulePeriod[] chargingSchedulePeriod) { + return chargingSchedulePeriod != null + && chargingSchedulePeriod.length >= 1 + && Arrays.stream(chargingSchedulePeriod).allMatch(item -> item.validate()); + } + + /** + * Gets the ID of the EVSE for which the schedule is requested. When evseid=0, the Charging + * Station calculated the expected consumption for the grid connection. + * + * @return The ID of the EVSE for which the schedule is requested + */ + public Integer getEvseId() { + return evseId; + } + + /** + * Sets the ID of the EVSE for which the schedule is requested. When evseid=0, the Charging + * Station calculated the expected consumption for the grid connection. + * + * @param evseId The ID of the EVSE for which the schedule is requested + */ + public void setEvseId(Integer evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(Integer evseId) { + return evseId != null; + } + + /** + * Gets duration of the schedule in seconds. + * + * @return Duration of the schedule in seconds + */ + public Integer getDuration() { + return duration; + } + + /** + * Sets duration of the schedule in seconds. + * + * @param duration Duration of the schedule in seconds + */ + public void setDuration(Integer duration) { + if (!isValidDuration(duration)) { + throw new PropertyConstraintException(duration, "duration is invalid"); + } + this.duration = duration; + } + + /** + * Returns whether the given duration is valid + * + * @param duration the duration to check the validity of + * @return {@code true} if duration is valid, {@code false} if not + */ + private boolean isValidDuration(Integer duration) { + return duration != null; + } + + /** + * Gets date and time at which the schedule becomes active. All time measurements within the + * schedule are relative to this timestamp. + * + * @return Date and time at which the schedule becomes active + */ + public ZonedDateTime getScheduleStart() { + return scheduleStart; + } + + /** + * Sets date and time at which the schedule becomes active. All time measurements within the + * schedule are relative to this timestamp. + * + * @param scheduleStart Date and time at which the schedule becomes active + */ + public void setScheduleStart(ZonedDateTime scheduleStart) { + if (!isValidScheduleStart(scheduleStart)) { + throw new PropertyConstraintException(scheduleStart, "scheduleStart is invalid"); + } + this.scheduleStart = scheduleStart; + } + + /** + * Returns whether the given scheduleStart is valid + * + * @param scheduleStart the scheduleStart to check the validity of + * @return {@code true} if scheduleStart is valid, {@code false} if not + */ + private boolean isValidScheduleStart(ZonedDateTime scheduleStart) { + return scheduleStart != null; + } + + /** + * Gets the unit of measure Limit is expressed in. + * + * @return The unit of measure Limit is expressed in + */ + public ChargingRateUnitEnum getChargingRateUnit() { + return chargingRateUnit; + } + + /** + * Sets the unit of measure Limit is expressed in. + * + * @param chargingRateUnit The unit of measure Limit is expressed in + */ + public void setChargingRateUnit(ChargingRateUnitEnum chargingRateUnit) { + if (!isValidChargingRateUnit(chargingRateUnit)) { + throw new PropertyConstraintException(chargingRateUnit, "chargingRateUnit is invalid"); + } + this.chargingRateUnit = chargingRateUnit; + } + + /** + * Returns whether the given chargingRateUnit is valid + * + * @param chargingRateUnit the chargingRateUnit to check the validity of + * @return {@code true} if chargingRateUnit is valid, {@code false} if not + */ + private boolean isValidChargingRateUnit(ChargingRateUnitEnum chargingRateUnit) { + return chargingRateUnit != null; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidChargingSchedulePeriod(chargingSchedulePeriod) + && isValidEvseId(evseId) + && isValidDuration(duration) + && isValidScheduleStart(scheduleStart) + && isValidChargingRateUnit(chargingRateUnit); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CompositeSchedule that = (CompositeSchedule) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(chargingSchedulePeriod, that.chargingSchedulePeriod) + && Objects.equals(evseId, that.evseId) + && Objects.equals(duration, that.duration) + && Objects.equals(scheduleStart, that.scheduleStart) + && Objects.equals(chargingRateUnit, that.chargingRateUnit); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + Arrays.hashCode(chargingSchedulePeriod), + evseId, + duration, + scheduleStart, + chargingRateUnit); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("chargingSchedulePeriod", chargingSchedulePeriod) + .add("evseId", evseId) + .add("duration", duration) + .add("scheduleStart", scheduleStart) + .add("chargingRateUnit", chargingRateUnit) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ConnectorEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ConnectorEnum.java new file mode 100644 index 000000000..b89909f3d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ConnectorEnum.java @@ -0,0 +1,58 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import com.google.gson.annotations.SerializedName; + +/** The connector type. */ +public enum ConnectorEnum { + cCCS1, + cCCS2, + cG105, + cTesla, + cType1, + cType2, + @SerializedName("s309-1P-16A") + s309_1P_16A, + @SerializedName("s309-1P-32A") + s309_1P_32A, + @SerializedName("s309-3P-16A") + s309_3P_16A, + @SerializedName("s309-3P-32A") + s309_3P_32A, + sBS1361, + @SerializedName("sCEE-7-7") + sCEE_7_7, + sType2, + sType3, + Other1PhMax16A, + Other1PhOver16A, + Other3Ph, + Pan, + wInductive, + wResonant, + Undetermined, + Unknown +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ConnectorStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ConnectorStatusEnum.java new file mode 100644 index 000000000..147e77fac --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ConnectorStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The current status of the Connector. */ +public enum ConnectorStatusEnum { + Available, + Occupied, + Reserved, + Unavailable, + Faulted +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ConsumptionCost.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ConsumptionCost.java new file mode 100644 index 000000000..800a26107 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ConsumptionCost.java @@ -0,0 +1,205 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Consumption Cost */ +public final class ConsumptionCost { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Consumption Cost. Start Value. Numeric + * + *

The lowest level of consumption that defines the starting point of this consumption block. + * The block interval extends to the start of the next interval. + */ + private Double startValue; + + /** Cost */ + private Cost[] cost; + + /** + * Constructor for the ConsumptionCost class + * + * @param startValue The lowest level of consumption that defines the starting point of this + * consumption block. The block interval extends to the start of the next interval. + * @param cost Cost + */ + public ConsumptionCost(Double startValue, Cost[] cost) { + setStartValue(startValue); + setCost(cost); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ConsumptionCost withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the lowest level of consumption that defines the starting point of this consumption block. + * The block interval extends to the start of the next interval. + * + * @return The lowest level of consumption that defines the starting point of this consumption + * block + */ + public Double getStartValue() { + return startValue; + } + + /** + * Sets the lowest level of consumption that defines the starting point of this consumption block. + * The block interval extends to the start of the next interval. + * + * @param startValue The lowest level of consumption that defines the starting point of this + * consumption block + */ + public void setStartValue(Double startValue) { + if (!isValidStartValue(startValue)) { + throw new PropertyConstraintException(startValue, "startValue is invalid"); + } + this.startValue = startValue; + } + + /** + * Returns whether the given startValue is valid + * + * @param startValue the startValue to check the validity of + * @return {@code true} if startValue is valid, {@code false} if not + */ + private boolean isValidStartValue(Double startValue) { + return startValue != null; + } + + /** + * Gets cost + * + * @return Cost + */ + public Cost[] getCost() { + return cost; + } + + /** + * Sets cost + * + * @param cost Cost + */ + public void setCost(Cost[] cost) { + if (!isValidCost(cost)) { + throw new PropertyConstraintException(cost, "cost is invalid"); + } + this.cost = cost; + } + + /** + * Returns whether the given cost is valid + * + * @param cost the cost to check the validity of + * @return {@code true} if cost is valid, {@code false} if not + */ + private boolean isValidCost(Cost[] cost) { + return cost != null + && cost.length >= 1 + && cost.length <= 3 + && Arrays.stream(cost).allMatch(item -> item.validate()); + } + + public boolean validate() { + return isValidCustomData(customData) && isValidStartValue(startValue) && isValidCost(cost); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConsumptionCost that = (ConsumptionCost) o; + return Objects.equals(customData, that.customData) + && Objects.equals(startValue, that.startValue) + && Arrays.equals(cost, that.cost); + } + + @Override + public int hashCode() { + return Objects.hash(customData, startValue, Arrays.hashCode(cost)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("startValue", startValue) + .add("cost", cost) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Cost.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Cost.java new file mode 100644 index 000000000..629459973 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Cost.java @@ -0,0 +1,244 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Cost */ +public final class Cost { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Cost. Cost Kind. Cost Kind Code + * + *

The kind of cost referred to in the message element amount + */ + private CostKindEnum costKind; + + /** + * Cost. Amount. Amount + * + *

The estimated or actual cost per kWh + */ + private Integer amount; + + /** + * Cost. Amount Multiplier. Integer + * + *

Values: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value + * is determined by: amount * 10 ^ amountMultiplier + */ + @Nullable private Integer amountMultiplier; + + /** + * Constructor for the Cost class + * + * @param costKind The kind of cost referred to in the message element amount + * @param amount The estimated or actual cost per kWh + */ + public Cost(CostKindEnum costKind, Integer amount) { + setCostKind(costKind); + setAmount(amount); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Cost withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the kind of cost referred to in the message element amount + * + * @return The kind of cost referred to in the message element amount + */ + public CostKindEnum getCostKind() { + return costKind; + } + + /** + * Sets the kind of cost referred to in the message element amount + * + * @param costKind The kind of cost referred to in the message element amount + */ + public void setCostKind(CostKindEnum costKind) { + if (!isValidCostKind(costKind)) { + throw new PropertyConstraintException(costKind, "costKind is invalid"); + } + this.costKind = costKind; + } + + /** + * Returns whether the given costKind is valid + * + * @param costKind the costKind to check the validity of + * @return {@code true} if costKind is valid, {@code false} if not + */ + private boolean isValidCostKind(CostKindEnum costKind) { + return costKind != null; + } + + /** + * Gets the estimated or actual cost per kWh + * + * @return The estimated or actual cost per kWh + */ + public Integer getAmount() { + return amount; + } + + /** + * Sets the estimated or actual cost per kWh + * + * @param amount The estimated or actual cost per kWh + */ + public void setAmount(Integer amount) { + if (!isValidAmount(amount)) { + throw new PropertyConstraintException(amount, "amount is invalid"); + } + this.amount = amount; + } + + /** + * Returns whether the given amount is valid + * + * @param amount the amount to check the validity of + * @return {@code true} if amount is valid, {@code false} if not + */ + private boolean isValidAmount(Integer amount) { + return amount != null; + } + + /** + * Gets values: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value + * is determined by: amount * 10 ^ amountMultiplier + * + * @return Values: -3..3, The amountMultiplier defines the exponent to base 10 (dec) + */ + @Nullable + public Integer getAmountMultiplier() { + return amountMultiplier; + } + + /** + * Sets values: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value + * is determined by: amount * 10 ^ amountMultiplier + * + * @param amountMultiplier Values: -3..3, The amountMultiplier defines the exponent to base 10 + * (dec) + */ + public void setAmountMultiplier(@Nullable Integer amountMultiplier) { + this.amountMultiplier = amountMultiplier; + } + + /** + * Adds values: -3..3, The amountMultiplier defines the exponent to base 10 (dec). The final value + * is determined by: amount * 10 ^ amountMultiplier + * + * @param amountMultiplier Values: -3..3, The amountMultiplier defines the exponent to base 10 + * (dec) + * @return this + */ + public Cost withAmountMultiplier(@Nullable Integer amountMultiplier) { + setAmountMultiplier(amountMultiplier); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) && isValidCostKind(costKind) && isValidAmount(amount); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cost that = (Cost) o; + return Objects.equals(customData, that.customData) + && Objects.equals(costKind, that.costKind) + && Objects.equals(amount, that.amount) + && Objects.equals(amountMultiplier, that.amountMultiplier); + } + + @Override + public int hashCode() { + return Objects.hash(customData, costKind, amount, amountMultiplier); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("costKind", costKind) + .add("amount", amount) + .add("amountMultiplier", amountMultiplier) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CostKindEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CostKindEnum.java new file mode 100644 index 000000000..c85179622 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CostKindEnum.java @@ -0,0 +1,36 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Cost. Cost Kind. Cost Kind Code + * + *

The kind of cost referred to in the message element amount + */ +public enum CostKindEnum { + CarbonDioxideEmission, + RelativePricePercentage, + RenewableGenerationPercentage +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CustomData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CustomData.java new file mode 100644 index 000000000..c50b3a42d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CustomData.java @@ -0,0 +1,104 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; + +/** Custom data */ +public class CustomData { + /** vendorId */ + private String vendorId; + + /** + * Constructor for the CustomData class + * + * @param vendorId vendorId + */ + public CustomData(String vendorId) { + setVendorId(vendorId); + } + + /** + * Gets vendorId + * + * @return vendorId + */ + public String getVendorId() { + return vendorId; + } + + /** + * Sets vendorId + * + * @param vendorId vendorId + */ + public void setVendorId(String vendorId) { + if (!isValidVendorId(vendorId)) { + throw new PropertyConstraintException(vendorId, "vendorId is invalid"); + } + this.vendorId = vendorId; + } + + /** + * Returns whether the given vendorId is valid + * + * @param vendorId the vendorId to check the validity of + * @return {@code true} if vendorId is valid, {@code false} if not + */ + private boolean isValidVendorId(String vendorId) { + return vendorId != null && vendorId.length() <= 255; + } + + public boolean validate() { + return isValidVendorId(vendorId); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CustomData that = (CustomData) o; + return Objects.equals(vendorId, that.vendorId); + } + + @Override + public int hashCode() { + return Objects.hash(vendorId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("vendorId", vendorId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CustomerInformationStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CustomerInformationStatusEnum.java new file mode 100644 index 000000000..005fa21c8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/CustomerInformationStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the request was accepted. */ +public enum CustomerInformationStatusEnum { + Accepted, + Rejected, + Invalid +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DCChargingParameters.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DCChargingParameters.java new file mode 100644 index 000000000..11f11eb90 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DCChargingParameters.java @@ -0,0 +1,499 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * DC Charging Parameters + * + *

EV DC charging parameters + */ +public final class DCChargingParameters { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * DC Charging Parameters. EV Max. Current + * + *

Maximum current (amps) supported by the electric vehicle. Includes cable capacity. + */ + private Integer evMaxCurrent; + + /** + * DC Charging Parameters. EV Max. Voltage + * + *

Maximum voltage supported by the electric vehicle + */ + private Integer evMaxVoltage; + + /** + * DC Charging Parameters. Energy Amount. Energy Amount + * + *

Amount of energy requested (in Wh). This inludes energy required for preconditioning. + */ + @Nullable private Integer energyAmount; + + /** + * DC Charging Parameters. EV Max. Power + * + *

Maximum power (in W) supported by the electric vehicle. Required for DC charging. + */ + @Nullable private Integer evMaxPower; + + /** + * DC Charging Parameters. State Of Charge. Numeric + * + *

Energy available in the battery (in percent of the battery capacity) + */ + @Nullable private Integer stateOfCharge; + + /** + * DC Charging Parameters. EV Energy Capacity. Numeric + * + *

Capacity of the electric vehicle battery (in Wh) + */ + @Nullable private Integer evEnergyCapacity; + + /** + * DC Charging Parameters. Full SOC. Percentage + * + *

Percentage of SoC at which the EV considers the battery fully charged. (possible values: 0 - + * 100) + */ + @Nullable private Integer fullSoC; + + /** + * DC Charging Parameters. Bulk SOC. Percentage + * + *

Percentage of SoC at which the EV considers a fast charging process to end. (possible + * values: 0 - 100) + */ + @Nullable private Integer bulkSoC; + + /** + * Constructor for the DCChargingParameters class + * + * @param evMaxCurrent Maximum current (amps) supported by the electric vehicle. Includes cable + * capacity. + * @param evMaxVoltage Maximum voltage supported by the electric vehicle + */ + public DCChargingParameters(Integer evMaxCurrent, Integer evMaxVoltage) { + setEvMaxCurrent(evMaxCurrent); + setEvMaxVoltage(evMaxVoltage); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public DCChargingParameters withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets maximum current (amps) supported by the electric vehicle. Includes cable capacity. + * + * @return Maximum current (amps) supported by the electric vehicle + */ + public Integer getEvMaxCurrent() { + return evMaxCurrent; + } + + /** + * Sets maximum current (amps) supported by the electric vehicle. Includes cable capacity. + * + * @param evMaxCurrent Maximum current (amps) supported by the electric vehicle + */ + public void setEvMaxCurrent(Integer evMaxCurrent) { + if (!isValidEvMaxCurrent(evMaxCurrent)) { + throw new PropertyConstraintException(evMaxCurrent, "evMaxCurrent is invalid"); + } + this.evMaxCurrent = evMaxCurrent; + } + + /** + * Returns whether the given evMaxCurrent is valid + * + * @param evMaxCurrent the evMaxCurrent to check the validity of + * @return {@code true} if evMaxCurrent is valid, {@code false} if not + */ + private boolean isValidEvMaxCurrent(Integer evMaxCurrent) { + return evMaxCurrent != null; + } + + /** + * Gets maximum voltage supported by the electric vehicle + * + * @return Maximum voltage supported by the electric vehicle + */ + public Integer getEvMaxVoltage() { + return evMaxVoltage; + } + + /** + * Sets maximum voltage supported by the electric vehicle + * + * @param evMaxVoltage Maximum voltage supported by the electric vehicle + */ + public void setEvMaxVoltage(Integer evMaxVoltage) { + if (!isValidEvMaxVoltage(evMaxVoltage)) { + throw new PropertyConstraintException(evMaxVoltage, "evMaxVoltage is invalid"); + } + this.evMaxVoltage = evMaxVoltage; + } + + /** + * Returns whether the given evMaxVoltage is valid + * + * @param evMaxVoltage the evMaxVoltage to check the validity of + * @return {@code true} if evMaxVoltage is valid, {@code false} if not + */ + private boolean isValidEvMaxVoltage(Integer evMaxVoltage) { + return evMaxVoltage != null; + } + + /** + * Gets amount of energy requested (in Wh). This inludes energy required for preconditioning. + * + * @return Amount of energy requested (in Wh) + */ + @Nullable + public Integer getEnergyAmount() { + return energyAmount; + } + + /** + * Sets amount of energy requested (in Wh). This inludes energy required for preconditioning. + * + * @param energyAmount Amount of energy requested (in Wh) + */ + public void setEnergyAmount(@Nullable Integer energyAmount) { + this.energyAmount = energyAmount; + } + + /** + * Adds amount of energy requested (in Wh). This inludes energy required for preconditioning. + * + * @param energyAmount Amount of energy requested (in Wh) + * @return this + */ + public DCChargingParameters withEnergyAmount(@Nullable Integer energyAmount) { + setEnergyAmount(energyAmount); + return this; + } + + /** + * Gets maximum power (in W) supported by the electric vehicle. Required for DC charging. + * + * @return Maximum power (in W) supported by the electric vehicle + */ + @Nullable + public Integer getEvMaxPower() { + return evMaxPower; + } + + /** + * Sets maximum power (in W) supported by the electric vehicle. Required for DC charging. + * + * @param evMaxPower Maximum power (in W) supported by the electric vehicle + */ + public void setEvMaxPower(@Nullable Integer evMaxPower) { + this.evMaxPower = evMaxPower; + } + + /** + * Adds maximum power (in W) supported by the electric vehicle. Required for DC charging. + * + * @param evMaxPower Maximum power (in W) supported by the electric vehicle + * @return this + */ + public DCChargingParameters withEvMaxPower(@Nullable Integer evMaxPower) { + setEvMaxPower(evMaxPower); + return this; + } + + /** + * Gets energy available in the battery (in percent of the battery capacity) + * + * @return Energy available in the battery (in percent of the battery capacity) + */ + @Nullable + public Integer getStateOfCharge() { + return stateOfCharge; + } + + /** + * Sets energy available in the battery (in percent of the battery capacity) + * + * @param stateOfCharge Energy available in the battery (in percent of the battery capacity) + */ + public void setStateOfCharge(@Nullable Integer stateOfCharge) { + if (!isValidStateOfCharge(stateOfCharge)) { + throw new PropertyConstraintException(stateOfCharge, "stateOfCharge is invalid"); + } + this.stateOfCharge = stateOfCharge; + } + + /** + * Returns whether the given stateOfCharge is valid + * + * @param stateOfCharge the stateOfCharge to check the validity of + * @return {@code true} if stateOfCharge is valid, {@code false} if not + */ + private boolean isValidStateOfCharge(@Nullable Integer stateOfCharge) { + return stateOfCharge == null || (stateOfCharge >= 0 && stateOfCharge <= 100); + } + + /** + * Adds energy available in the battery (in percent of the battery capacity) + * + * @param stateOfCharge Energy available in the battery (in percent of the battery capacity) + * @return this + */ + public DCChargingParameters withStateOfCharge(@Nullable Integer stateOfCharge) { + setStateOfCharge(stateOfCharge); + return this; + } + + /** + * Gets capacity of the electric vehicle battery (in Wh) + * + * @return Capacity of the electric vehicle battery (in Wh) + */ + @Nullable + public Integer getEvEnergyCapacity() { + return evEnergyCapacity; + } + + /** + * Sets capacity of the electric vehicle battery (in Wh) + * + * @param evEnergyCapacity Capacity of the electric vehicle battery (in Wh) + */ + public void setEvEnergyCapacity(@Nullable Integer evEnergyCapacity) { + this.evEnergyCapacity = evEnergyCapacity; + } + + /** + * Adds capacity of the electric vehicle battery (in Wh) + * + * @param evEnergyCapacity Capacity of the electric vehicle battery (in Wh) + * @return this + */ + public DCChargingParameters withEvEnergyCapacity(@Nullable Integer evEnergyCapacity) { + setEvEnergyCapacity(evEnergyCapacity); + return this; + } + + /** + * Gets percentage of SoC at which the EV considers the battery fully charged. (possible values: 0 + * - 100) + * + * @return Percentage of SoC at which the EV considers the battery fully charged + */ + @Nullable + public Integer getFullSoC() { + return fullSoC; + } + + /** + * Sets percentage of SoC at which the EV considers the battery fully charged. (possible values: 0 + * - 100) + * + * @param fullSoC Percentage of SoC at which the EV considers the battery fully charged + */ + public void setFullSoC(@Nullable Integer fullSoC) { + if (!isValidFullSoC(fullSoC)) { + throw new PropertyConstraintException(fullSoC, "fullSoC is invalid"); + } + this.fullSoC = fullSoC; + } + + /** + * Returns whether the given fullSoC is valid + * + * @param fullSoC the fullSoC to check the validity of + * @return {@code true} if fullSoC is valid, {@code false} if not + */ + private boolean isValidFullSoC(@Nullable Integer fullSoC) { + return fullSoC == null || (fullSoC >= 0 && fullSoC <= 100); + } + + /** + * Adds percentage of SoC at which the EV considers the battery fully charged. (possible values: 0 + * - 100) + * + * @param fullSoC Percentage of SoC at which the EV considers the battery fully charged + * @return this + */ + public DCChargingParameters withFullSoC(@Nullable Integer fullSoC) { + setFullSoC(fullSoC); + return this; + } + + /** + * Gets percentage of SoC at which the EV considers a fast charging process to end. (possible + * values: 0 - 100) + * + * @return Percentage of SoC at which the EV considers a fast charging process to end + */ + @Nullable + public Integer getBulkSoC() { + return bulkSoC; + } + + /** + * Sets percentage of SoC at which the EV considers a fast charging process to end. (possible + * values: 0 - 100) + * + * @param bulkSoC Percentage of SoC at which the EV considers a fast charging process to end + */ + public void setBulkSoC(@Nullable Integer bulkSoC) { + if (!isValidBulkSoC(bulkSoC)) { + throw new PropertyConstraintException(bulkSoC, "bulkSoC is invalid"); + } + this.bulkSoC = bulkSoC; + } + + /** + * Returns whether the given bulkSoC is valid + * + * @param bulkSoC the bulkSoC to check the validity of + * @return {@code true} if bulkSoC is valid, {@code false} if not + */ + private boolean isValidBulkSoC(@Nullable Integer bulkSoC) { + return bulkSoC == null || (bulkSoC >= 0 && bulkSoC <= 100); + } + + /** + * Adds percentage of SoC at which the EV considers a fast charging process to end. (possible + * values: 0 - 100) + * + * @param bulkSoC Percentage of SoC at which the EV considers a fast charging process to end + * @return this + */ + public DCChargingParameters withBulkSoC(@Nullable Integer bulkSoC) { + setBulkSoC(bulkSoC); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidEvMaxCurrent(evMaxCurrent) + && isValidEvMaxVoltage(evMaxVoltage) + && isValidStateOfCharge(stateOfCharge) + && isValidFullSoC(fullSoC) + && isValidBulkSoC(bulkSoC); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DCChargingParameters that = (DCChargingParameters) o; + return Objects.equals(customData, that.customData) + && Objects.equals(evMaxCurrent, that.evMaxCurrent) + && Objects.equals(evMaxVoltage, that.evMaxVoltage) + && Objects.equals(energyAmount, that.energyAmount) + && Objects.equals(evMaxPower, that.evMaxPower) + && Objects.equals(stateOfCharge, that.stateOfCharge) + && Objects.equals(evEnergyCapacity, that.evEnergyCapacity) + && Objects.equals(fullSoC, that.fullSoC) + && Objects.equals(bulkSoC, that.bulkSoC); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + evMaxCurrent, + evMaxVoltage, + energyAmount, + evMaxPower, + stateOfCharge, + evEnergyCapacity, + fullSoC, + bulkSoC); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("evMaxCurrent", evMaxCurrent) + .add("evMaxVoltage", evMaxVoltage) + .add("energyAmount", energyAmount) + .add("evMaxPower", evMaxPower) + .add("stateOfCharge", stateOfCharge) + .add("evEnergyCapacity", evEnergyCapacity) + .add("fullSoC", fullSoC) + .add("bulkSoC", bulkSoC) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DataEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DataEnum.java new file mode 100644 index 000000000..2b1b86eaf --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DataEnum.java @@ -0,0 +1,40 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import com.google.gson.annotations.SerializedName; + +/** Data type of this variable. */ +public enum DataEnum { + string, + decimal, + integer, + dateTime, + @SerializedName("boolean") + booleanType, + OptionList, + SequenceList, + MemberList +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DataTransferStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DataTransferStatusEnum.java new file mode 100644 index 000000000..e4f9e0665 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DataTransferStatusEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The success or failure of the data transfer. */ +public enum DataTransferStatusEnum { + Accepted, + Rejected, + UnknownMessageId, + UnknownVendorId +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DeleteCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DeleteCertificateStatusEnum.java new file mode 100644 index 000000000..9be3d8764 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DeleteCertificateStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Charging Station indicates if it can process the request. */ +public enum DeleteCertificateStatusEnum { + Accepted, + Failed, + NotFound +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DisplayMessageStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DisplayMessageStatusEnum.java new file mode 100644 index 000000000..0ab42d237 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/DisplayMessageStatusEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the Charging Station is able to display the message. */ +public enum DisplayMessageStatusEnum { + Accepted, + NotSupportedMessageFormat, + Rejected, + NotSupportedPriority, + NotSupportedState, + UnknownTransaction +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EVSE.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EVSE.java new file mode 100644 index 000000000..2f709ffcc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EVSE.java @@ -0,0 +1,202 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * EVSE + * + *

Electric Vehicle Supply Equipment + */ +public final class EVSE { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Identified Object. MRID. Numeric Identifier + * + *

EVSE Identifier. This contains a number (greater than 0) designating an EVSE of the Charging + * Station. + */ + private Integer id; + + /** An id to designate a specific connector (on an EVSE) by connector index number. */ + @Nullable private Integer connectorId; + + /** + * Constructor for the EVSE class + * + * @param id EVSE Identifier. This contains a number (greater than 0) designating an EVSE of the + * Charging Station. + */ + public EVSE(Integer id) { + setId(id); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EVSE withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets EVSE Identifier. This contains a number (greater than 0) designating an EVSE of the + * Charging Station. + * + * @return EVSE Identifier + */ + public Integer getId() { + return id; + } + + /** + * Sets EVSE Identifier. This contains a number (greater than 0) designating an EVSE of the + * Charging Station. + * + * @param id EVSE Identifier + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null; + } + + /** + * Gets an id to designate a specific connector (on an EVSE) by connector index number. + * + * @return An id to designate a specific connector (on an EVSE) by connector index number + */ + @Nullable + public Integer getConnectorId() { + return connectorId; + } + + /** + * Sets an id to designate a specific connector (on an EVSE) by connector index number. + * + * @param connectorId An id to designate a specific connector (on an EVSE) by connector index + * number + */ + public void setConnectorId(@Nullable Integer connectorId) { + this.connectorId = connectorId; + } + + /** + * Adds an id to designate a specific connector (on an EVSE) by connector index number. + * + * @param connectorId An id to designate a specific connector (on an EVSE) by connector index + * number + * @return this + */ + public EVSE withConnectorId(@Nullable Integer connectorId) { + setConnectorId(connectorId); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) && isValidId(id); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EVSE that = (EVSE) o; + return Objects.equals(customData, that.customData) + && Objects.equals(id, that.id) + && Objects.equals(connectorId, that.connectorId); + } + + @Override + public int hashCode() { + return Objects.hash(customData, id, connectorId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("id", id) + .add("connectorId", connectorId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EnergyTransferModeEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EnergyTransferModeEnum.java new file mode 100644 index 000000000..5c0bedad2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EnergyTransferModeEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Charging Needs. Requested. Energy Transfer Mode Code + * + *

Mode of energy transfer requested by the EV. + */ +public enum EnergyTransferModeEnum { + DC, + AC_single_phase, + AC_two_phase, + AC_three_phase +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EventData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EventData.java new file mode 100644 index 000000000..df473d9af --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EventData.java @@ -0,0 +1,688 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to report an event notification for a component-variable. */ +public final class EventData { + /** Custom data */ + @Nullable private CustomData customData; + + /** The identifier of the event. This field can be referred to as a cause by other events. */ + private Integer eventId; + + /** Timestamp of the moment the report was generated. */ + private ZonedDateTime timestamp; + + /** Type of monitor that triggered this event, e.g. exceeding a threshold value. */ + private EventTriggerEnum trigger; + + /** Refers to the Id of an event that is considered to be the cause for this event. */ + @Nullable private Integer cause; + + /** + * Actual value (attributeType Actual) of the variable. + * + *

The Configuration Variable ReportingValueSize can be used to limit + * GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max + * size of these values will always remain equal. + */ + private String actualValue; + + /** Technical (error) code as reported by component. */ + @Nullable private String techCode; + + /** Technical detail information as reported by component. */ + @Nullable private String techInfo; + + /** + * Cleared is set to true to report the clearing of a monitored situation, i.e. a 'return to + * normal'. + */ + @Nullable private Boolean cleared; + + /** + * If an event notification is linked to a specific transaction, this field can be used to specify + * its transactionId. + */ + @Nullable private String transactionId; + + /** A physical or logical component */ + private Component component; + + /** The identifier of the VariableMonitoring which triggered the event. */ + @Nullable private Integer variableMonitoringId; + + /** Specifies the event notification type of the message. */ + private EventNotificationEnum eventNotificationType; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** + * Constructor for the EventData class + * + * @param eventId The identifier of the event. This field can be referred to as a cause by other + * events. + * @param timestamp Timestamp of the moment the report was generated. + * @param trigger Type of monitor that triggered this event, e.g. exceeding a threshold value. + * @param actualValue Actual value (attributeType Actual) of the variable. + * @param component A physical or logical component + * @param eventNotificationType Specifies the event notification type of the message. + * @param variable Reference key to a component-variable. + */ + public EventData( + Integer eventId, + ZonedDateTime timestamp, + EventTriggerEnum trigger, + String actualValue, + Component component, + EventNotificationEnum eventNotificationType, + Variable variable) { + setEventId(eventId); + setTimestamp(timestamp); + setTrigger(trigger); + setActualValue(actualValue); + setComponent(component); + setEventNotificationType(eventNotificationType); + setVariable(variable); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public EventData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the identifier of the event. This field can be referred to as a cause by other events. + * + * @return The identifier of the event + */ + public Integer getEventId() { + return eventId; + } + + /** + * Sets the identifier of the event. This field can be referred to as a cause by other events. + * + * @param eventId The identifier of the event + */ + public void setEventId(Integer eventId) { + if (!isValidEventId(eventId)) { + throw new PropertyConstraintException(eventId, "eventId is invalid"); + } + this.eventId = eventId; + } + + /** + * Returns whether the given eventId is valid + * + * @param eventId the eventId to check the validity of + * @return {@code true} if eventId is valid, {@code false} if not + */ + private boolean isValidEventId(Integer eventId) { + return eventId != null; + } + + /** + * Gets timestamp of the moment the report was generated. + * + * @return Timestamp of the moment the report was generated + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets timestamp of the moment the report was generated. + * + * @param timestamp Timestamp of the moment the report was generated + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + /** + * Gets type of monitor that triggered this event, e.g. exceeding a threshold value. + * + * @return Type of monitor that triggered this event, e.g. exceeding a threshold value + */ + public EventTriggerEnum getTrigger() { + return trigger; + } + + /** + * Sets type of monitor that triggered this event, e.g. exceeding a threshold value. + * + * @param trigger Type of monitor that triggered this event, e.g. exceeding a threshold value + */ + public void setTrigger(EventTriggerEnum trigger) { + if (!isValidTrigger(trigger)) { + throw new PropertyConstraintException(trigger, "trigger is invalid"); + } + this.trigger = trigger; + } + + /** + * Returns whether the given trigger is valid + * + * @param trigger the trigger to check the validity of + * @return {@code true} if trigger is valid, {@code false} if not + */ + private boolean isValidTrigger(EventTriggerEnum trigger) { + return trigger != null; + } + + /** + * Gets refers to the Id of an event that is considered to be the cause for this event. + * + * @return Refers to the Id of an event that is considered to be the cause for this event + */ + @Nullable + public Integer getCause() { + return cause; + } + + /** + * Sets refers to the Id of an event that is considered to be the cause for this event. + * + * @param cause Refers to the Id of an event that is considered to be the cause for this event + */ + public void setCause(@Nullable Integer cause) { + this.cause = cause; + } + + /** + * Adds refers to the Id of an event that is considered to be the cause for this event. + * + * @param cause Refers to the Id of an event that is considered to be the cause for this event + * @return this + */ + public EventData withCause(@Nullable Integer cause) { + setCause(cause); + return this; + } + + /** + * Gets actual value (attributeType Actual) of the variable. + * + * @return Actual value (attributeType Actual) of the variable + */ + public String getActualValue() { + return actualValue; + } + + /** + * Sets actual value (attributeType Actual) of the variable. + * + * @param actualValue Actual value (attributeType Actual) of the variable + */ + public void setActualValue(String actualValue) { + if (!isValidActualValue(actualValue)) { + throw new PropertyConstraintException(actualValue, "actualValue is invalid"); + } + this.actualValue = actualValue; + } + + /** + * Returns whether the given actualValue is valid + * + * @param actualValue the actualValue to check the validity of + * @return {@code true} if actualValue is valid, {@code false} if not + */ + private boolean isValidActualValue(String actualValue) { + return actualValue != null && actualValue.length() <= 2500; + } + + /** + * Gets technical (error) code as reported by component. + * + * @return Technical (error) code as reported by component + */ + @Nullable + public String getTechCode() { + return techCode; + } + + /** + * Sets technical (error) code as reported by component. + * + * @param techCode Technical (error) code as reported by component + */ + public void setTechCode(@Nullable String techCode) { + if (!isValidTechCode(techCode)) { + throw new PropertyConstraintException(techCode, "techCode is invalid"); + } + this.techCode = techCode; + } + + /** + * Returns whether the given techCode is valid + * + * @param techCode the techCode to check the validity of + * @return {@code true} if techCode is valid, {@code false} if not + */ + private boolean isValidTechCode(@Nullable String techCode) { + return techCode == null || techCode.length() <= 50; + } + + /** + * Adds technical (error) code as reported by component. + * + * @param techCode Technical (error) code as reported by component + * @return this + */ + public EventData withTechCode(@Nullable String techCode) { + setTechCode(techCode); + return this; + } + + /** + * Gets technical detail information as reported by component. + * + * @return Technical detail information as reported by component + */ + @Nullable + public String getTechInfo() { + return techInfo; + } + + /** + * Sets technical detail information as reported by component. + * + * @param techInfo Technical detail information as reported by component + */ + public void setTechInfo(@Nullable String techInfo) { + if (!isValidTechInfo(techInfo)) { + throw new PropertyConstraintException(techInfo, "techInfo is invalid"); + } + this.techInfo = techInfo; + } + + /** + * Returns whether the given techInfo is valid + * + * @param techInfo the techInfo to check the validity of + * @return {@code true} if techInfo is valid, {@code false} if not + */ + private boolean isValidTechInfo(@Nullable String techInfo) { + return techInfo == null || techInfo.length() <= 500; + } + + /** + * Adds technical detail information as reported by component. + * + * @param techInfo Technical detail information as reported by component + * @return this + */ + public EventData withTechInfo(@Nullable String techInfo) { + setTechInfo(techInfo); + return this; + } + + /** + * Gets cleared is set to true to report the clearing of a monitored situation, i.e. a 'return to + * normal'. + * + * @return Cleared is set to true to report the clearing of a monitored situation, i.e. a 'return + * to normal' + */ + @Nullable + public Boolean getCleared() { + return cleared; + } + + /** + * Sets cleared is set to true to report the clearing of a monitored situation, i.e. a 'return to + * normal'. + * + * @param cleared Cleared is set to true to report the clearing of a monitored situation, i.e. a + * 'return to normal' + */ + public void setCleared(@Nullable Boolean cleared) { + this.cleared = cleared; + } + + /** + * Adds cleared is set to true to report the clearing of a monitored situation, i.e. a 'return to + * normal'. + * + * @param cleared Cleared is set to true to report the clearing of a monitored situation, i.e. a + * 'return to normal' + * @return this + */ + public EventData withCleared(@Nullable Boolean cleared) { + setCleared(cleared); + return this; + } + + /** + * Gets if an event notification is linked to a specific transaction, this field can be used to + * specify its transactionId. + * + * @return If an event notification is linked to a specific transaction, this field can be used to + * specify its transactionId + */ + @Nullable + public String getTransactionId() { + return transactionId; + } + + /** + * Sets if an event notification is linked to a specific transaction, this field can be used to + * specify its transactionId. + * + * @param transactionId If an event notification is linked to a specific transaction, this field + * can be used to specify its transactionId + */ + public void setTransactionId(@Nullable String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(@Nullable String transactionId) { + return transactionId == null || transactionId.length() <= 36; + } + + /** + * Adds if an event notification is linked to a specific transaction, this field can be used to + * specify its transactionId. + * + * @param transactionId If an event notification is linked to a specific transaction, this field + * can be used to specify its transactionId + * @return this + */ + public EventData withTransactionId(@Nullable String transactionId) { + setTransactionId(transactionId); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets the identifier of the VariableMonitoring which triggered the event. + * + * @return The identifier of the VariableMonitoring which triggered the event + */ + @Nullable + public Integer getVariableMonitoringId() { + return variableMonitoringId; + } + + /** + * Sets the identifier of the VariableMonitoring which triggered the event. + * + * @param variableMonitoringId The identifier of the VariableMonitoring which triggered the event + */ + public void setVariableMonitoringId(@Nullable Integer variableMonitoringId) { + this.variableMonitoringId = variableMonitoringId; + } + + /** + * Adds the identifier of the VariableMonitoring which triggered the event. + * + * @param variableMonitoringId The identifier of the VariableMonitoring which triggered the event + * @return this + */ + public EventData withVariableMonitoringId(@Nullable Integer variableMonitoringId) { + setVariableMonitoringId(variableMonitoringId); + return this; + } + + /** + * Gets specifies the event notification type of the message. + * + * @return Specifies the event notification type of the message + */ + public EventNotificationEnum getEventNotificationType() { + return eventNotificationType; + } + + /** + * Sets specifies the event notification type of the message. + * + * @param eventNotificationType Specifies the event notification type of the message + */ + public void setEventNotificationType(EventNotificationEnum eventNotificationType) { + if (!isValidEventNotificationType(eventNotificationType)) { + throw new PropertyConstraintException( + eventNotificationType, "eventNotificationType is invalid"); + } + this.eventNotificationType = eventNotificationType; + } + + /** + * Returns whether the given eventNotificationType is valid + * + * @param eventNotificationType the eventNotificationType to check the validity of + * @return {@code true} if eventNotificationType is valid, {@code false} if not + */ + private boolean isValidEventNotificationType(EventNotificationEnum eventNotificationType) { + return eventNotificationType != null; + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidEventId(eventId) + && isValidTimestamp(timestamp) + && isValidTrigger(trigger) + && isValidActualValue(actualValue) + && isValidTechCode(techCode) + && isValidTechInfo(techInfo) + && isValidTransactionId(transactionId) + && isValidComponent(component) + && isValidEventNotificationType(eventNotificationType) + && isValidVariable(variable); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventData that = (EventData) o; + return Objects.equals(customData, that.customData) + && Objects.equals(eventId, that.eventId) + && Objects.equals(timestamp, that.timestamp) + && Objects.equals(trigger, that.trigger) + && Objects.equals(cause, that.cause) + && Objects.equals(actualValue, that.actualValue) + && Objects.equals(techCode, that.techCode) + && Objects.equals(techInfo, that.techInfo) + && Objects.equals(cleared, that.cleared) + && Objects.equals(transactionId, that.transactionId) + && Objects.equals(component, that.component) + && Objects.equals(variableMonitoringId, that.variableMonitoringId) + && Objects.equals(eventNotificationType, that.eventNotificationType) + && Objects.equals(variable, that.variable); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + eventId, + timestamp, + trigger, + cause, + actualValue, + techCode, + techInfo, + cleared, + transactionId, + component, + variableMonitoringId, + eventNotificationType, + variable); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("eventId", eventId) + .add("timestamp", timestamp) + .add("trigger", trigger) + .add("cause", cause) + .add("actualValue", actualValue) + .add("techCode", techCode) + .add("techInfo", techInfo) + .add("cleared", cleared) + .add("transactionId", transactionId) + .add("component", component) + .add("variableMonitoringId", variableMonitoringId) + .add("eventNotificationType", eventNotificationType) + .add("variable", variable) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EventNotificationEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EventNotificationEnum.java new file mode 100644 index 000000000..fbe50d1e9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EventNotificationEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Specifies the event notification type of the message. */ +public enum EventNotificationEnum { + HardWiredNotification, + HardWiredMonitor, + PreconfiguredMonitor, + CustomMonitor +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EventTriggerEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EventTriggerEnum.java new file mode 100644 index 000000000..a7d07ca3a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/EventTriggerEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Type of monitor that triggered this event, e.g. exceeding a threshold value. */ +public enum EventTriggerEnum { + Alerting, + Delta, + Periodic +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Firmware.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Firmware.java new file mode 100644 index 000000000..7cd701455 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Firmware.java @@ -0,0 +1,348 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Firmware + * + *

A copy of the firmware that can be loaded/updated on the Charging Station. + */ +public final class Firmware { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Firmware. Location. URI + * + *

URI defining the origin of the firmware. + */ + private String location; + + /** + * Firmware. Retrieve. Date Time + * + *

Date and time at which the firmware shall be retrieved. + */ + private ZonedDateTime retrieveDateTime; + + /** + * Firmware. Install. Date Time + * + *

Date and time at which the firmware shall be installed. + */ + @Nullable private ZonedDateTime installDateTime; + + /** Certificate with which the firmware was signed. PEM encoded X.509 certificate. */ + @Nullable private String signingCertificate; + + /** + * Firmware. Signature. Signature + * + *

Base64 encoded firmware signature. + */ + @Nullable private String signature; + + /** + * Constructor for the Firmware class + * + * @param location URI defining the origin of the firmware. + * @param retrieveDateTime Date and time at which the firmware shall be retrieved. + */ + public Firmware(String location, ZonedDateTime retrieveDateTime) { + setLocation(location); + setRetrieveDateTime(retrieveDateTime); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Firmware withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets URI defining the origin of the firmware. + * + * @return URI defining the origin of the firmware + */ + public String getLocation() { + return location; + } + + /** + * Sets URI defining the origin of the firmware. + * + * @param location URI defining the origin of the firmware + */ + public void setLocation(String location) { + if (!isValidLocation(location)) { + throw new PropertyConstraintException(location, "location is invalid"); + } + this.location = location; + } + + /** + * Returns whether the given location is valid + * + * @param location the location to check the validity of + * @return {@code true} if location is valid, {@code false} if not + */ + private boolean isValidLocation(String location) { + return location != null && location.length() <= 512; + } + + /** + * Gets date and time at which the firmware shall be retrieved. + * + * @return Date and time at which the firmware shall be retrieved + */ + public ZonedDateTime getRetrieveDateTime() { + return retrieveDateTime; + } + + /** + * Sets date and time at which the firmware shall be retrieved. + * + * @param retrieveDateTime Date and time at which the firmware shall be retrieved + */ + public void setRetrieveDateTime(ZonedDateTime retrieveDateTime) { + if (!isValidRetrieveDateTime(retrieveDateTime)) { + throw new PropertyConstraintException(retrieveDateTime, "retrieveDateTime is invalid"); + } + this.retrieveDateTime = retrieveDateTime; + } + + /** + * Returns whether the given retrieveDateTime is valid + * + * @param retrieveDateTime the retrieveDateTime to check the validity of + * @return {@code true} if retrieveDateTime is valid, {@code false} if not + */ + private boolean isValidRetrieveDateTime(ZonedDateTime retrieveDateTime) { + return retrieveDateTime != null; + } + + /** + * Gets date and time at which the firmware shall be installed. + * + * @return Date and time at which the firmware shall be installed + */ + @Nullable + public ZonedDateTime getInstallDateTime() { + return installDateTime; + } + + /** + * Sets date and time at which the firmware shall be installed. + * + * @param installDateTime Date and time at which the firmware shall be installed + */ + public void setInstallDateTime(@Nullable ZonedDateTime installDateTime) { + this.installDateTime = installDateTime; + } + + /** + * Adds date and time at which the firmware shall be installed. + * + * @param installDateTime Date and time at which the firmware shall be installed + * @return this + */ + public Firmware withInstallDateTime(@Nullable ZonedDateTime installDateTime) { + setInstallDateTime(installDateTime); + return this; + } + + /** + * Gets certificate with which the firmware was signed. PEM encoded X.509 certificate. + * + * @return Certificate with which the firmware was signed + */ + @Nullable + public String getSigningCertificate() { + return signingCertificate; + } + + /** + * Sets certificate with which the firmware was signed. PEM encoded X.509 certificate. + * + * @param signingCertificate Certificate with which the firmware was signed + */ + public void setSigningCertificate(@Nullable String signingCertificate) { + if (!isValidSigningCertificate(signingCertificate)) { + throw new PropertyConstraintException(signingCertificate, "signingCertificate is invalid"); + } + this.signingCertificate = signingCertificate; + } + + /** + * Returns whether the given signingCertificate is valid + * + * @param signingCertificate the signingCertificate to check the validity of + * @return {@code true} if signingCertificate is valid, {@code false} if not + */ + private boolean isValidSigningCertificate(@Nullable String signingCertificate) { + return signingCertificate == null || signingCertificate.length() <= 5500; + } + + /** + * Adds certificate with which the firmware was signed. PEM encoded X.509 certificate. + * + * @param signingCertificate Certificate with which the firmware was signed + * @return this + */ + public Firmware withSigningCertificate(@Nullable String signingCertificate) { + setSigningCertificate(signingCertificate); + return this; + } + + /** + * Gets base64 encoded firmware signature. + * + * @return Base64 encoded firmware signature + */ + @Nullable + public String getSignature() { + return signature; + } + + /** + * Sets base64 encoded firmware signature. + * + * @param signature Base64 encoded firmware signature + */ + public void setSignature(@Nullable String signature) { + if (!isValidSignature(signature)) { + throw new PropertyConstraintException(signature, "signature is invalid"); + } + this.signature = signature; + } + + /** + * Returns whether the given signature is valid + * + * @param signature the signature to check the validity of + * @return {@code true} if signature is valid, {@code false} if not + */ + private boolean isValidSignature(@Nullable String signature) { + return signature == null || signature.length() <= 800; + } + + /** + * Adds base64 encoded firmware signature. + * + * @param signature Base64 encoded firmware signature + * @return this + */ + public Firmware withSignature(@Nullable String signature) { + setSignature(signature); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidLocation(location) + && isValidRetrieveDateTime(retrieveDateTime) + && isValidSigningCertificate(signingCertificate) + && isValidSignature(signature); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Firmware that = (Firmware) o; + return Objects.equals(customData, that.customData) + && Objects.equals(location, that.location) + && Objects.equals(retrieveDateTime, that.retrieveDateTime) + && Objects.equals(installDateTime, that.installDateTime) + && Objects.equals(signingCertificate, that.signingCertificate) + && Objects.equals(signature, that.signature); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, location, retrieveDateTime, installDateTime, signingCertificate, signature); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("location", location) + .add("retrieveDateTime", retrieveDateTime) + .add("installDateTime", installDateTime) + .add("signingCertificate", signingCertificate) + .add("signature", signature) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/FirmwareStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/FirmwareStatusEnum.java new file mode 100644 index 000000000..7ff0b4d17 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/FirmwareStatusEnum.java @@ -0,0 +1,43 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The progress status of the firmware installation. */ +public enum FirmwareStatusEnum { + Downloaded, + DownloadFailed, + Downloading, + DownloadScheduled, + DownloadPaused, + Idle, + InstallationFailed, + Installing, + Installed, + InstallRebooting, + InstallScheduled, + InstallVerificationFailed, + InvalidSignature, + SignatureVerified +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GenericDeviceModelStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GenericDeviceModelStatusEnum.java new file mode 100644 index 000000000..b58664007 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GenericDeviceModelStatusEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the Charging Station was able to accept the request. */ +public enum GenericDeviceModelStatusEnum { + Accepted, + Rejected, + NotSupported, + EmptyResultSet +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GenericStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GenericStatusEnum.java new file mode 100644 index 000000000..fb528f1dd --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GenericStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Specifies whether the CSMS can process the request. */ +public enum GenericStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetCertificateIdUseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetCertificateIdUseEnum.java new file mode 100644 index 000000000..82e314687 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetCertificateIdUseEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The type of the requested certificate(s). */ +public enum GetCertificateIdUseEnum { + V2GRootCertificate, + MORootCertificate, + CSMSRootCertificate, + V2GCertificateChain, + ManufacturerRootCertificate +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetCertificateStatusEnum.java new file mode 100644 index 000000000..991acd3d9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetCertificateStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the charging station was able to retrieve the OCSP certificate status. */ +public enum GetCertificateStatusEnum { + Accepted, + Failed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetChargingProfileStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetChargingProfileStatusEnum.java new file mode 100644 index 000000000..a2f8b17fb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetChargingProfileStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Whether the Charging Station is able to process this request and will send + * ReportChargingProfilesRequest messages. + */ +public enum GetChargingProfileStatusEnum { + Accepted, + NoProfiles +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetDisplayMessagesStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetDisplayMessagesStatusEnum.java new file mode 100644 index 000000000..f069d8ca2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetDisplayMessagesStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Whether the Charging Station has Display Messages that match the request criteria in the + * GetDisplayMessagesRequest + */ +public enum GetDisplayMessagesStatusEnum { + Accepted, + Unknown +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetInstalledCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetInstalledCertificateStatusEnum.java new file mode 100644 index 000000000..69587f15d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetInstalledCertificateStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Charging Station indicates if it can process the request. */ +public enum GetInstalledCertificateStatusEnum { + Accepted, + NotFound +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetVariableData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetVariableData.java new file mode 100644 index 000000000..b720bac49 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetVariableData.java @@ -0,0 +1,227 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to hold parameters for GetVariables request. */ +public final class GetVariableData { + /** Custom data */ + @Nullable private CustomData customData; + + /** Attribute type for which value is requested. When absent, default Actual is assumed. */ + @Nullable private AttributeEnum attributeType; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** + * Constructor for the GetVariableData class + * + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + */ + public GetVariableData(Component component, Variable variable) { + setComponent(component); + setVariable(variable); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetVariableData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets attribute type for which value is requested. When absent, default Actual is assumed. + * + * @return Attribute type for which value is requested + */ + public AttributeEnum getAttributeType() { + return attributeType != null ? attributeType : AttributeEnum.Actual; + } + + /** + * Sets attribute type for which value is requested. When absent, default Actual is assumed. + * + * @param attributeType Attribute type for which value is requested + */ + public void setAttributeType(@Nullable AttributeEnum attributeType) { + this.attributeType = attributeType; + } + + /** + * Adds attribute type for which value is requested. When absent, default Actual is assumed. + * + * @param attributeType Attribute type for which value is requested + * @return this + */ + public GetVariableData withAttributeType(@Nullable AttributeEnum attributeType) { + setAttributeType(attributeType); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidComponent(component) + && isValidVariable(variable); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetVariableData that = (GetVariableData) o; + return Objects.equals(customData, that.customData) + && Objects.equals(attributeType, that.attributeType) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable); + } + + @Override + public int hashCode() { + return Objects.hash(customData, attributeType, component, variable); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("attributeType", attributeType) + .add("component", component) + .add("variable", variable) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetVariableResult.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetVariableResult.java new file mode 100644 index 000000000..6622a2341 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetVariableResult.java @@ -0,0 +1,386 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to hold results of GetVariables request. */ +public final class GetVariableResult { + /** Custom data */ + @Nullable private CustomData customData; + + /** More information about the status. */ + @Nullable private StatusInfo attributeStatusInfo; + + /** Result status of getting the variable. */ + private GetVariableStatusEnum attributeStatus; + + /** Attribute type for which value is requested. When absent, default Actual is assumed. */ + @Nullable private AttributeEnum attributeType; + + /** + * Value of requested attribute type of component-variable. This field can only be empty when the + * given status is NOT accepted. + * + *

The Configuration Variable ReportingValueSize can be used to limit + * GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max + * size of these values will always remain equal. + */ + @Nullable private String attributeValue; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** + * Constructor for the GetVariableResult class + * + * @param attributeStatus Result status of getting the variable. + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + */ + public GetVariableResult( + GetVariableStatusEnum attributeStatus, Component component, Variable variable) { + setAttributeStatus(attributeStatus); + setComponent(component); + setVariable(variable); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public GetVariableResult withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getAttributeStatusInfo() { + return attributeStatusInfo; + } + + /** + * Sets more information about the status. + * + * @param attributeStatusInfo More information about the status + */ + public void setAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + if (!isValidAttributeStatusInfo(attributeStatusInfo)) { + throw new PropertyConstraintException(attributeStatusInfo, "attributeStatusInfo is invalid"); + } + this.attributeStatusInfo = attributeStatusInfo; + } + + /** + * Returns whether the given attributeStatusInfo is valid + * + * @param attributeStatusInfo the attributeStatusInfo to check the validity of + * @return {@code true} if attributeStatusInfo is valid, {@code false} if not + */ + private boolean isValidAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + return attributeStatusInfo == null || attributeStatusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param attributeStatusInfo More information about the status + * @return this + */ + public GetVariableResult withAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + setAttributeStatusInfo(attributeStatusInfo); + return this; + } + + /** + * Gets result status of getting the variable. + * + * @return Result status of getting the variable + */ + public GetVariableStatusEnum getAttributeStatus() { + return attributeStatus; + } + + /** + * Sets result status of getting the variable. + * + * @param attributeStatus Result status of getting the variable + */ + public void setAttributeStatus(GetVariableStatusEnum attributeStatus) { + if (!isValidAttributeStatus(attributeStatus)) { + throw new PropertyConstraintException(attributeStatus, "attributeStatus is invalid"); + } + this.attributeStatus = attributeStatus; + } + + /** + * Returns whether the given attributeStatus is valid + * + * @param attributeStatus the attributeStatus to check the validity of + * @return {@code true} if attributeStatus is valid, {@code false} if not + */ + private boolean isValidAttributeStatus(GetVariableStatusEnum attributeStatus) { + return attributeStatus != null; + } + + /** + * Gets attribute type for which value is requested. When absent, default Actual is assumed. + * + * @return Attribute type for which value is requested + */ + public AttributeEnum getAttributeType() { + return attributeType != null ? attributeType : AttributeEnum.Actual; + } + + /** + * Sets attribute type for which value is requested. When absent, default Actual is assumed. + * + * @param attributeType Attribute type for which value is requested + */ + public void setAttributeType(@Nullable AttributeEnum attributeType) { + this.attributeType = attributeType; + } + + /** + * Adds attribute type for which value is requested. When absent, default Actual is assumed. + * + * @param attributeType Attribute type for which value is requested + * @return this + */ + public GetVariableResult withAttributeType(@Nullable AttributeEnum attributeType) { + setAttributeType(attributeType); + return this; + } + + /** + * Gets value of requested attribute type of component-variable. This field can only be empty when + * the given status is NOT accepted. + * + * @return Value of requested attribute type of component-variable + */ + @Nullable + public String getAttributeValue() { + return attributeValue; + } + + /** + * Sets value of requested attribute type of component-variable. This field can only be empty when + * the given status is NOT accepted. + * + * @param attributeValue Value of requested attribute type of component-variable + */ + public void setAttributeValue(@Nullable String attributeValue) { + if (!isValidAttributeValue(attributeValue)) { + throw new PropertyConstraintException(attributeValue, "attributeValue is invalid"); + } + this.attributeValue = attributeValue; + } + + /** + * Returns whether the given attributeValue is valid + * + * @param attributeValue the attributeValue to check the validity of + * @return {@code true} if attributeValue is valid, {@code false} if not + */ + private boolean isValidAttributeValue(@Nullable String attributeValue) { + if (attributeStatus != GetVariableStatusEnum.Accepted) { + return attributeValue == null || attributeValue.length() <= 2500; + } else { + return attributeValue != null && attributeValue.length() <= 2500; + } + } + + /** + * Adds value of requested attribute type of component-variable. This field can only be empty when + * the given status is NOT accepted. + * + * @param attributeValue Value of requested attribute type of component-variable + * @return this + */ + public GetVariableResult withAttributeValue(@Nullable String attributeValue) { + setAttributeValue(attributeValue); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidAttributeStatusInfo(attributeStatusInfo) + && isValidAttributeStatus(attributeStatus) + && isValidAttributeValue(attributeValue) + && isValidComponent(component) + && isValidVariable(variable); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetVariableResult that = (GetVariableResult) o; + return Objects.equals(customData, that.customData) + && Objects.equals(attributeStatusInfo, that.attributeStatusInfo) + && Objects.equals(attributeStatus, that.attributeStatus) + && Objects.equals(attributeType, that.attributeType) + && Objects.equals(attributeValue, that.attributeValue) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + attributeStatusInfo, + attributeStatus, + attributeType, + attributeValue, + component, + variable); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("attributeStatusInfo", attributeStatusInfo) + .add("attributeStatus", attributeStatus) + .add("attributeType", attributeType) + .add("attributeValue", attributeValue) + .add("component", component) + .add("variable", variable) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetVariableStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetVariableStatusEnum.java new file mode 100644 index 000000000..439bf173e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/GetVariableStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Result status of getting the variable. */ +public enum GetVariableStatusEnum { + Accepted, + Rejected, + UnknownComponent, + UnknownVariable, + NotSupportedAttributeType +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/HashAlgorithmEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/HashAlgorithmEnum.java new file mode 100644 index 000000000..033a3021d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/HashAlgorithmEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Used algorithms for the hashes provided. */ +public enum HashAlgorithmEnum { + SHA256, + SHA384, + SHA512 +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/IdToken.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/IdToken.java new file mode 100644 index 000000000..36d253efe --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/IdToken.java @@ -0,0 +1,263 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ +public final class IdToken { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private AdditionalInfo[] additionalInfo; + + /** + * IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also + * contain a UUID. + */ + private String idToken; + + /** Enumeration of possible idToken types. */ + private IdTokenEnum type; + + /** + * Constructor for the IdToken class + * + * @param idToken IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can + * for example also contain a UUID. + * @param type Enumeration of possible idToken types. + */ + public IdToken(String idToken, IdTokenEnum type) { + setIdToken(idToken); + setType(type); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public IdToken withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public AdditionalInfo[] getAdditionalInfo() { + return additionalInfo; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param additionalInfo A case insensitive identifier to use for the authorization and the type + * of authorization to support multiple forms of identifiers + */ + public void setAdditionalInfo(@Nullable AdditionalInfo[] additionalInfo) { + if (!isValidAdditionalInfo(additionalInfo)) { + throw new PropertyConstraintException(additionalInfo, "additionalInfo is invalid"); + } + this.additionalInfo = additionalInfo; + } + + /** + * Returns whether the given additionalInfo is valid + * + * @param additionalInfo the additionalInfo to check the validity of + * @return {@code true} if additionalInfo is valid, {@code false} if not + */ + private boolean isValidAdditionalInfo(@Nullable AdditionalInfo[] additionalInfo) { + return additionalInfo == null + || (additionalInfo.length >= 1 + && Arrays.stream(additionalInfo).allMatch(item -> item.validate())); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param additionalInfo A case insensitive identifier to use for the authorization and the type + * of authorization to support multiple forms of identifiers + * @return this + */ + public IdToken withAdditionalInfo(@Nullable AdditionalInfo[] additionalInfo) { + setAdditionalInfo(additionalInfo); + return this; + } + + /** + * Gets idToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example + * also contain a UUID. + * + * @return IdToken is case insensitive + */ + public String getIdToken() { + return idToken; + } + + /** + * Sets idToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example + * also contain a UUID. + * + * @param idToken IdToken is case insensitive + */ + public void setIdToken(String idToken) { + if (!isValidIdToken(idToken)) { + throw new PropertyConstraintException(idToken, "idToken is invalid"); + } + this.idToken = idToken; + } + + /** + * Returns whether the given idToken is valid + * + * @param idToken the idToken to check the validity of + * @return {@code true} if idToken is valid, {@code false} if not + */ + private boolean isValidIdToken(String idToken) { + return idToken != null && idToken.length() <= 36; + } + + /** + * Gets enumeration of possible idToken types. + * + * @return Enumeration of possible idToken types + */ + public IdTokenEnum getType() { + return type; + } + + /** + * Sets enumeration of possible idToken types. + * + * @param type Enumeration of possible idToken types + */ + public void setType(IdTokenEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(IdTokenEnum type) { + return type != null; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidAdditionalInfo(additionalInfo) + && isValidIdToken(idToken) + && isValidType(type); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IdToken that = (IdToken) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(additionalInfo, that.additionalInfo) + && Objects.equals(idToken, that.idToken) + && Objects.equals(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(additionalInfo), idToken, type); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("additionalInfo", additionalInfo) + .add("idToken", idToken) + .add("type", type) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/IdTokenEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/IdTokenEnum.java new file mode 100644 index 000000000..36a227172 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/IdTokenEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Enumeration of possible idToken types. */ +public enum IdTokenEnum { + Central, + eMAID, + ISO14443, + ISO15693, + KeyCode, + Local, + MacAddress, + NoAuthorization +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/IdTokenInfo.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/IdTokenInfo.java new file mode 100644 index 000000000..cb8f4b39b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/IdTokenInfo.java @@ -0,0 +1,542 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * ID Token + * + *

Status information about an identifier. It is advised to not stop charging for a token that + * expires during charging, as ExpiryDate is only used for caching purposes. If ExpiryDate is not + * given, the status has no end date. + */ +public final class IdTokenInfo { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * ID Token. Status. Authorization Status + * + *

Current status of the ID Token. + */ + private AuthorizationStatusEnum status; + + /** + * ID Token. Expiry. Date Time + * + *

Date and Time after which the token must be considered invalid. + */ + @Nullable private ZonedDateTime cacheExpiryDateTime; + + /** + * Priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse + * overrules this one. + */ + @Nullable private Integer chargingPriority; + + /** + * ID Token. Language1. Language Code + * + *

Preferred user interface language of identifier user. Contains a language code as defined in + * [RFC5646]. + */ + @Nullable private String language1; + + /** + * Only used when the IdToken is only valid for one or more specific EVSEs, not for the entire + * Charging Station. + */ + @Nullable private Integer[] evseId; + + /** + * A case insensitive identifier to use for the authorization and the type of authorization to + * support multiple forms of identifiers. + */ + @Nullable private IdToken groupIdToken; + + /** + * ID Token. Language2. Language Code + * + *

Second preferred user interface language of identifier user. Don’t use when language1 is + * omitted, has to be different from language1. Contains a language code as defined in [RFC5646]. + */ + @Nullable private String language2; + + /** + * Message Content + * + *

Message details, for a message to be displayed on a Charging Station. + */ + @Nullable private MessageContent personalMessage; + + /** + * Constructor for the IdTokenInfo class + * + * @param status Current status of the ID Token. + */ + public IdTokenInfo(AuthorizationStatusEnum status) { + setStatus(status); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public IdTokenInfo withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets current status of the ID Token. + * + * @return Current status of the ID Token + */ + public AuthorizationStatusEnum getStatus() { + return status; + } + + /** + * Sets current status of the ID Token. + * + * @param status Current status of the ID Token + */ + public void setStatus(AuthorizationStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(AuthorizationStatusEnum status) { + return status != null; + } + + /** + * Gets date and Time after which the token must be considered invalid. + * + * @return Date and Time after which the token must be considered invalid + */ + @Nullable + public ZonedDateTime getCacheExpiryDateTime() { + return cacheExpiryDateTime; + } + + /** + * Sets date and Time after which the token must be considered invalid. + * + * @param cacheExpiryDateTime Date and Time after which the token must be considered invalid + */ + public void setCacheExpiryDateTime(@Nullable ZonedDateTime cacheExpiryDateTime) { + this.cacheExpiryDateTime = cacheExpiryDateTime; + } + + /** + * Adds date and Time after which the token must be considered invalid. + * + * @param cacheExpiryDateTime Date and Time after which the token must be considered invalid + * @return this + */ + public IdTokenInfo withCacheExpiryDateTime(@Nullable ZonedDateTime cacheExpiryDateTime) { + setCacheExpiryDateTime(cacheExpiryDateTime); + return this; + } + + /** + * Gets priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse + * overrules this one. + * + * @return Priority from a business point of view + */ + @Nullable + public Integer getChargingPriority() { + return chargingPriority; + } + + /** + * Sets priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse + * overrules this one. + * + * @param chargingPriority Priority from a business point of view + */ + public void setChargingPriority(@Nullable Integer chargingPriority) { + this.chargingPriority = chargingPriority; + } + + /** + * Adds priority from a business point of view. Default priority is 0, The range is from -9 to 9. + * Higher values indicate a higher priority. The chargingPriority in TransactionEventResponse + * overrules this one. + * + * @param chargingPriority Priority from a business point of view + * @return this + */ + public IdTokenInfo withChargingPriority(@Nullable Integer chargingPriority) { + setChargingPriority(chargingPriority); + return this; + } + + /** + * Gets preferred user interface language of identifier user. Contains a language code as defined + * in [RFC5646]. + * + * @return Preferred user interface language of identifier user + */ + @Nullable + public String getLanguage1() { + return language1; + } + + /** + * Sets preferred user interface language of identifier user. Contains a language code as defined + * in [RFC5646]. + * + * @param language1 Preferred user interface language of identifier user + */ + public void setLanguage1(@Nullable String language1) { + if (!isValidLanguage1(language1)) { + throw new PropertyConstraintException(language1, "language1 is invalid"); + } + this.language1 = language1; + } + + /** + * Returns whether the given language1 is valid + * + * @param language1 the language1 to check the validity of + * @return {@code true} if language1 is valid, {@code false} if not + */ + private boolean isValidLanguage1(@Nullable String language1) { + return language1 == null || language1.length() <= 8; + } + + /** + * Adds preferred user interface language of identifier user. Contains a language code as defined + * in [RFC5646]. + * + * @param language1 Preferred user interface language of identifier user + * @return this + */ + public IdTokenInfo withLanguage1(@Nullable String language1) { + setLanguage1(language1); + return this; + } + + /** + * Gets only used when the IdToken is only valid for one or more specific EVSEs, not for the + * entire Charging Station. + * + * @return Only used when the IdToken is only valid for one or more specific EVSEs, not for the + * entire Charging Station + */ + @Nullable + public Integer[] getEvseId() { + return evseId; + } + + /** + * Sets only used when the IdToken is only valid for one or more specific EVSEs, not for the + * entire Charging Station. + * + * @param evseId Only used when the IdToken is only valid for one or more specific EVSEs, not for + * the entire Charging Station + */ + public void setEvseId(@Nullable Integer[] evseId) { + if (!isValidEvseId(evseId)) { + throw new PropertyConstraintException(evseId, "evseId is invalid"); + } + this.evseId = evseId; + } + + /** + * Returns whether the given evseId is valid + * + * @param evseId the evseId to check the validity of + * @return {@code true} if evseId is valid, {@code false} if not + */ + private boolean isValidEvseId(@Nullable Integer[] evseId) { + return evseId == null || (evseId.length >= 1); + } + + /** + * Adds only used when the IdToken is only valid for one or more specific EVSEs, not for the + * entire Charging Station. + * + * @param evseId Only used when the IdToken is only valid for one or more specific EVSEs, not for + * the entire Charging Station + * @return this + */ + public IdTokenInfo withEvseId(@Nullable Integer[] evseId) { + setEvseId(evseId); + return this; + } + + /** + * Gets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @return A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + @Nullable + public IdToken getGroupIdToken() { + return groupIdToken; + } + + /** + * Sets a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + */ + public void setGroupIdToken(@Nullable IdToken groupIdToken) { + if (!isValidGroupIdToken(groupIdToken)) { + throw new PropertyConstraintException(groupIdToken, "groupIdToken is invalid"); + } + this.groupIdToken = groupIdToken; + } + + /** + * Returns whether the given groupIdToken is valid + * + * @param groupIdToken the groupIdToken to check the validity of + * @return {@code true} if groupIdToken is valid, {@code false} if not + */ + private boolean isValidGroupIdToken(@Nullable IdToken groupIdToken) { + return groupIdToken == null || groupIdToken.validate(); + } + + /** + * Adds a case insensitive identifier to use for the authorization and the type of authorization + * to support multiple forms of identifiers. + * + * @param groupIdToken A case insensitive identifier to use for the authorization and the type of + * authorization to support multiple forms of identifiers + * @return this + */ + public IdTokenInfo withGroupIdToken(@Nullable IdToken groupIdToken) { + setGroupIdToken(groupIdToken); + return this; + } + + /** + * Gets second preferred user interface language of identifier user. Don’t use when language1 is + * omitted, has to be different from language1. Contains a language code as defined in [RFC5646]. + * + * @return Second preferred user interface language of identifier user + */ + @Nullable + public String getLanguage2() { + return language2; + } + + /** + * Sets second preferred user interface language of identifier user. Don’t use when language1 is + * omitted, has to be different from language1. Contains a language code as defined in [RFC5646]. + * + * @param language2 Second preferred user interface language of identifier user + */ + public void setLanguage2(@Nullable String language2) { + if (!isValidLanguage2(language2)) { + throw new PropertyConstraintException(language2, "language2 is invalid"); + } + this.language2 = language2; + } + + /** + * Returns whether the given language2 is valid + * + * @param language2 the language2 to check the validity of + * @return {@code true} if language2 is valid, {@code false} if not + */ + private boolean isValidLanguage2(@Nullable String language2) { + return language2 == null || language2.length() <= 8; + } + + /** + * Adds second preferred user interface language of identifier user. Don’t use when language1 is + * omitted, has to be different from language1. Contains a language code as defined in [RFC5646]. + * + * @param language2 Second preferred user interface language of identifier user + * @return this + */ + public IdTokenInfo withLanguage2(@Nullable String language2) { + setLanguage2(language2); + return this; + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + @Nullable + public MessageContent getPersonalMessage() { + return personalMessage; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param personalMessage Message details, for a message to be displayed on a Charging Station + */ + public void setPersonalMessage(@Nullable MessageContent personalMessage) { + if (!isValidPersonalMessage(personalMessage)) { + throw new PropertyConstraintException(personalMessage, "personalMessage is invalid"); + } + this.personalMessage = personalMessage; + } + + /** + * Returns whether the given personalMessage is valid + * + * @param personalMessage the personalMessage to check the validity of + * @return {@code true} if personalMessage is valid, {@code false} if not + */ + private boolean isValidPersonalMessage(@Nullable MessageContent personalMessage) { + return personalMessage == null || personalMessage.validate(); + } + + /** + * Adds message details, for a message to be displayed on a Charging Station. + * + * @param personalMessage Message details, for a message to be displayed on a Charging Station + * @return this + */ + public IdTokenInfo withPersonalMessage(@Nullable MessageContent personalMessage) { + setPersonalMessage(personalMessage); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidStatus(status) + && isValidLanguage1(language1) + && isValidEvseId(evseId) + && isValidGroupIdToken(groupIdToken) + && isValidLanguage2(language2) + && isValidPersonalMessage(personalMessage); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IdTokenInfo that = (IdTokenInfo) o; + return Objects.equals(customData, that.customData) + && Objects.equals(status, that.status) + && Objects.equals(cacheExpiryDateTime, that.cacheExpiryDateTime) + && Objects.equals(chargingPriority, that.chargingPriority) + && Objects.equals(language1, that.language1) + && Arrays.equals(evseId, that.evseId) + && Objects.equals(groupIdToken, that.groupIdToken) + && Objects.equals(language2, that.language2) + && Objects.equals(personalMessage, that.personalMessage); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + status, + cacheExpiryDateTime, + chargingPriority, + language1, + Arrays.hashCode(evseId), + groupIdToken, + language2, + personalMessage); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("status", status) + .add("cacheExpiryDateTime", cacheExpiryDateTime) + .add("chargingPriority", chargingPriority) + .add("language1", language1) + .add("evseId", evseId) + .add("groupIdToken", groupIdToken) + .add("language2", language2) + .add("personalMessage", personalMessage) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/InstallCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/InstallCertificateStatusEnum.java new file mode 100644 index 000000000..4b9386f85 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/InstallCertificateStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Charging Station indicates if installation was successful. */ +public enum InstallCertificateStatusEnum { + Accepted, + Rejected, + Failed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/InstallCertificateUseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/InstallCertificateUseEnum.java new file mode 100644 index 000000000..239259d2e --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/InstallCertificateUseEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The certificate type that is sent. */ +public enum InstallCertificateUseEnum { + V2GRootCertificate, + MORootCertificate, + CSMSRootCertificate, + ManufacturerRootCertificate +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Iso15118EVCertificateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Iso15118EVCertificateStatusEnum.java new file mode 100644 index 000000000..30e39eb4c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Iso15118EVCertificateStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the message was processed properly. */ +public enum Iso15118EVCertificateStatusEnum { + Accepted, + Failed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LocationEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LocationEnum.java new file mode 100644 index 000000000..3faebf142 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LocationEnum.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Sampled Value. Location. Location Code + * + *

Where the measured value has been sampled. Default = "Outlet" + */ +public enum LocationEnum { + Body, + Cable, + EV, + Inlet, + Outlet +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LogEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LogEnum.java new file mode 100644 index 000000000..07f363dad --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LogEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The type of log file that the Charging Station should send. */ +public enum LogEnum { + DiagnosticsLog, + SecurityLog +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LogParameters.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LogParameters.java new file mode 100644 index 000000000..4d71634e8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LogParameters.java @@ -0,0 +1,246 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Log + * + *

Generic class for the configuration of logging entries. + */ +public final class LogParameters { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Log. Remote Location. URI + * + *

The URL of the location at the remote system where the log should be stored. + */ + private String remoteLocation; + + /** + * Log. Oldest Timestamp. Date Time + * + *

The date and time of the oldest logging information to include in the diagnostics. + */ + @Nullable private ZonedDateTime oldestTimestamp; + + /** + * Log. Latest Timestamp. Date Time + * + *

The date and time of the latest logging information to include in the diagnostics. + */ + @Nullable private ZonedDateTime latestTimestamp; + + /** + * Constructor for the LogParameters class + * + * @param remoteLocation The URL of the location at the remote system where the log should be + * stored. + */ + public LogParameters(String remoteLocation) { + setRemoteLocation(remoteLocation); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public LogParameters withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the URL of the location at the remote system where the log should be stored. + * + * @return The URL of the location at the remote system where the log should be stored + */ + public String getRemoteLocation() { + return remoteLocation; + } + + /** + * Sets the URL of the location at the remote system where the log should be stored. + * + * @param remoteLocation The URL of the location at the remote system where the log should be + * stored + */ + public void setRemoteLocation(String remoteLocation) { + if (!isValidRemoteLocation(remoteLocation)) { + throw new PropertyConstraintException(remoteLocation, "remoteLocation is invalid"); + } + this.remoteLocation = remoteLocation; + } + + /** + * Returns whether the given remoteLocation is valid + * + * @param remoteLocation the remoteLocation to check the validity of + * @return {@code true} if remoteLocation is valid, {@code false} if not + */ + private boolean isValidRemoteLocation(String remoteLocation) { + return remoteLocation != null && remoteLocation.length() <= 512; + } + + /** + * Gets the date and time of the oldest logging information to include in the diagnostics. + * + * @return The date and time of the oldest logging information to include in the diagnostics + */ + @Nullable + public ZonedDateTime getOldestTimestamp() { + return oldestTimestamp; + } + + /** + * Sets the date and time of the oldest logging information to include in the diagnostics. + * + * @param oldestTimestamp The date and time of the oldest logging information to include in the + * diagnostics + */ + public void setOldestTimestamp(@Nullable ZonedDateTime oldestTimestamp) { + this.oldestTimestamp = oldestTimestamp; + } + + /** + * Adds the date and time of the oldest logging information to include in the diagnostics. + * + * @param oldestTimestamp The date and time of the oldest logging information to include in the + * diagnostics + * @return this + */ + public LogParameters withOldestTimestamp(@Nullable ZonedDateTime oldestTimestamp) { + setOldestTimestamp(oldestTimestamp); + return this; + } + + /** + * Gets the date and time of the latest logging information to include in the diagnostics. + * + * @return The date and time of the latest logging information to include in the diagnostics + */ + @Nullable + public ZonedDateTime getLatestTimestamp() { + return latestTimestamp; + } + + /** + * Sets the date and time of the latest logging information to include in the diagnostics. + * + * @param latestTimestamp The date and time of the latest logging information to include in the + * diagnostics + */ + public void setLatestTimestamp(@Nullable ZonedDateTime latestTimestamp) { + this.latestTimestamp = latestTimestamp; + } + + /** + * Adds the date and time of the latest logging information to include in the diagnostics. + * + * @param latestTimestamp The date and time of the latest logging information to include in the + * diagnostics + * @return this + */ + public LogParameters withLatestTimestamp(@Nullable ZonedDateTime latestTimestamp) { + setLatestTimestamp(latestTimestamp); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) && isValidRemoteLocation(remoteLocation); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LogParameters that = (LogParameters) o; + return Objects.equals(customData, that.customData) + && Objects.equals(remoteLocation, that.remoteLocation) + && Objects.equals(oldestTimestamp, that.oldestTimestamp) + && Objects.equals(latestTimestamp, that.latestTimestamp); + } + + @Override + public int hashCode() { + return Objects.hash(customData, remoteLocation, oldestTimestamp, latestTimestamp); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("remoteLocation", remoteLocation) + .add("oldestTimestamp", oldestTimestamp) + .add("latestTimestamp", latestTimestamp) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LogStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LogStatusEnum.java new file mode 100644 index 000000000..db4f1d2e1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/LogStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** This field indicates whether the Charging Station was able to accept the request. */ +public enum LogStatusEnum { + Accepted, + Rejected, + AcceptedCanceled +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MeasurandEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MeasurandEnum.java new file mode 100644 index 000000000..107b56c62 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MeasurandEnum.java @@ -0,0 +1,82 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import com.google.gson.annotations.SerializedName; + +/** + * Sampled Value. Measurand. Measurand Code + * + *

Type of measurement. Default = "Energy.Active.Import.Register" + */ +public enum MeasurandEnum { + @SerializedName("Current.Export") + CurrentExport, + @SerializedName("Current.Import") + CurrentImport, + @SerializedName("Current.Offered") + CurrentOffered, + @SerializedName("Energy.Active.Export.Register") + EnergyActiveExportRegister, + @SerializedName("Energy.Active.Import.Register") + EnergyActiveImportRegister, + @SerializedName("Energy.Reactive.Export.Register") + EnergyReactiveExportRegister, + @SerializedName("Energy.Reactive.Import.Register") + EnergyReactiveImportRegister, + @SerializedName("Energy.Active.Export.Interval") + EnergyActiveExportInterval, + @SerializedName("Energy.Active.Import.Interval") + EnergyActiveImportInterval, + @SerializedName("Energy.Active.Net") + EnergyActiveNet, + @SerializedName("Energy.Reactive.Export.Interval") + EnergyReactiveExportInterval, + @SerializedName("Energy.Reactive.Import.Interval") + EnergyReactiveImportInterval, + @SerializedName("Energy.Reactive.Net") + EnergyReactiveNet, + @SerializedName("Energy.Apparent.Net") + EnergyApparentNet, + @SerializedName("Energy.Apparent.Import") + EnergyApparentImport, + @SerializedName("Energy.Apparent.Export") + EnergyApparentExport, + Frequency, + @SerializedName("Power.Active.Export") + PowerActiveExport, + @SerializedName("Power.Active.Import") + PowerActiveImport, + @SerializedName("Power.Factor") + PowerFactor, + @SerializedName("Power.Offered") + PowerOffered, + @SerializedName("Power.Reactive.Export") + PowerReactiveExport, + @SerializedName("Power.Reactive.Import") + PowerReactiveImport, + SoC, + Voltage +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageContent.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageContent.java new file mode 100644 index 000000000..551839f75 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageContent.java @@ -0,0 +1,258 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Message Content + * + *

Message details, for a message to be displayed on a Charging Station. + */ +public final class MessageContent { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Message Content. Format. Message Format Code + * + *

Format of the message. + */ + private MessageFormatEnum format; + + /** + * Message Content. Language. Language Code + * + *

Message language identifier. Contains a language code as defined in [RFC5646]. + */ + @Nullable private String language; + + /** + * Message Content. Content. Message + * + *

Message contents. + */ + private String content; + + /** + * Constructor for the MessageContent class + * + * @param format Format of the message. + * @param content Message contents. + */ + public MessageContent(MessageFormatEnum format, String content) { + setFormat(format); + setContent(content); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MessageContent withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets format of the message. + * + * @return Format of the message + */ + public MessageFormatEnum getFormat() { + return format; + } + + /** + * Sets format of the message. + * + * @param format Format of the message + */ + public void setFormat(MessageFormatEnum format) { + if (!isValidFormat(format)) { + throw new PropertyConstraintException(format, "format is invalid"); + } + this.format = format; + } + + /** + * Returns whether the given format is valid + * + * @param format the format to check the validity of + * @return {@code true} if format is valid, {@code false} if not + */ + private boolean isValidFormat(MessageFormatEnum format) { + return format != null; + } + + /** + * Gets message language identifier. Contains a language code as defined in [RFC5646]. + * + * @return Message language identifier + */ + @Nullable + public String getLanguage() { + return language; + } + + /** + * Sets message language identifier. Contains a language code as defined in [RFC5646]. + * + * @param language Message language identifier + */ + public void setLanguage(@Nullable String language) { + if (!isValidLanguage(language)) { + throw new PropertyConstraintException(language, "language is invalid"); + } + this.language = language; + } + + /** + * Returns whether the given language is valid + * + * @param language the language to check the validity of + * @return {@code true} if language is valid, {@code false} if not + */ + private boolean isValidLanguage(@Nullable String language) { + return language == null || language.length() <= 8; + } + + /** + * Adds message language identifier. Contains a language code as defined in [RFC5646]. + * + * @param language Message language identifier + * @return this + */ + public MessageContent withLanguage(@Nullable String language) { + setLanguage(language); + return this; + } + + /** + * Gets message contents. + * + * @return Message contents + */ + public String getContent() { + return content; + } + + /** + * Sets message contents. + * + * @param content Message contents + */ + public void setContent(String content) { + if (!isValidContent(content)) { + throw new PropertyConstraintException(content, "content is invalid"); + } + this.content = content; + } + + /** + * Returns whether the given content is valid + * + * @param content the content to check the validity of + * @return {@code true} if content is valid, {@code false} if not + */ + private boolean isValidContent(String content) { + return content != null && content.length() <= 512; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidFormat(format) + && isValidLanguage(language) + && isValidContent(content); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MessageContent that = (MessageContent) o; + return Objects.equals(customData, that.customData) + && Objects.equals(format, that.format) + && Objects.equals(language, that.language) + && Objects.equals(content, that.content); + } + + @Override + public int hashCode() { + return Objects.hash(customData, format, language, content); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("format", format) + .add("language", language) + .add("content", content) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageFormatEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageFormatEnum.java new file mode 100644 index 000000000..5129043bb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageFormatEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Message Content. Format. Message Format Code + * + *

Format of the message. + */ +public enum MessageFormatEnum { + ASCII, + HTML, + URI, + UTF8 +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageInfo.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageInfo.java new file mode 100644 index 000000000..48ab639e9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageInfo.java @@ -0,0 +1,494 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Message Info + * + *

Message details, for a message to be displayed on a Charging Station. + */ +public final class MessageInfo { + /** Custom data */ + @Nullable private CustomData customData; + + /** A physical or logical component */ + @Nullable private Component display; + + /** + * Identified Object. MRID. Numeric Identifier + * + *

Master resource identifier, unique within an exchange context. It is defined within the OCPP + * context as a positive Integer value (greater or equal to zero). + */ + private Integer id; + + /** + * Message Info. Priority. Message Priority Code + * + *

With what priority should this message be shown + */ + private MessagePriorityEnum priority; + + /** + * Message Info. State. Message State Code + * + *

During what state should this message be shown. When omitted this message should be shown in + * any state of the Charging Station. + */ + @Nullable private MessageStateEnum state; + + /** + * Message Info. Start. Date Time + * + *

From what date-time should this message be shown. If omitted: directly. + */ + @Nullable private ZonedDateTime startDateTime; + + /** + * Message Info. End. Date Time + * + *

Until what date-time should this message be shown, after this date/time this message SHALL + * be removed. + */ + @Nullable private ZonedDateTime endDateTime; + + /** + * During which transaction shall this message be shown. Message SHALL be removed by the Charging + * Station after transaction has ended. + */ + @Nullable private String transactionId; + + /** + * Message Content + * + *

Message details, for a message to be displayed on a Charging Station. + */ + private MessageContent message; + + /** + * Constructor for the MessageInfo class + * + * @param id Master resource identifier, unique within an exchange context. It is defined within + * the OCPP context as a positive Integer value (greater or equal to zero). + * @param priority With what priority should this message be shown + * @param message Message details, for a message to be displayed on a Charging Station. + */ + public MessageInfo(Integer id, MessagePriorityEnum priority, MessageContent message) { + setId(id); + setPriority(priority); + setMessage(message); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MessageInfo withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + @Nullable + public Component getDisplay() { + return display; + } + + /** + * Sets a physical or logical component + * + * @param display A physical or logical component + */ + public void setDisplay(@Nullable Component display) { + if (!isValidDisplay(display)) { + throw new PropertyConstraintException(display, "display is invalid"); + } + this.display = display; + } + + /** + * Returns whether the given display is valid + * + * @param display the display to check the validity of + * @return {@code true} if display is valid, {@code false} if not + */ + private boolean isValidDisplay(@Nullable Component display) { + return display == null || display.validate(); + } + + /** + * Adds a physical or logical component + * + * @param display A physical or logical component + * @return this + */ + public MessageInfo withDisplay(@Nullable Component display) { + setDisplay(display); + return this; + } + + /** + * Gets master resource identifier, unique within an exchange context. It is defined within the + * OCPP context as a positive Integer value (greater or equal to zero). + * + * @return Master resource identifier, unique within an exchange context + */ + public Integer getId() { + return id; + } + + /** + * Sets master resource identifier, unique within an exchange context. It is defined within the + * OCPP context as a positive Integer value (greater or equal to zero). + * + * @param id Master resource identifier, unique within an exchange context + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null; + } + + /** + * Gets with what priority should this message be shown + * + * @return With what priority should this message be shown + */ + public MessagePriorityEnum getPriority() { + return priority; + } + + /** + * Sets with what priority should this message be shown + * + * @param priority With what priority should this message be shown + */ + public void setPriority(MessagePriorityEnum priority) { + if (!isValidPriority(priority)) { + throw new PropertyConstraintException(priority, "priority is invalid"); + } + this.priority = priority; + } + + /** + * Returns whether the given priority is valid + * + * @param priority the priority to check the validity of + * @return {@code true} if priority is valid, {@code false} if not + */ + private boolean isValidPriority(MessagePriorityEnum priority) { + return priority != null; + } + + /** + * Gets during what state should this message be shown. When omitted this message should be shown + * in any state of the Charging Station. + * + * @return During what state should this message be shown + */ + @Nullable + public MessageStateEnum getState() { + return state; + } + + /** + * Sets during what state should this message be shown. When omitted this message should be shown + * in any state of the Charging Station. + * + * @param state During what state should this message be shown + */ + public void setState(@Nullable MessageStateEnum state) { + this.state = state; + } + + /** + * Adds during what state should this message be shown. When omitted this message should be shown + * in any state of the Charging Station. + * + * @param state During what state should this message be shown + * @return this + */ + public MessageInfo withState(@Nullable MessageStateEnum state) { + setState(state); + return this; + } + + /** + * Gets from what date-time should this message be shown. If omitted: directly. + * + * @return From what date-time should this message be shown + */ + @Nullable + public ZonedDateTime getStartDateTime() { + return startDateTime; + } + + /** + * Sets from what date-time should this message be shown. If omitted: directly. + * + * @param startDateTime From what date-time should this message be shown + */ + public void setStartDateTime(@Nullable ZonedDateTime startDateTime) { + this.startDateTime = startDateTime; + } + + /** + * Adds from what date-time should this message be shown. If omitted: directly. + * + * @param startDateTime From what date-time should this message be shown + * @return this + */ + public MessageInfo withStartDateTime(@Nullable ZonedDateTime startDateTime) { + setStartDateTime(startDateTime); + return this; + } + + /** + * Gets until what date-time should this message be shown, after this date/time this message SHALL + * be removed. + * + * @return Until what date-time should this message be shown, after this date/time this message + * SHALL be removed + */ + @Nullable + public ZonedDateTime getEndDateTime() { + return endDateTime; + } + + /** + * Sets until what date-time should this message be shown, after this date/time this message SHALL + * be removed. + * + * @param endDateTime Until what date-time should this message be shown, after this date/time this + * message SHALL be removed + */ + public void setEndDateTime(@Nullable ZonedDateTime endDateTime) { + this.endDateTime = endDateTime; + } + + /** + * Adds until what date-time should this message be shown, after this date/time this message SHALL + * be removed. + * + * @param endDateTime Until what date-time should this message be shown, after this date/time this + * message SHALL be removed + * @return this + */ + public MessageInfo withEndDateTime(@Nullable ZonedDateTime endDateTime) { + setEndDateTime(endDateTime); + return this; + } + + /** + * Gets during which transaction shall this message be shown. Message SHALL be removed by the + * Charging Station after transaction has ended. + * + * @return During which transaction shall this message be shown + */ + @Nullable + public String getTransactionId() { + return transactionId; + } + + /** + * Sets during which transaction shall this message be shown. Message SHALL be removed by the + * Charging Station after transaction has ended. + * + * @param transactionId During which transaction shall this message be shown + */ + public void setTransactionId(@Nullable String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(@Nullable String transactionId) { + return transactionId == null || transactionId.length() <= 36; + } + + /** + * Adds during which transaction shall this message be shown. Message SHALL be removed by the + * Charging Station after transaction has ended. + * + * @param transactionId During which transaction shall this message be shown + * @return this + */ + public MessageInfo withTransactionId(@Nullable String transactionId) { + setTransactionId(transactionId); + return this; + } + + /** + * Gets message details, for a message to be displayed on a Charging Station. + * + * @return Message details, for a message to be displayed on a Charging Station + */ + public MessageContent getMessage() { + return message; + } + + /** + * Sets message details, for a message to be displayed on a Charging Station. + * + * @param message Message details, for a message to be displayed on a Charging Station + */ + public void setMessage(MessageContent message) { + if (!isValidMessage(message)) { + throw new PropertyConstraintException(message, "message is invalid"); + } + this.message = message; + } + + /** + * Returns whether the given message is valid + * + * @param message the message to check the validity of + * @return {@code true} if message is valid, {@code false} if not + */ + private boolean isValidMessage(MessageContent message) { + return message != null && message.validate(); + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidDisplay(display) + && isValidId(id) + && isValidPriority(priority) + && isValidTransactionId(transactionId) + && isValidMessage(message); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MessageInfo that = (MessageInfo) o; + return Objects.equals(customData, that.customData) + && Objects.equals(display, that.display) + && Objects.equals(id, that.id) + && Objects.equals(priority, that.priority) + && Objects.equals(state, that.state) + && Objects.equals(startDateTime, that.startDateTime) + && Objects.equals(endDateTime, that.endDateTime) + && Objects.equals(transactionId, that.transactionId) + && Objects.equals(message, that.message); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + display, + id, + priority, + state, + startDateTime, + endDateTime, + transactionId, + message); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("display", display) + .add("id", id) + .add("priority", priority) + .add("state", state) + .add("startDateTime", startDateTime) + .add("endDateTime", endDateTime) + .add("transactionId", transactionId) + .add("message", message) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessagePriorityEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessagePriorityEnum.java new file mode 100644 index 000000000..9c4b70319 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessagePriorityEnum.java @@ -0,0 +1,36 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Message Info. Priority. Message Priority Code + * + *

With what priority should this message be shown + */ +public enum MessagePriorityEnum { + AlwaysFront, + InFront, + NormalCycle +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageStateEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageStateEnum.java new file mode 100644 index 000000000..d9b6aa884 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageStateEnum.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Message Info. State. Message State Code + * + *

During what state should this message be shown. When omitted this message should be shown in + * any state of the Charging Station. + */ +public enum MessageStateEnum { + Charging, + Faulted, + Idle, + Unavailable +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageTriggerEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageTriggerEnum.java new file mode 100644 index 000000000..693fa31ee --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MessageTriggerEnum.java @@ -0,0 +1,40 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Type of message to be triggered. */ +public enum MessageTriggerEnum { + BootNotification, + LogStatusNotification, + FirmwareStatusNotification, + Heartbeat, + MeterValues, + SignChargingStationCertificate, + SignV2GCertificate, + StatusNotification, + TransactionEvent, + SignCombinedCertificate, + PublishFirmwareStatusNotification +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MeterValue.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MeterValue.java new file mode 100644 index 000000000..1fbc13036 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MeterValue.java @@ -0,0 +1,215 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.time.ZonedDateTime; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Meter Value + * + *

Collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All + * sampled values in a MeterValue are sampled at the same point in time. + */ +public final class MeterValue { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Sampled Value + * + *

Single sampled value in MeterValues. Each value can be accompanied by optional fields. + * + *

To save on mobile data usage, default values of all of the optional fields are such that. + * The value without any additional fields will be interpreted, as a register reading of active + * import energy in Wh (Watt-hour) units. + */ + private SampledValue[] sampledValue; + + /** + * Meter Value. Timestamp. Date Time + * + *

Timestamp for measured value(s). + */ + private ZonedDateTime timestamp; + + /** + * Constructor for the MeterValue class + * + * @param sampledValue Single sampled value in MeterValues. Each value can be accompanied by + * optional fields. + * @param timestamp Timestamp for measured value(s). + */ + public MeterValue(SampledValue[] sampledValue, ZonedDateTime timestamp) { + setSampledValue(sampledValue); + setTimestamp(timestamp); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MeterValue withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets single sampled value in MeterValues. Each value can be accompanied by optional fields. + * + * @return Single sampled value in MeterValues + */ + public SampledValue[] getSampledValue() { + return sampledValue; + } + + /** + * Sets single sampled value in MeterValues. Each value can be accompanied by optional fields. + * + * @param sampledValue Single sampled value in MeterValues + */ + public void setSampledValue(SampledValue[] sampledValue) { + if (!isValidSampledValue(sampledValue)) { + throw new PropertyConstraintException(sampledValue, "sampledValue is invalid"); + } + this.sampledValue = sampledValue; + } + + /** + * Returns whether the given sampledValue is valid + * + * @param sampledValue the sampledValue to check the validity of + * @return {@code true} if sampledValue is valid, {@code false} if not + */ + private boolean isValidSampledValue(SampledValue[] sampledValue) { + return sampledValue != null + && sampledValue.length >= 1 + && Arrays.stream(sampledValue).allMatch(item -> item.validate()); + } + + /** + * Gets timestamp for measured value(s). + * + * @return Timestamp for measured value(s) + */ + public ZonedDateTime getTimestamp() { + return timestamp; + } + + /** + * Sets timestamp for measured value(s). + * + * @param timestamp Timestamp for measured value(s) + */ + public void setTimestamp(ZonedDateTime timestamp) { + if (!isValidTimestamp(timestamp)) { + throw new PropertyConstraintException(timestamp, "timestamp is invalid"); + } + this.timestamp = timestamp; + } + + /** + * Returns whether the given timestamp is valid + * + * @param timestamp the timestamp to check the validity of + * @return {@code true} if timestamp is valid, {@code false} if not + */ + private boolean isValidTimestamp(ZonedDateTime timestamp) { + return timestamp != null; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidSampledValue(sampledValue) + && isValidTimestamp(timestamp); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MeterValue that = (MeterValue) o; + return Objects.equals(customData, that.customData) + && Arrays.equals(sampledValue, that.sampledValue) + && Objects.equals(timestamp, that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash(customData, Arrays.hashCode(sampledValue), timestamp); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("sampledValue", sampledValue) + .add("timestamp", timestamp) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Modem.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Modem.java new file mode 100644 index 000000000..f3f6650b0 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Modem.java @@ -0,0 +1,219 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Wireless Communication Module + * + *

Parameters required for initiating and maintaining wireless communication with other devices. + */ +public final class Modem { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Wireless Communication Module. ICCID. CI20 Text + * + *

The ICCID of the modem’s SIM card. + */ + @Nullable private String iccid; + + /** + * Wireless Communication Module. IMSI. CI20 Text + * + *

The IMSI of the modem’s SIM card. + */ + @Nullable private String imsi; + + /** Constructor for the Modem class */ + public Modem() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Modem withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the ICCID of the modem’s SIM card. + * + * @return The ICCID of the modem’s SIM card + */ + @Nullable + public String getIccid() { + return iccid; + } + + /** + * Sets the ICCID of the modem’s SIM card. + * + * @param iccid The ICCID of the modem’s SIM card + */ + public void setIccid(@Nullable String iccid) { + if (!isValidIccid(iccid)) { + throw new PropertyConstraintException(iccid, "iccid is invalid"); + } + this.iccid = iccid; + } + + /** + * Returns whether the given iccid is valid + * + * @param iccid the iccid to check the validity of + * @return {@code true} if iccid is valid, {@code false} if not + */ + private boolean isValidIccid(@Nullable String iccid) { + return iccid == null || iccid.length() <= 20; + } + + /** + * Adds the ICCID of the modem’s SIM card. + * + * @param iccid The ICCID of the modem’s SIM card + * @return this + */ + public Modem withIccid(@Nullable String iccid) { + setIccid(iccid); + return this; + } + + /** + * Gets the IMSI of the modem’s SIM card. + * + * @return The IMSI of the modem’s SIM card + */ + @Nullable + public String getImsi() { + return imsi; + } + + /** + * Sets the IMSI of the modem’s SIM card. + * + * @param imsi The IMSI of the modem’s SIM card + */ + public void setImsi(@Nullable String imsi) { + if (!isValidImsi(imsi)) { + throw new PropertyConstraintException(imsi, "imsi is invalid"); + } + this.imsi = imsi; + } + + /** + * Returns whether the given imsi is valid + * + * @param imsi the imsi to check the validity of + * @return {@code true} if imsi is valid, {@code false} if not + */ + private boolean isValidImsi(@Nullable String imsi) { + return imsi == null || imsi.length() <= 20; + } + + /** + * Adds the IMSI of the modem’s SIM card. + * + * @param imsi The IMSI of the modem’s SIM card + * @return this + */ + public Modem withImsi(@Nullable String imsi) { + setImsi(imsi); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) && isValidIccid(iccid) && isValidImsi(imsi); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Modem that = (Modem) o; + return Objects.equals(customData, that.customData) + && Objects.equals(iccid, that.iccid) + && Objects.equals(imsi, that.imsi); + } + + @Override + public int hashCode() { + return Objects.hash(customData, iccid, imsi); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("iccid", iccid) + .add("imsi", imsi) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitorEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitorEnum.java new file mode 100644 index 000000000..a0287495c --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitorEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The type of this monitor, e.g. a threshold, delta or periodic monitor. */ +public enum MonitorEnum { + UpperThreshold, + LowerThreshold, + Delta, + Periodic, + PeriodicClockAligned +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitoringBaseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitoringBaseEnum.java new file mode 100644 index 000000000..334b08c21 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitoringBaseEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Specify which monitoring base will be set */ +public enum MonitoringBaseEnum { + All, + FactoryDefault, + HardWiredOnly +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitoringCriterionEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitoringCriterionEnum.java new file mode 100644 index 000000000..2fbe523f4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitoringCriterionEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** MonitoringCriterionEnumType */ +public enum MonitoringCriterionEnum { + ThresholdMonitoring, + DeltaMonitoring, + PeriodicMonitoring +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitoringData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitoringData.java new file mode 100644 index 000000000..ed06cdbe8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MonitoringData.java @@ -0,0 +1,236 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to hold parameters of SetVariableMonitoring request. */ +public final class MonitoringData { + /** Custom data */ + @Nullable private CustomData customData; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** A monitoring setting for a variable. */ + private VariableMonitoring[] variableMonitoring; + + /** + * Constructor for the MonitoringData class + * + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + * @param variableMonitoring A monitoring setting for a variable. + */ + public MonitoringData( + Component component, Variable variable, VariableMonitoring[] variableMonitoring) { + setComponent(component); + setVariable(variable); + setVariableMonitoring(variableMonitoring); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public MonitoringData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets a monitoring setting for a variable. + * + * @return A monitoring setting for a variable + */ + public VariableMonitoring[] getVariableMonitoring() { + return variableMonitoring; + } + + /** + * Sets a monitoring setting for a variable. + * + * @param variableMonitoring A monitoring setting for a variable + */ + public void setVariableMonitoring(VariableMonitoring[] variableMonitoring) { + if (!isValidVariableMonitoring(variableMonitoring)) { + throw new PropertyConstraintException(variableMonitoring, "variableMonitoring is invalid"); + } + this.variableMonitoring = variableMonitoring; + } + + /** + * Returns whether the given variableMonitoring is valid + * + * @param variableMonitoring the variableMonitoring to check the validity of + * @return {@code true} if variableMonitoring is valid, {@code false} if not + */ + private boolean isValidVariableMonitoring(VariableMonitoring[] variableMonitoring) { + return variableMonitoring != null + && variableMonitoring.length >= 1 + && Arrays.stream(variableMonitoring).allMatch(item -> item.validate()); + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidComponent(component) + && isValidVariable(variable) + && isValidVariableMonitoring(variableMonitoring); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MonitoringData that = (MonitoringData) o; + return Objects.equals(customData, that.customData) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Arrays.equals(variableMonitoring, that.variableMonitoring); + } + + @Override + public int hashCode() { + return Objects.hash(customData, component, variable, Arrays.hashCode(variableMonitoring)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("component", component) + .add("variable", variable) + .add("variableMonitoring", variableMonitoring) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MutabilityEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MutabilityEnum.java new file mode 100644 index 000000000..b6714f6ee --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/MutabilityEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The mutability of this attribute. Default is ReadWrite when omitted. */ +public enum MutabilityEnum { + ReadOnly, + WriteOnly, + ReadWrite +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/NetworkConnectionProfile.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/NetworkConnectionProfile.java new file mode 100644 index 000000000..8ed816d2a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/NetworkConnectionProfile.java @@ -0,0 +1,518 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Communication Function + * + *

The NetworkConnectionProfile defines the functional and technical parameters of a + * communication link. + */ +public final class NetworkConnectionProfile { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * APN + * + *

Collection of configuration data needed to make a data-connection over a cellular network. + * + *

NOTE: When asking a GSM modem to dial in, it is possible to specify which mobile operator + * should be used. This can be done with the mobile country code (MCC) in combination with a + * mobile network code (MNC). Example: If your preferred network is Vodafone Netherlands, the + * MCC=204 and the MNC=04 which means the key PreferredNetwork = 20404 Some modems allows to + * specify a preferred network, which means, if this network is not available, a different network + * is used. If you specify UseOnlyPreferredNetwork and this network is not available, the modem + * will not dial in. + */ + @Nullable private APN apn; + + /** + * Communication Function. OCPP Version. OCPP Version Code + * + *

The OCPP version used for this communication function. + */ + private OCPPVersionEnum ocppVersion; + + /** + * Communication Function. OCPP Transport. OCPP Transport Code + * + *

The transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in OCPP 2.0, but is + * supported by other versions of OCPP. + */ + private OCPPTransportEnum ocppTransport; + + /** + * Communication Function. OCPP Central System URL. URI + * + *

URL of the CSMS(s) that this Charging Station communicates with. + */ + private String ocppCsmsUrl; + + /** + * Duration in seconds before a message send by the Charging Station via this network connection + * times-out. The best setting depends on the underlying network and response times of the CSMS. + * If you are looking for a some guideline: use 30 seconds as a starting point. + */ + private Integer messageTimeout; + + /** The security profile used when connecting to the CSMS with this NetworkConnectionProfile. */ + private Integer securityProfile; + + /** Applicable Network Interface. */ + private OCPPInterfaceEnum ocppInterface; + + /** + * VPN + * + *

VPN Configuration settings + */ + @Nullable private VPN vpn; + + /** + * Constructor for the NetworkConnectionProfile class + * + * @param ocppVersion The OCPP version used for this communication function. + * @param ocppTransport The transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in + * OCPP 2.0, but is supported by other versions of OCPP. + * @param ocppCsmsUrl URL of the CSMS(s) that this Charging Station communicates with. + * @param messageTimeout Duration in seconds before a message send by the Charging Station via + * this network connection times-out. The best setting depends on the underlying network and + * response times of the CSMS. If you are looking for a some guideline: use 30 seconds as a + * starting point. + * @param securityProfile The security profile used when connecting to the CSMS with this + * NetworkConnectionProfile. + * @param ocppInterface Applicable Network Interface. + */ + public NetworkConnectionProfile( + OCPPVersionEnum ocppVersion, + OCPPTransportEnum ocppTransport, + String ocppCsmsUrl, + Integer messageTimeout, + Integer securityProfile, + OCPPInterfaceEnum ocppInterface) { + setOcppVersion(ocppVersion); + setOcppTransport(ocppTransport); + setOcppCsmsUrl(ocppCsmsUrl); + setMessageTimeout(messageTimeout); + setSecurityProfile(securityProfile); + setOcppInterface(ocppInterface); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public NetworkConnectionProfile withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets collection of configuration data needed to make a data-connection over a cellular network. + * + * @return Collection of configuration data needed to make a data-connection over a cellular + * network + */ + @Nullable + public APN getApn() { + return apn; + } + + /** + * Sets collection of configuration data needed to make a data-connection over a cellular network. + * + * @param apn Collection of configuration data needed to make a data-connection over a cellular + * network + */ + public void setApn(@Nullable APN apn) { + if (!isValidApn(apn)) { + throw new PropertyConstraintException(apn, "apn is invalid"); + } + this.apn = apn; + } + + /** + * Returns whether the given apn is valid + * + * @param apn the apn to check the validity of + * @return {@code true} if apn is valid, {@code false} if not + */ + private boolean isValidApn(@Nullable APN apn) { + return apn == null || apn.validate(); + } + + /** + * Adds collection of configuration data needed to make a data-connection over a cellular network. + * + * @param apn Collection of configuration data needed to make a data-connection over a cellular + * network + * @return this + */ + public NetworkConnectionProfile withApn(@Nullable APN apn) { + setApn(apn); + return this; + } + + /** + * Gets the OCPP version used for this communication function. + * + * @return The OCPP version used for this communication function + */ + public OCPPVersionEnum getOcppVersion() { + return ocppVersion; + } + + /** + * Sets the OCPP version used for this communication function. + * + * @param ocppVersion The OCPP version used for this communication function + */ + public void setOcppVersion(OCPPVersionEnum ocppVersion) { + if (!isValidOcppVersion(ocppVersion)) { + throw new PropertyConstraintException(ocppVersion, "ocppVersion is invalid"); + } + this.ocppVersion = ocppVersion; + } + + /** + * Returns whether the given ocppVersion is valid + * + * @param ocppVersion the ocppVersion to check the validity of + * @return {@code true} if ocppVersion is valid, {@code false} if not + */ + private boolean isValidOcppVersion(OCPPVersionEnum ocppVersion) { + return ocppVersion != null; + } + + /** + * Gets the transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in OCPP 2.0, but + * is supported by other versions of OCPP. + * + * @return The transport protocol (e.g. SOAP or JSON) + */ + public OCPPTransportEnum getOcppTransport() { + return ocppTransport; + } + + /** + * Sets the transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in OCPP 2.0, but + * is supported by other versions of OCPP. + * + * @param ocppTransport The transport protocol (e.g. SOAP or JSON) + */ + public void setOcppTransport(OCPPTransportEnum ocppTransport) { + if (!isValidOcppTransport(ocppTransport)) { + throw new PropertyConstraintException(ocppTransport, "ocppTransport is invalid"); + } + this.ocppTransport = ocppTransport; + } + + /** + * Returns whether the given ocppTransport is valid + * + * @param ocppTransport the ocppTransport to check the validity of + * @return {@code true} if ocppTransport is valid, {@code false} if not + */ + private boolean isValidOcppTransport(OCPPTransportEnum ocppTransport) { + return ocppTransport != null; + } + + /** + * Gets URL of the CSMS(s) that this Charging Station communicates with. + * + * @return URL of the CSMS(s) that this Charging Station communicates with + */ + public String getOcppCsmsUrl() { + return ocppCsmsUrl; + } + + /** + * Sets URL of the CSMS(s) that this Charging Station communicates with. + * + * @param ocppCsmsUrl URL of the CSMS(s) that this Charging Station communicates with + */ + public void setOcppCsmsUrl(String ocppCsmsUrl) { + if (!isValidOcppCsmsUrl(ocppCsmsUrl)) { + throw new PropertyConstraintException(ocppCsmsUrl, "ocppCsmsUrl is invalid"); + } + this.ocppCsmsUrl = ocppCsmsUrl; + } + + /** + * Returns whether the given ocppCsmsUrl is valid + * + * @param ocppCsmsUrl the ocppCsmsUrl to check the validity of + * @return {@code true} if ocppCsmsUrl is valid, {@code false} if not + */ + private boolean isValidOcppCsmsUrl(String ocppCsmsUrl) { + return ocppCsmsUrl != null && ocppCsmsUrl.length() <= 512; + } + + /** + * Gets duration in seconds before a message send by the Charging Station via this network + * connection times-out. The best setting depends on the underlying network and response times of + * the CSMS. If you are looking for a some guideline: use 30 seconds as a starting point. + * + * @return Duration in seconds before a message send by the Charging Station via this network + * connection times-out + */ + public Integer getMessageTimeout() { + return messageTimeout; + } + + /** + * Sets duration in seconds before a message send by the Charging Station via this network + * connection times-out. The best setting depends on the underlying network and response times of + * the CSMS. If you are looking for a some guideline: use 30 seconds as a starting point. + * + * @param messageTimeout Duration in seconds before a message send by the Charging Station via + * this network connection times-out + */ + public void setMessageTimeout(Integer messageTimeout) { + if (!isValidMessageTimeout(messageTimeout)) { + throw new PropertyConstraintException(messageTimeout, "messageTimeout is invalid"); + } + this.messageTimeout = messageTimeout; + } + + /** + * Returns whether the given messageTimeout is valid + * + * @param messageTimeout the messageTimeout to check the validity of + * @return {@code true} if messageTimeout is valid, {@code false} if not + */ + private boolean isValidMessageTimeout(Integer messageTimeout) { + return messageTimeout != null; + } + + /** + * Gets the security profile used when connecting to the CSMS with this NetworkConnectionProfile. + * + * @return The security profile used when connecting to the CSMS with this + * NetworkConnectionProfile + */ + public Integer getSecurityProfile() { + return securityProfile; + } + + /** + * Sets the security profile used when connecting to the CSMS with this NetworkConnectionProfile. + * + * @param securityProfile The security profile used when connecting to the CSMS with this + * NetworkConnectionProfile + */ + public void setSecurityProfile(Integer securityProfile) { + if (!isValidSecurityProfile(securityProfile)) { + throw new PropertyConstraintException(securityProfile, "securityProfile is invalid"); + } + this.securityProfile = securityProfile; + } + + /** + * Returns whether the given securityProfile is valid + * + * @param securityProfile the securityProfile to check the validity of + * @return {@code true} if securityProfile is valid, {@code false} if not + */ + private boolean isValidSecurityProfile(Integer securityProfile) { + return securityProfile != null; + } + + /** + * Gets applicable Network Interface. + * + * @return Applicable Network Interface + */ + public OCPPInterfaceEnum getOcppInterface() { + return ocppInterface; + } + + /** + * Sets applicable Network Interface. + * + * @param ocppInterface Applicable Network Interface + */ + public void setOcppInterface(OCPPInterfaceEnum ocppInterface) { + if (!isValidOcppInterface(ocppInterface)) { + throw new PropertyConstraintException(ocppInterface, "ocppInterface is invalid"); + } + this.ocppInterface = ocppInterface; + } + + /** + * Returns whether the given ocppInterface is valid + * + * @param ocppInterface the ocppInterface to check the validity of + * @return {@code true} if ocppInterface is valid, {@code false} if not + */ + private boolean isValidOcppInterface(OCPPInterfaceEnum ocppInterface) { + return ocppInterface != null; + } + + /** + * Gets VPN Configuration settings + * + * @return VPN Configuration settings + */ + @Nullable + public VPN getVpn() { + return vpn; + } + + /** + * Sets VPN Configuration settings + * + * @param vpn VPN Configuration settings + */ + public void setVpn(@Nullable VPN vpn) { + if (!isValidVpn(vpn)) { + throw new PropertyConstraintException(vpn, "vpn is invalid"); + } + this.vpn = vpn; + } + + /** + * Returns whether the given vpn is valid + * + * @param vpn the vpn to check the validity of + * @return {@code true} if vpn is valid, {@code false} if not + */ + private boolean isValidVpn(@Nullable VPN vpn) { + return vpn == null || vpn.validate(); + } + + /** + * Adds VPN Configuration settings + * + * @param vpn VPN Configuration settings + * @return this + */ + public NetworkConnectionProfile withVpn(@Nullable VPN vpn) { + setVpn(vpn); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidApn(apn) + && isValidOcppVersion(ocppVersion) + && isValidOcppTransport(ocppTransport) + && isValidOcppCsmsUrl(ocppCsmsUrl) + && isValidMessageTimeout(messageTimeout) + && isValidSecurityProfile(securityProfile) + && isValidOcppInterface(ocppInterface) + && isValidVpn(vpn); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NetworkConnectionProfile that = (NetworkConnectionProfile) o; + return Objects.equals(customData, that.customData) + && Objects.equals(apn, that.apn) + && Objects.equals(ocppVersion, that.ocppVersion) + && Objects.equals(ocppTransport, that.ocppTransport) + && Objects.equals(ocppCsmsUrl, that.ocppCsmsUrl) + && Objects.equals(messageTimeout, that.messageTimeout) + && Objects.equals(securityProfile, that.securityProfile) + && Objects.equals(ocppInterface, that.ocppInterface) + && Objects.equals(vpn, that.vpn); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + apn, + ocppVersion, + ocppTransport, + ocppCsmsUrl, + messageTimeout, + securityProfile, + ocppInterface, + vpn); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("apn", apn) + .add("ocppVersion", ocppVersion) + .add("ocppTransport", ocppTransport) + .add("ocppCsmsUrl", ocppCsmsUrl) + .add("messageTimeout", messageTimeout) + .add("securityProfile", securityProfile) + .add("ocppInterface", ocppInterface) + .add("vpn", vpn) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/NotifyEVChargingNeedsStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/NotifyEVChargingNeedsStatusEnum.java new file mode 100644 index 000000000..00322e886 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/NotifyEVChargingNeedsStatusEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Returns whether the CSMS has been able to process the message successfully. It does not imply + * that the evChargingNeeds can be met with the current charging profile. + */ +public enum NotifyEVChargingNeedsStatusEnum { + Accepted, + Rejected, + Processing +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCPPInterfaceEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCPPInterfaceEnum.java new file mode 100644 index 000000000..b75c527db --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCPPInterfaceEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Applicable Network Interface. */ +public enum OCPPInterfaceEnum { + Wired0, + Wired1, + Wired2, + Wired3, + Wireless0, + Wireless1, + Wireless2, + Wireless3 +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCPPTransportEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCPPTransportEnum.java new file mode 100644 index 000000000..bc00a5512 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCPPTransportEnum.java @@ -0,0 +1,36 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Communication Function. OCPP Transport. OCPP Transport Code + * + *

The transport protocol (e.g. SOAP or JSON). Note: SOAP is not supported in OCPP 2.0, but is + * supported by other versions of OCPP. + */ +public enum OCPPTransportEnum { + JSON, + SOAP +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCPPVersionEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCPPVersionEnum.java new file mode 100644 index 000000000..6ff685ec1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCPPVersionEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Communication Function. OCPP Version. OCPP Version Code + * + *

The OCPP version used for this communication function. + */ +public enum OCPPVersionEnum { + OCPP12, + OCPP15, + OCPP16, + OCPP20 +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCSPRequestData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCSPRequestData.java new file mode 100644 index 000000000..a46c7908d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OCSPRequestData.java @@ -0,0 +1,316 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** OCSPRequestDataType */ +public final class OCSPRequestData { + /** Custom data */ + @Nullable private CustomData customData; + + /** Used algorithms for the hashes provided. */ + private HashAlgorithmEnum hashAlgorithm; + + /** Hashed value of the Issuer DN (Distinguished Name). */ + private String issuerNameHash; + + /** Hashed value of the issuers public key */ + private String issuerKeyHash; + + /** The serial number of the certificate. */ + private String serialNumber; + + /** The responder URL (Case insensitive). */ + private String responderURL; + + /** + * Constructor for the OCSPRequestData class + * + * @param hashAlgorithm Used algorithms for the hashes provided. + * @param issuerNameHash Hashed value of the Issuer DN (Distinguished Name). + * @param issuerKeyHash Hashed value of the issuers public key + * @param serialNumber The serial number of the certificate. + * @param responderURL The responder URL (Case insensitive). + */ + public OCSPRequestData( + HashAlgorithmEnum hashAlgorithm, + String issuerNameHash, + String issuerKeyHash, + String serialNumber, + String responderURL) { + setHashAlgorithm(hashAlgorithm); + setIssuerNameHash(issuerNameHash); + setIssuerKeyHash(issuerKeyHash); + setSerialNumber(serialNumber); + setResponderURL(responderURL); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public OCSPRequestData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets used algorithms for the hashes provided. + * + * @return Used algorithms for the hashes provided + */ + public HashAlgorithmEnum getHashAlgorithm() { + return hashAlgorithm; + } + + /** + * Sets used algorithms for the hashes provided. + * + * @param hashAlgorithm Used algorithms for the hashes provided + */ + public void setHashAlgorithm(HashAlgorithmEnum hashAlgorithm) { + if (!isValidHashAlgorithm(hashAlgorithm)) { + throw new PropertyConstraintException(hashAlgorithm, "hashAlgorithm is invalid"); + } + this.hashAlgorithm = hashAlgorithm; + } + + /** + * Returns whether the given hashAlgorithm is valid + * + * @param hashAlgorithm the hashAlgorithm to check the validity of + * @return {@code true} if hashAlgorithm is valid, {@code false} if not + */ + private boolean isValidHashAlgorithm(HashAlgorithmEnum hashAlgorithm) { + return hashAlgorithm != null; + } + + /** + * Gets hashed value of the Issuer DN (Distinguished Name). + * + * @return Hashed value of the Issuer DN (Distinguished Name) + */ + public String getIssuerNameHash() { + return issuerNameHash; + } + + /** + * Sets hashed value of the Issuer DN (Distinguished Name). + * + * @param issuerNameHash Hashed value of the Issuer DN (Distinguished Name) + */ + public void setIssuerNameHash(String issuerNameHash) { + if (!isValidIssuerNameHash(issuerNameHash)) { + throw new PropertyConstraintException(issuerNameHash, "issuerNameHash is invalid"); + } + this.issuerNameHash = issuerNameHash; + } + + /** + * Returns whether the given issuerNameHash is valid + * + * @param issuerNameHash the issuerNameHash to check the validity of + * @return {@code true} if issuerNameHash is valid, {@code false} if not + */ + private boolean isValidIssuerNameHash(String issuerNameHash) { + return issuerNameHash != null && issuerNameHash.length() <= 128; + } + + /** + * Gets hashed value of the issuers public key + * + * @return Hashed value of the issuers public key + */ + public String getIssuerKeyHash() { + return issuerKeyHash; + } + + /** + * Sets hashed value of the issuers public key + * + * @param issuerKeyHash Hashed value of the issuers public key + */ + public void setIssuerKeyHash(String issuerKeyHash) { + if (!isValidIssuerKeyHash(issuerKeyHash)) { + throw new PropertyConstraintException(issuerKeyHash, "issuerKeyHash is invalid"); + } + this.issuerKeyHash = issuerKeyHash; + } + + /** + * Returns whether the given issuerKeyHash is valid + * + * @param issuerKeyHash the issuerKeyHash to check the validity of + * @return {@code true} if issuerKeyHash is valid, {@code false} if not + */ + private boolean isValidIssuerKeyHash(String issuerKeyHash) { + return issuerKeyHash != null && issuerKeyHash.length() <= 128; + } + + /** + * Gets the serial number of the certificate. + * + * @return The serial number of the certificate + */ + public String getSerialNumber() { + return serialNumber; + } + + /** + * Sets the serial number of the certificate. + * + * @param serialNumber The serial number of the certificate + */ + public void setSerialNumber(String serialNumber) { + if (!isValidSerialNumber(serialNumber)) { + throw new PropertyConstraintException(serialNumber, "serialNumber is invalid"); + } + this.serialNumber = serialNumber; + } + + /** + * Returns whether the given serialNumber is valid + * + * @param serialNumber the serialNumber to check the validity of + * @return {@code true} if serialNumber is valid, {@code false} if not + */ + private boolean isValidSerialNumber(String serialNumber) { + return serialNumber != null && serialNumber.length() <= 40; + } + + /** + * Gets the responder URL (Case insensitive). + * + * @return The responder URL (Case insensitive) + */ + public String getResponderURL() { + return responderURL; + } + + /** + * Sets the responder URL (Case insensitive). + * + * @param responderURL The responder URL (Case insensitive) + */ + public void setResponderURL(String responderURL) { + if (!isValidResponderURL(responderURL)) { + throw new PropertyConstraintException(responderURL, "responderURL is invalid"); + } + this.responderURL = responderURL; + } + + /** + * Returns whether the given responderURL is valid + * + * @param responderURL the responderURL to check the validity of + * @return {@code true} if responderURL is valid, {@code false} if not + */ + private boolean isValidResponderURL(String responderURL) { + return responderURL != null && responderURL.length() <= 512; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidHashAlgorithm(hashAlgorithm) + && isValidIssuerNameHash(issuerNameHash) + && isValidIssuerKeyHash(issuerKeyHash) + && isValidSerialNumber(serialNumber) + && isValidResponderURL(responderURL); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OCSPRequestData that = (OCSPRequestData) o; + return Objects.equals(customData, that.customData) + && Objects.equals(hashAlgorithm, that.hashAlgorithm) + && Objects.equals(issuerNameHash, that.issuerNameHash) + && Objects.equals(issuerKeyHash, that.issuerKeyHash) + && Objects.equals(serialNumber, that.serialNumber) + && Objects.equals(responderURL, that.responderURL); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, hashAlgorithm, issuerNameHash, issuerKeyHash, serialNumber, responderURL); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("hashAlgorithm", hashAlgorithm) + .add("issuerNameHash", issuerNameHash) + .add("issuerKeyHash", issuerKeyHash) + .add("serialNumber", serialNumber) + .add("responderURL", responderURL) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OperationalStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OperationalStatusEnum.java new file mode 100644 index 000000000..22dab92d8 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/OperationalStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The type of availability change that the Charging Station should perform. */ +public enum OperationalStatusEnum { + Inoperative, + Operative +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/PhaseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/PhaseEnum.java new file mode 100644 index 000000000..9c0f6fd10 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/PhaseEnum.java @@ -0,0 +1,53 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import com.google.gson.annotations.SerializedName; + +/** + * Sampled Value. Phase. Phase Code + * + *

How the measured value is to be interpreted. For instance between L1 and neutral (L1-N) Please + * note that not all values of phase are applicable to all Measurands. When phase is absent, the + * measured value is interpreted as an overall value. + */ +public enum PhaseEnum { + L1, + L2, + L3, + N, + @SerializedName("L1-N") + L1_N, + @SerializedName("L2-N") + L2_N, + @SerializedName("L3-N") + L3_N, + @SerializedName("L1-L2") + L1_L2, + @SerializedName("L2-L3") + L2_L3, + @SerializedName("L3-L1") + L3_L1 +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/PublishFirmwareStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/PublishFirmwareStatusEnum.java new file mode 100644 index 000000000..6d450642f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/PublishFirmwareStatusEnum.java @@ -0,0 +1,39 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The progress status of the publishfirmware installation. */ +public enum PublishFirmwareStatusEnum { + Idle, + DownloadScheduled, + Downloading, + Downloaded, + Published, + DownloadFailed, + DownloadPaused, + InvalidChecksum, + ChecksumVerified, + PublishFailed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReadingContextEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReadingContextEnum.java new file mode 100644 index 000000000..d5f107835 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReadingContextEnum.java @@ -0,0 +1,49 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import com.google.gson.annotations.SerializedName; + +/** + * Sampled Value. Context. Reading Context Code + * + *

Type of detail value: start, end or sample. Default = "Sample.Periodic" + */ +public enum ReadingContextEnum { + @SerializedName("Interruption.Begin") + InterruptionBegin, + @SerializedName("Interruption.End") + InterruptionEnd, + Other, + @SerializedName("Sample.Clock") + SampleClock, + @SerializedName("Sample.Periodic") + SamplePeriodic, + @SerializedName("Transaction.Begin") + TransactionBegin, + @SerializedName("Transaction.End") + TransactionEnd, + Trigger +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReasonEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReasonEnum.java new file mode 100644 index 000000000..eb35b8243 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReasonEnum.java @@ -0,0 +1,52 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Transaction. Stopped Reason. EOT Reason Code + * + *

The reason why the transaction was stopped. MAY only be omitted when Reason is "Local". + */ +public enum ReasonEnum { + DeAuthorized, + EmergencyStop, + EnergyLimitReached, + EVDisconnected, + GroundFault, + ImmediateReset, + Local, + LocalOutOfCredit, + MasterPass, + Other, + OvercurrentFault, + PowerLoss, + PowerQuality, + Reboot, + Remote, + SOCLimitReached, + StoppedByEV, + TimeLimitReached, + Timeout +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RecurrencyKindEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RecurrencyKindEnum.java new file mode 100644 index 000000000..ad8b184ae --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RecurrencyKindEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Charging Profile. Recurrency Kind. Recurrency Kind Code + * + *

The start point of a recurrence. + */ +public enum RecurrencyKindEnum { + Daily, + Weekly +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RegistrationStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RegistrationStatusEnum.java new file mode 100644 index 000000000..30f45fc52 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RegistrationStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the Charging Station has been registered within the CSMS. */ +public enum RegistrationStatusEnum { + Accepted, + Pending, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RelativeTimeInterval.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RelativeTimeInterval.java new file mode 100644 index 000000000..21b1dc39f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RelativeTimeInterval.java @@ -0,0 +1,196 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Relative Timer Interval */ +public final class RelativeTimeInterval { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Relative Timer Interval. Start. Elapsed Time + * + *

Start of the interval, in seconds from NOW. + */ + private Integer start; + + /** + * Relative Timer Interval. Duration. Elapsed Time + * + *

Duration of the interval, in seconds. + */ + @Nullable private Integer duration; + + /** + * Constructor for the RelativeTimeInterval class + * + * @param start Start of the interval, in seconds from NOW. + */ + public RelativeTimeInterval(Integer start) { + setStart(start); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public RelativeTimeInterval withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets start of the interval, in seconds from NOW. + * + * @return Start of the interval, in seconds from NOW + */ + public Integer getStart() { + return start; + } + + /** + * Sets start of the interval, in seconds from NOW. + * + * @param start Start of the interval, in seconds from NOW + */ + public void setStart(Integer start) { + if (!isValidStart(start)) { + throw new PropertyConstraintException(start, "start is invalid"); + } + this.start = start; + } + + /** + * Returns whether the given start is valid + * + * @param start the start to check the validity of + * @return {@code true} if start is valid, {@code false} if not + */ + private boolean isValidStart(Integer start) { + return start != null; + } + + /** + * Gets duration of the interval, in seconds. + * + * @return Duration of the interval, in seconds + */ + @Nullable + public Integer getDuration() { + return duration; + } + + /** + * Sets duration of the interval, in seconds. + * + * @param duration Duration of the interval, in seconds + */ + public void setDuration(@Nullable Integer duration) { + this.duration = duration; + } + + /** + * Adds duration of the interval, in seconds. + * + * @param duration Duration of the interval, in seconds + * @return this + */ + public RelativeTimeInterval withDuration(@Nullable Integer duration) { + setDuration(duration); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) && isValidStart(start); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RelativeTimeInterval that = (RelativeTimeInterval) o; + return Objects.equals(customData, that.customData) + && Objects.equals(start, that.start) + && Objects.equals(duration, that.duration); + } + + @Override + public int hashCode() { + return Objects.hash(customData, start, duration); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("start", start) + .add("duration", duration) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReportBaseEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReportBaseEnum.java new file mode 100644 index 000000000..fe30d64a4 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReportBaseEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The report base. */ +public enum ReportBaseEnum { + ConfigurationInventory, + FullInventory, + SummaryInventory +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReportData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReportData.java new file mode 100644 index 000000000..f45e82ce3 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReportData.java @@ -0,0 +1,294 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to report components, variables and variable attributes and characteristics. */ +public final class ReportData { + /** Custom data */ + @Nullable private CustomData customData; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** Attribute data of a variable. */ + private VariableAttribute[] variableAttribute; + + /** Fixed read-only parameters of a variable. */ + @Nullable private VariableCharacteristics variableCharacteristics; + + /** + * Constructor for the ReportData class + * + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + * @param variableAttribute Attribute data of a variable. + */ + public ReportData(Component component, Variable variable, VariableAttribute[] variableAttribute) { + setComponent(component); + setVariable(variable); + setVariableAttribute(variableAttribute); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public ReportData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets attribute data of a variable. + * + * @return Attribute data of a variable + */ + public VariableAttribute[] getVariableAttribute() { + return variableAttribute; + } + + /** + * Sets attribute data of a variable. + * + * @param variableAttribute Attribute data of a variable + */ + public void setVariableAttribute(VariableAttribute[] variableAttribute) { + if (!isValidVariableAttribute(variableAttribute)) { + throw new PropertyConstraintException(variableAttribute, "variableAttribute is invalid"); + } + this.variableAttribute = variableAttribute; + } + + /** + * Returns whether the given variableAttribute is valid + * + * @param variableAttribute the variableAttribute to check the validity of + * @return {@code true} if variableAttribute is valid, {@code false} if not + */ + private boolean isValidVariableAttribute(VariableAttribute[] variableAttribute) { + return variableAttribute != null + && variableAttribute.length >= 1 + && variableAttribute.length <= 4 + && Arrays.stream(variableAttribute).allMatch(item -> item.validate()); + } + + /** + * Gets fixed read-only parameters of a variable. + * + * @return Fixed read-only parameters of a variable + */ + @Nullable + public VariableCharacteristics getVariableCharacteristics() { + return variableCharacteristics; + } + + /** + * Sets fixed read-only parameters of a variable. + * + * @param variableCharacteristics Fixed read-only parameters of a variable + */ + public void setVariableCharacteristics( + @Nullable VariableCharacteristics variableCharacteristics) { + if (!isValidVariableCharacteristics(variableCharacteristics)) { + throw new PropertyConstraintException( + variableCharacteristics, "variableCharacteristics is invalid"); + } + this.variableCharacteristics = variableCharacteristics; + } + + /** + * Returns whether the given variableCharacteristics is valid + * + * @param variableCharacteristics the variableCharacteristics to check the validity of + * @return {@code true} if variableCharacteristics is valid, {@code false} if not + */ + private boolean isValidVariableCharacteristics( + @Nullable VariableCharacteristics variableCharacteristics) { + return variableCharacteristics == null || variableCharacteristics.validate(); + } + + /** + * Adds fixed read-only parameters of a variable. + * + * @param variableCharacteristics Fixed read-only parameters of a variable + * @return this + */ + public ReportData withVariableCharacteristics( + @Nullable VariableCharacteristics variableCharacteristics) { + setVariableCharacteristics(variableCharacteristics); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidComponent(component) + && isValidVariable(variable) + && isValidVariableAttribute(variableAttribute) + && isValidVariableCharacteristics(variableCharacteristics); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReportData that = (ReportData) o; + return Objects.equals(customData, that.customData) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Arrays.equals(variableAttribute, that.variableAttribute) + && Objects.equals(variableCharacteristics, that.variableCharacteristics); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, + component, + variable, + Arrays.hashCode(variableAttribute), + variableCharacteristics); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("component", component) + .add("variable", variable) + .add("variableAttribute", variableAttribute) + .add("variableCharacteristics", variableCharacteristics) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RequestStartStopStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RequestStartStopStatusEnum.java new file mode 100644 index 000000000..f29d4aff1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/RequestStartStopStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Status indicating whether Charging Station accepts the request to stop a transaction. */ +public enum RequestStartStopStatusEnum { + Accepted, + Rejected +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReservationUpdateStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReservationUpdateStatusEnum.java new file mode 100644 index 000000000..6a9870158 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReservationUpdateStatusEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The updated reservation status. */ +public enum ReservationUpdateStatusEnum { + Expired, + Removed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReserveNowStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReserveNowStatusEnum.java new file mode 100644 index 000000000..4e1f21062 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ReserveNowStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The success or failure of the reservation. */ +public enum ReserveNowStatusEnum { + Accepted, + Faulted, + Occupied, + Rejected, + Unavailable +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ResetEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ResetEnum.java new file mode 100644 index 000000000..4845f9f56 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ResetEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The type of reset that the Charging Station or EVSE should perform. */ +public enum ResetEnum { + Immediate, + OnIdle +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ResetStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ResetStatusEnum.java new file mode 100644 index 000000000..ad9ba35b6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/ResetStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the Charging Station is able to perform the reset. */ +public enum ResetStatusEnum { + Accepted, + Rejected, + Scheduled +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SalesTariff.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SalesTariff.java new file mode 100644 index 000000000..406bc7717 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SalesTariff.java @@ -0,0 +1,312 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Sales Tariff + * + *

NOTE: This dataType is based on dataTypes from ISO 15118-2. + */ +public final class SalesTariff { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Identified Object. MRID. Numeric Identifier + * + *

SalesTariff identifier used to identify one sales tariff. An SAID remains a unique + * identifier for one schedule throughout a charging session. + */ + private Integer id; + + /** + * Sales Tariff. Sales. Tariff Description + * + *

A human readable title/short description of the sales tariff e.g. for HMI display purposes. + */ + @Nullable private String salesTariffDescription; + + /** + * Sales Tariff. Num E Price Levels. Counter + * + *

The overall number of distinct price levels used across all provided SalesTariff elements. + */ + @Nullable private Integer numEPriceLevels; + + /** Sales Tariff Entry */ + private SalesTariffEntry[] salesTariffEntry; + + /** + * Constructor for the SalesTariff class + * + * @param id SalesTariff identifier used to identify one sales tariff. An SAID remains a unique + * identifier for one schedule throughout a charging session. + * @param salesTariffEntry Sales Tariff Entry + */ + public SalesTariff(Integer id, SalesTariffEntry[] salesTariffEntry) { + setId(id); + setSalesTariffEntry(salesTariffEntry); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SalesTariff withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets salesTariff identifier used to identify one sales tariff. An SAID remains a unique + * identifier for one schedule throughout a charging session. + * + * @return SalesTariff identifier used to identify one sales tariff + */ + public Integer getId() { + return id; + } + + /** + * Sets salesTariff identifier used to identify one sales tariff. An SAID remains a unique + * identifier for one schedule throughout a charging session. + * + * @param id SalesTariff identifier used to identify one sales tariff + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null; + } + + /** + * Gets a human readable title/short description of the sales tariff e.g. for HMI display + * purposes. + * + * @return A human readable title/short description of the sales tariff e.g. for HMI display + * purposes + */ + @Nullable + public String getSalesTariffDescription() { + return salesTariffDescription; + } + + /** + * Sets a human readable title/short description of the sales tariff e.g. for HMI display + * purposes. + * + * @param salesTariffDescription A human readable title/short description of the sales tariff e.g. + * for HMI display purposes + */ + public void setSalesTariffDescription(@Nullable String salesTariffDescription) { + if (!isValidSalesTariffDescription(salesTariffDescription)) { + throw new PropertyConstraintException( + salesTariffDescription, "salesTariffDescription is invalid"); + } + this.salesTariffDescription = salesTariffDescription; + } + + /** + * Returns whether the given salesTariffDescription is valid + * + * @param salesTariffDescription the salesTariffDescription to check the validity of + * @return {@code true} if salesTariffDescription is valid, {@code false} if not + */ + private boolean isValidSalesTariffDescription(@Nullable String salesTariffDescription) { + return salesTariffDescription == null || salesTariffDescription.length() <= 32; + } + + /** + * Adds a human readable title/short description of the sales tariff e.g. for HMI display + * purposes. + * + * @param salesTariffDescription A human readable title/short description of the sales tariff e.g. + * for HMI display purposes + * @return this + */ + public SalesTariff withSalesTariffDescription(@Nullable String salesTariffDescription) { + setSalesTariffDescription(salesTariffDescription); + return this; + } + + /** + * Gets the overall number of distinct price levels used across all provided SalesTariff elements. + * + * @return The overall number of distinct price levels used across all provided SalesTariff + * elements + */ + @Nullable + public Integer getNumEPriceLevels() { + return numEPriceLevels; + } + + /** + * Sets the overall number of distinct price levels used across all provided SalesTariff elements. + * + * @param numEPriceLevels The overall number of distinct price levels used across all provided + * SalesTariff elements + */ + public void setNumEPriceLevels(@Nullable Integer numEPriceLevels) { + this.numEPriceLevels = numEPriceLevels; + } + + /** + * Adds the overall number of distinct price levels used across all provided SalesTariff elements. + * + * @param numEPriceLevels The overall number of distinct price levels used across all provided + * SalesTariff elements + * @return this + */ + public SalesTariff withNumEPriceLevels(@Nullable Integer numEPriceLevels) { + setNumEPriceLevels(numEPriceLevels); + return this; + } + + /** + * Gets sales Tariff Entry + * + * @return Sales Tariff Entry + */ + public SalesTariffEntry[] getSalesTariffEntry() { + return salesTariffEntry; + } + + /** + * Sets sales Tariff Entry + * + * @param salesTariffEntry Sales Tariff Entry + */ + public void setSalesTariffEntry(SalesTariffEntry[] salesTariffEntry) { + if (!isValidSalesTariffEntry(salesTariffEntry)) { + throw new PropertyConstraintException(salesTariffEntry, "salesTariffEntry is invalid"); + } + this.salesTariffEntry = salesTariffEntry; + } + + /** + * Returns whether the given salesTariffEntry is valid + * + * @param salesTariffEntry the salesTariffEntry to check the validity of + * @return {@code true} if salesTariffEntry is valid, {@code false} if not + */ + private boolean isValidSalesTariffEntry(SalesTariffEntry[] salesTariffEntry) { + return salesTariffEntry != null + && salesTariffEntry.length >= 1 + && salesTariffEntry.length <= 1024 + && Arrays.stream(salesTariffEntry).allMatch(item -> item.validate()); + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidId(id) + && isValidSalesTariffDescription(salesTariffDescription) + && isValidSalesTariffEntry(salesTariffEntry); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SalesTariff that = (SalesTariff) o; + return Objects.equals(customData, that.customData) + && Objects.equals(id, that.id) + && Objects.equals(salesTariffDescription, that.salesTariffDescription) + && Objects.equals(numEPriceLevels, that.numEPriceLevels) + && Arrays.equals(salesTariffEntry, that.salesTariffEntry); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, id, salesTariffDescription, numEPriceLevels, Arrays.hashCode(salesTariffEntry)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("id", id) + .add("salesTariffDescription", salesTariffDescription) + .add("numEPriceLevels", numEPriceLevels) + .add("salesTariffEntry", salesTariffEntry) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SalesTariffEntry.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SalesTariffEntry.java new file mode 100644 index 000000000..3e907abe5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SalesTariffEntry.java @@ -0,0 +1,270 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Sales Tariff Entry */ +public final class SalesTariffEntry { + /** Custom data */ + @Nullable private CustomData customData; + + /** Relative Timer Interval */ + private RelativeTimeInterval relativeTimeInterval; + + /** + * Sales Tariff Entry. E Price Level. Unsigned Integer + * + *

The price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for + * the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a + * more expensive TariffEntry. + */ + @Nullable private Integer ePriceLevel; + + /** Consumption Cost */ + @Nullable private ConsumptionCost[] consumptionCost; + + /** + * Constructor for the SalesTariffEntry class + * + * @param relativeTimeInterval Relative Timer Interval + */ + public SalesTariffEntry(RelativeTimeInterval relativeTimeInterval) { + setRelativeTimeInterval(relativeTimeInterval); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SalesTariffEntry withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets relative Timer Interval + * + * @return Relative Timer Interval + */ + public RelativeTimeInterval getRelativeTimeInterval() { + return relativeTimeInterval; + } + + /** + * Sets relative Timer Interval + * + * @param relativeTimeInterval Relative Timer Interval + */ + public void setRelativeTimeInterval(RelativeTimeInterval relativeTimeInterval) { + if (!isValidRelativeTimeInterval(relativeTimeInterval)) { + throw new PropertyConstraintException( + relativeTimeInterval, "relativeTimeInterval is invalid"); + } + this.relativeTimeInterval = relativeTimeInterval; + } + + /** + * Returns whether the given relativeTimeInterval is valid + * + * @param relativeTimeInterval the relativeTimeInterval to check the validity of + * @return {@code true} if relativeTimeInterval is valid, {@code false} if not + */ + private boolean isValidRelativeTimeInterval(RelativeTimeInterval relativeTimeInterval) { + return relativeTimeInterval != null && relativeTimeInterval.validate(); + } + + /** + * Gets the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for + * the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a + * more expensive TariffEntry. + * + * @return The price level of this SalesTariffEntry (referring to NumEPriceLevels) + */ + @Nullable + public Integer getEPriceLevel() { + return ePriceLevel; + } + + /** + * Sets the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for + * the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a + * more expensive TariffEntry. + * + * @param ePriceLevel The price level of this SalesTariffEntry (referring to NumEPriceLevels) + */ + public void setEPriceLevel(@Nullable Integer ePriceLevel) { + if (!isValidEPriceLevel(ePriceLevel)) { + throw new PropertyConstraintException(ePriceLevel, "ePriceLevel is invalid"); + } + this.ePriceLevel = ePriceLevel; + } + + /** + * Returns whether the given ePriceLevel is valid + * + * @param ePriceLevel the ePriceLevel to check the validity of + * @return {@code true} if ePriceLevel is valid, {@code false} if not + */ + private boolean isValidEPriceLevel(@Nullable Integer ePriceLevel) { + return ePriceLevel == null || (ePriceLevel >= 0); + } + + /** + * Adds the price level of this SalesTariffEntry (referring to NumEPriceLevels). Small values for + * the EPriceLevel represent a cheaper TariffEntry. Large values for the EPriceLevel represent a + * more expensive TariffEntry. + * + * @param ePriceLevel The price level of this SalesTariffEntry (referring to NumEPriceLevels) + * @return this + */ + public SalesTariffEntry withEPriceLevel(@Nullable Integer ePriceLevel) { + setEPriceLevel(ePriceLevel); + return this; + } + + /** + * Gets consumption Cost + * + * @return Consumption Cost + */ + @Nullable + public ConsumptionCost[] getConsumptionCost() { + return consumptionCost; + } + + /** + * Sets consumption Cost + * + * @param consumptionCost Consumption Cost + */ + public void setConsumptionCost(@Nullable ConsumptionCost[] consumptionCost) { + if (!isValidConsumptionCost(consumptionCost)) { + throw new PropertyConstraintException(consumptionCost, "consumptionCost is invalid"); + } + this.consumptionCost = consumptionCost; + } + + /** + * Returns whether the given consumptionCost is valid + * + * @param consumptionCost the consumptionCost to check the validity of + * @return {@code true} if consumptionCost is valid, {@code false} if not + */ + private boolean isValidConsumptionCost(@Nullable ConsumptionCost[] consumptionCost) { + return consumptionCost == null + || (consumptionCost.length >= 1 + && consumptionCost.length <= 3 + && Arrays.stream(consumptionCost).allMatch(item -> item.validate())); + } + + /** + * Adds consumption Cost + * + * @param consumptionCost Consumption Cost + * @return this + */ + public SalesTariffEntry withConsumptionCost(@Nullable ConsumptionCost[] consumptionCost) { + setConsumptionCost(consumptionCost); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidRelativeTimeInterval(relativeTimeInterval) + && isValidEPriceLevel(ePriceLevel) + && isValidConsumptionCost(consumptionCost); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SalesTariffEntry that = (SalesTariffEntry) o; + return Objects.equals(customData, that.customData) + && Objects.equals(relativeTimeInterval, that.relativeTimeInterval) + && Objects.equals(ePriceLevel, that.ePriceLevel) + && Arrays.equals(consumptionCost, that.consumptionCost); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, relativeTimeInterval, ePriceLevel, Arrays.hashCode(consumptionCost)); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("relativeTimeInterval", relativeTimeInterval) + .add("ePriceLevel", ePriceLevel) + .add("consumptionCost", consumptionCost) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SampledValue.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SampledValue.java new file mode 100644 index 000000000..03d38f6f1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SampledValue.java @@ -0,0 +1,426 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Sampled Value + * + *

Single sampled value in MeterValues. Each value can be accompanied by optional fields. + * + *

To save on mobile data usage, default values of all of the optional fields are such that. The + * value without any additional fields will be interpreted, as a register reading of active import + * energy in Wh (Watt-hour) units. + */ +public final class SampledValue { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Sampled Value. Value. Measure + * + *

The measured value. + */ + private Double value; + + /** + * Sampled Value. Context. Reading Context Code + * + *

Type of detail value: start, end or sample. Default = "Sample.Periodic" + */ + @Nullable private ReadingContextEnum context; + + /** + * Sampled Value. Measurand. Measurand Code + * + *

Type of measurement. Default = "Energy.Active.Import.Register" + */ + @Nullable private MeasurandEnum measurand; + + /** + * Sampled Value. Phase. Phase Code + * + *

How the measured value is to be interpreted. For instance between L1 and neutral (L1-N) + * Please note that not all values of phase are applicable to all Measurands. When phase is + * absent, the measured value is interpreted as an overall value. + */ + @Nullable private PhaseEnum phase; + + /** + * Sampled Value. Location. Location Code + * + *

Where the measured value has been sampled. Default = "Outlet" + */ + @Nullable private LocationEnum location; + + /** A signed version of the meter value. */ + @Nullable private SignedMeterValue signedMeterValue; + + /** A UnitOfMeasure with a multiplier */ + @Nullable private UnitOfMeasure unitOfMeasure; + + /** + * Constructor for the SampledValue class + * + * @param value The measured value. + */ + public SampledValue(Double value) { + setValue(value); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SampledValue withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the measured value. + * + * @return The measured value + */ + public Double getValue() { + return value; + } + + /** + * Sets the measured value. + * + * @param value The measured value + */ + public void setValue(Double value) { + if (!isValidValue(value)) { + throw new PropertyConstraintException(value, "value is invalid"); + } + this.value = value; + } + + /** + * Returns whether the given value is valid + * + * @param value the value to check the validity of + * @return {@code true} if value is valid, {@code false} if not + */ + private boolean isValidValue(Double value) { + return value != null; + } + + /** + * Gets type of detail value: start, end or sample. Default = "Sample.Periodic" + * + * @return Type of detail value: start, end or sample + */ + public ReadingContextEnum getContext() { + return context != null ? context : ReadingContextEnum.SamplePeriodic; + } + + /** + * Sets type of detail value: start, end or sample. Default = "Sample.Periodic" + * + * @param context Type of detail value: start, end or sample + */ + public void setContext(@Nullable ReadingContextEnum context) { + this.context = context; + } + + /** + * Adds type of detail value: start, end or sample. Default = "Sample.Periodic" + * + * @param context Type of detail value: start, end or sample + * @return this + */ + public SampledValue withContext(@Nullable ReadingContextEnum context) { + setContext(context); + return this; + } + + /** + * Gets type of measurement. Default = "Energy.Active.Import.Register" + * + * @return Type of measurement + */ + public MeasurandEnum getMeasurand() { + return measurand != null ? measurand : MeasurandEnum.EnergyActiveImportRegister; + } + + /** + * Sets type of measurement. Default = "Energy.Active.Import.Register" + * + * @param measurand Type of measurement + */ + public void setMeasurand(@Nullable MeasurandEnum measurand) { + this.measurand = measurand; + } + + /** + * Adds type of measurement. Default = "Energy.Active.Import.Register" + * + * @param measurand Type of measurement + * @return this + */ + public SampledValue withMeasurand(@Nullable MeasurandEnum measurand) { + setMeasurand(measurand); + return this; + } + + /** + * Gets how the measured value is to be interpreted. For instance between L1 and neutral (L1-N) + * Please note that not all values of phase are applicable to all Measurands. When phase is + * absent, the measured value is interpreted as an overall value. + * + * @return How the measured value is to be interpreted + */ + @Nullable + public PhaseEnum getPhase() { + return phase; + } + + /** + * Sets how the measured value is to be interpreted. For instance between L1 and neutral (L1-N) + * Please note that not all values of phase are applicable to all Measurands. When phase is + * absent, the measured value is interpreted as an overall value. + * + * @param phase How the measured value is to be interpreted + */ + public void setPhase(@Nullable PhaseEnum phase) { + this.phase = phase; + } + + /** + * Adds how the measured value is to be interpreted. For instance between L1 and neutral (L1-N) + * Please note that not all values of phase are applicable to all Measurands. When phase is + * absent, the measured value is interpreted as an overall value. + * + * @param phase How the measured value is to be interpreted + * @return this + */ + public SampledValue withPhase(@Nullable PhaseEnum phase) { + setPhase(phase); + return this; + } + + /** + * Gets where the measured value has been sampled. Default = "Outlet" + * + * @return Where the measured value has been sampled + */ + public LocationEnum getLocation() { + return location != null ? location : LocationEnum.Outlet; + } + + /** + * Sets where the measured value has been sampled. Default = "Outlet" + * + * @param location Where the measured value has been sampled + */ + public void setLocation(@Nullable LocationEnum location) { + this.location = location; + } + + /** + * Adds where the measured value has been sampled. Default = "Outlet" + * + * @param location Where the measured value has been sampled + * @return this + */ + public SampledValue withLocation(@Nullable LocationEnum location) { + setLocation(location); + return this; + } + + /** + * Gets a signed version of the meter value. + * + * @return A signed version of the meter value + */ + @Nullable + public SignedMeterValue getSignedMeterValue() { + return signedMeterValue; + } + + /** + * Sets a signed version of the meter value. + * + * @param signedMeterValue A signed version of the meter value + */ + public void setSignedMeterValue(@Nullable SignedMeterValue signedMeterValue) { + if (!isValidSignedMeterValue(signedMeterValue)) { + throw new PropertyConstraintException(signedMeterValue, "signedMeterValue is invalid"); + } + this.signedMeterValue = signedMeterValue; + } + + /** + * Returns whether the given signedMeterValue is valid + * + * @param signedMeterValue the signedMeterValue to check the validity of + * @return {@code true} if signedMeterValue is valid, {@code false} if not + */ + private boolean isValidSignedMeterValue(@Nullable SignedMeterValue signedMeterValue) { + return signedMeterValue == null || signedMeterValue.validate(); + } + + /** + * Adds a signed version of the meter value. + * + * @param signedMeterValue A signed version of the meter value + * @return this + */ + public SampledValue withSignedMeterValue(@Nullable SignedMeterValue signedMeterValue) { + setSignedMeterValue(signedMeterValue); + return this; + } + + /** + * Gets a UnitOfMeasure with a multiplier + * + * @return A UnitOfMeasure with a multiplier + */ + @Nullable + public UnitOfMeasure getUnitOfMeasure() { + return unitOfMeasure; + } + + /** + * Sets a UnitOfMeasure with a multiplier + * + * @param unitOfMeasure A UnitOfMeasure with a multiplier + */ + public void setUnitOfMeasure(@Nullable UnitOfMeasure unitOfMeasure) { + if (!isValidUnitOfMeasure(unitOfMeasure)) { + throw new PropertyConstraintException(unitOfMeasure, "unitOfMeasure is invalid"); + } + this.unitOfMeasure = unitOfMeasure; + } + + /** + * Returns whether the given unitOfMeasure is valid + * + * @param unitOfMeasure the unitOfMeasure to check the validity of + * @return {@code true} if unitOfMeasure is valid, {@code false} if not + */ + private boolean isValidUnitOfMeasure(@Nullable UnitOfMeasure unitOfMeasure) { + return unitOfMeasure == null || unitOfMeasure.validate(); + } + + /** + * Adds a UnitOfMeasure with a multiplier + * + * @param unitOfMeasure A UnitOfMeasure with a multiplier + * @return this + */ + public SampledValue withUnitOfMeasure(@Nullable UnitOfMeasure unitOfMeasure) { + setUnitOfMeasure(unitOfMeasure); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidValue(value) + && isValidSignedMeterValue(signedMeterValue) + && isValidUnitOfMeasure(unitOfMeasure); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SampledValue that = (SampledValue) o; + return Objects.equals(customData, that.customData) + && Objects.equals(value, that.value) + && Objects.equals(context, that.context) + && Objects.equals(measurand, that.measurand) + && Objects.equals(phase, that.phase) + && Objects.equals(location, that.location) + && Objects.equals(signedMeterValue, that.signedMeterValue) + && Objects.equals(unitOfMeasure, that.unitOfMeasure); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, value, context, measurand, phase, location, signedMeterValue, unitOfMeasure); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("value", value) + .add("context", context) + .add("measurand", measurand) + .add("phase", phase) + .add("location", location) + .add("signedMeterValue", signedMeterValue) + .add("unitOfMeasure", unitOfMeasure) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SendLocalListStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SendLocalListStatusEnum.java new file mode 100644 index 000000000..6c762bb54 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SendLocalListStatusEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Whether the Charging Station has successfully received and applied the update of the Local + * Authorization List. + */ +public enum SendLocalListStatusEnum { + Accepted, + Failed, + VersionMismatch +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetMonitoringData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetMonitoringData.java new file mode 100644 index 000000000..e78ee5b3d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetMonitoringData.java @@ -0,0 +1,433 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to hold parameters of SetVariableMonitoring request. */ +public final class SetMonitoringData { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * An id SHALL only be given to replace an existing monitor. The Charging Station handles the + * generation of id's for new monitors. + */ + @Nullable private Integer id; + + /** + * Monitor only active when a transaction is ongoing on a component relevant to this transaction. + * Default = false. + */ + @Nullable private Boolean transaction; + + /** + * Value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + */ + private Double value; + + /** The type of this monitor, e.g. a threshold, delta or periodic monitor. */ + private MonitorEnum type; + + /** + * The severity that will be assigned to an event that is triggered by this monitor. The severity + * range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + *

+   * The severity levels have the following meaning: +
+   * *0-Danger* +
+   * Lives are potentially in danger. Urgent attention is needed and action should be taken immediately. +
+   * *1-Hardware Failure* +
+   * That the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. +
+   * *2-System Failure* +
+   * That the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. +
+   * *3-Critical* +
+   * A critical error. Action is required. +
+   * *4-Error* +
+   * A non-urgent error. Action is required. +
+   * *5-Alert* +
+   * An alert event. Default severity for any type of monitoring event. +
+   * *6-Warning* +
+   * A warning event. Action may be required. +
+   * *7-Notice* +
+   * An unusual event. No immediate action is required. +
+   * *8-Informational* +
+   * A regular operational event. May be used for reporting, measuring throughput, etc. No action is required. +
+   * *9-Debug* +
+   * Information useful to developers for debugging, not useful during operations.
+   * 
+ */ + private Integer severity; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** + * Constructor for the SetMonitoringData class + * + * @param value Value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this + * is the interval in seconds. + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor. + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + */ + public SetMonitoringData( + Double value, MonitorEnum type, Integer severity, Component component, Variable variable) { + setValue(value); + setType(type); + setSeverity(severity); + setComponent(component); + setVariable(variable); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets an id SHALL only be given to replace an existing monitor. The Charging Station handles the + * generation of id's for new monitors. + * + * @return An id SHALL only be given to replace an existing monitor + */ + @Nullable + public Integer getId() { + return id; + } + + /** + * Sets an id SHALL only be given to replace an existing monitor. The Charging Station handles the + * generation of id's for new monitors. + * + * @param id An id SHALL only be given to replace an existing monitor + */ + public void setId(@Nullable Integer id) { + this.id = id; + } + + /** + * Adds an id SHALL only be given to replace an existing monitor. The Charging Station handles the + * generation of id's for new monitors. + * + * @param id An id SHALL only be given to replace an existing monitor + * @return this + */ + public SetMonitoringData withId(@Nullable Integer id) { + setId(id); + return this; + } + + /** + * Gets monitor only active when a transaction is ongoing on a component relevant to this + * transaction. Default = false. + * + * @return Monitor only active when a transaction is ongoing on a component relevant to this + * transaction + */ + public Boolean getTransaction() { + return transaction != null ? transaction : false; + } + + /** + * Sets monitor only active when a transaction is ongoing on a component relevant to this + * transaction. Default = false. + * + * @param transaction Monitor only active when a transaction is ongoing on a component relevant to + * this transaction + */ + public void setTransaction(@Nullable Boolean transaction) { + this.transaction = transaction; + } + + /** + * Adds monitor only active when a transaction is ongoing on a component relevant to this + * transaction. Default = false. + * + * @param transaction Monitor only active when a transaction is ongoing on a component relevant to + * this transaction + * @return this + */ + public SetMonitoringData withTransaction(@Nullable Boolean transaction) { + setTransaction(transaction); + return this; + } + + /** + * Gets value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + * + * @return Value for threshold or delta monitoring + */ + public Double getValue() { + return value; + } + + /** + * Sets value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + * + * @param value Value for threshold or delta monitoring + */ + public void setValue(Double value) { + if (!isValidValue(value)) { + throw new PropertyConstraintException(value, "value is invalid"); + } + this.value = value; + } + + /** + * Returns whether the given value is valid + * + * @param value the value to check the validity of + * @return {@code true} if value is valid, {@code false} if not + */ + private boolean isValidValue(Double value) { + return value != null; + } + + /** + * Gets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @return The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public MonitorEnum getType() { + return type; + } + + /** + * Sets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public void setType(MonitorEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(MonitorEnum type) { + return type != null; + } + + /** + * Gets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @return The severity that will be assigned to an event that is triggered by this monitor + */ + public Integer getSeverity() { + return severity; + } + + /** + * Sets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor + */ + public void setSeverity(Integer severity) { + if (!isValidSeverity(severity)) { + throw new PropertyConstraintException(severity, "severity is invalid"); + } + this.severity = severity; + } + + /** + * Returns whether the given severity is valid + * + * @param severity the severity to check the validity of + * @return {@code true} if severity is valid, {@code false} if not + */ + private boolean isValidSeverity(Integer severity) { + return severity != null; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidValue(value) + && isValidType(type) + && isValidSeverity(severity) + && isValidComponent(component) + && isValidVariable(variable); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringData that = (SetMonitoringData) o; + return Objects.equals(customData, that.customData) + && Objects.equals(id, that.id) + && Objects.equals(transaction, that.transaction) + && Objects.equals(value, that.value) + && Objects.equals(type, that.type) + && Objects.equals(severity, that.severity) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable); + } + + @Override + public int hashCode() { + return Objects.hash(customData, id, transaction, value, type, severity, component, variable); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("id", id) + .add("transaction", transaction) + .add("value", value) + .add("type", type) + .add("severity", severity) + .add("component", component) + .add("variable", variable) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetMonitoringResult.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetMonitoringResult.java new file mode 100644 index 000000000..5a2276c0b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetMonitoringResult.java @@ -0,0 +1,447 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Class to hold result of SetVariableMonitoring request. */ +public final class SetMonitoringResult { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Id given to the VariableMonitor by the Charging Station. The Id is only returned when status is + * accepted. Installed VariableMonitors should have unique id's but the id's of removed Installed + * monitors should have unique id's but the id's of removed monitors MAY be reused. + */ + @Nullable private Integer id; + + /** More information about the status. */ + @Nullable private StatusInfo statusInfo; + + /** + * Status is OK if a value could be returned. Otherwise this will indicate the reason why a value + * could not be returned. + */ + private SetMonitoringStatusEnum status; + + /** The type of this monitor, e.g. a threshold, delta or periodic monitor. */ + private MonitorEnum type; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** + * The severity that will be assigned to an event that is triggered by this monitor. The severity + * range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + *
+   * The severity levels have the following meaning: +
+   * *0-Danger* +
+   * Lives are potentially in danger. Urgent attention is needed and action should be taken immediately. +
+   * *1-Hardware Failure* +
+   * That the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. +
+   * *2-System Failure* +
+   * That the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. +
+   * *3-Critical* +
+   * A critical error. Action is required. +
+   * *4-Error* +
+   * A non-urgent error. Action is required. +
+   * *5-Alert* +
+   * An alert event. Default severity for any type of monitoring event. +
+   * *6-Warning* +
+   * A warning event. Action may be required. +
+   * *7-Notice* +
+   * An unusual event. No immediate action is required. +
+   * *8-Informational* +
+   * A regular operational event. May be used for reporting, measuring throughput, etc. No action is required. +
+   * *9-Debug* +
+   * Information useful to developers for debugging, not useful during operations.
+   * 
+ */ + private Integer severity; + + /** + * Constructor for the SetMonitoringResult class + * + * @param status Status is OK if a value could be returned. Otherwise this will indicate the + * reason why a value could not be returned. + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor. + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + */ + public SetMonitoringResult( + SetMonitoringStatusEnum status, + MonitorEnum type, + Component component, + Variable variable, + Integer severity) { + setStatus(status); + setType(type); + setComponent(component); + setVariable(variable); + setSeverity(severity); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetMonitoringResult withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets id given to the VariableMonitor by the Charging Station. The Id is only returned when + * status is accepted. Installed VariableMonitors should have unique id's but the id's of removed + * Installed monitors should have unique id's but the id's of removed monitors MAY be reused. + * + * @return Id given to the VariableMonitor by the Charging Station + */ + @Nullable + public Integer getId() { + return id; + } + + /** + * Sets id given to the VariableMonitor by the Charging Station. The Id is only returned when + * status is accepted. Installed VariableMonitors should have unique id's but the id's of removed + * Installed monitors should have unique id's but the id's of removed monitors MAY be reused. + * + * @param id Id given to the VariableMonitor by the Charging Station + */ + public void setId(@Nullable Integer id) { + this.id = id; + } + + /** + * Adds id given to the VariableMonitor by the Charging Station. The Id is only returned when + * status is accepted. Installed VariableMonitors should have unique id's but the id's of removed + * Installed monitors should have unique id's but the id's of removed monitors MAY be reused. + * + * @param id Id given to the VariableMonitor by the Charging Station + * @return this + */ + public SetMonitoringResult withId(@Nullable Integer id) { + setId(id); + return this; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getStatusInfo() { + return statusInfo; + } + + /** + * Sets more information about the status. + * + * @param statusInfo More information about the status + */ + public void setStatusInfo(@Nullable StatusInfo statusInfo) { + if (!isValidStatusInfo(statusInfo)) { + throw new PropertyConstraintException(statusInfo, "statusInfo is invalid"); + } + this.statusInfo = statusInfo; + } + + /** + * Returns whether the given statusInfo is valid + * + * @param statusInfo the statusInfo to check the validity of + * @return {@code true} if statusInfo is valid, {@code false} if not + */ + private boolean isValidStatusInfo(@Nullable StatusInfo statusInfo) { + return statusInfo == null || statusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param statusInfo More information about the status + * @return this + */ + public SetMonitoringResult withStatusInfo(@Nullable StatusInfo statusInfo) { + setStatusInfo(statusInfo); + return this; + } + + /** + * Gets status is OK if a value could be returned. Otherwise this will indicate the reason why a + * value could not be returned. + * + * @return Status is OK if a value could be returned + */ + public SetMonitoringStatusEnum getStatus() { + return status; + } + + /** + * Sets status is OK if a value could be returned. Otherwise this will indicate the reason why a + * value could not be returned. + * + * @param status Status is OK if a value could be returned + */ + public void setStatus(SetMonitoringStatusEnum status) { + if (!isValidStatus(status)) { + throw new PropertyConstraintException(status, "status is invalid"); + } + this.status = status; + } + + /** + * Returns whether the given status is valid + * + * @param status the status to check the validity of + * @return {@code true} if status is valid, {@code false} if not + */ + private boolean isValidStatus(SetMonitoringStatusEnum status) { + return status != null; + } + + /** + * Gets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @return The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public MonitorEnum getType() { + return type; + } + + /** + * Sets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public void setType(MonitorEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(MonitorEnum type) { + return type != null; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + /** + * Gets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @return The severity that will be assigned to an event that is triggered by this monitor + */ + public Integer getSeverity() { + return severity; + } + + /** + * Sets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor + */ + public void setSeverity(Integer severity) { + if (!isValidSeverity(severity)) { + throw new PropertyConstraintException(severity, "severity is invalid"); + } + this.severity = severity; + } + + /** + * Returns whether the given severity is valid + * + * @param severity the severity to check the validity of + * @return {@code true} if severity is valid, {@code false} if not + */ + private boolean isValidSeverity(Integer severity) { + return severity != null; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidStatusInfo(statusInfo) + && isValidStatus(status) + && isValidType(type) + && isValidComponent(component) + && isValidVariable(variable) + && isValidSeverity(severity); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetMonitoringResult that = (SetMonitoringResult) o; + return Objects.equals(customData, that.customData) + && Objects.equals(id, that.id) + && Objects.equals(statusInfo, that.statusInfo) + && Objects.equals(status, that.status) + && Objects.equals(type, that.type) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable) + && Objects.equals(severity, that.severity); + } + + @Override + public int hashCode() { + return Objects.hash(customData, id, statusInfo, status, type, component, variable, severity); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("id", id) + .add("statusInfo", statusInfo) + .add("status", status) + .add("type", type) + .add("component", component) + .add("variable", variable) + .add("severity", severity) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetMonitoringStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetMonitoringStatusEnum.java new file mode 100644 index 000000000..7252689e7 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetMonitoringStatusEnum.java @@ -0,0 +1,38 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * Status is OK if a value could be returned. Otherwise this will indicate the reason why a value + * could not be returned. + */ +public enum SetMonitoringStatusEnum { + Accepted, + UnknownComponent, + UnknownVariable, + UnsupportedMonitorType, + Rejected, + Duplicate +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetNetworkProfileStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetNetworkProfileStatusEnum.java new file mode 100644 index 000000000..a2858f55b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetNetworkProfileStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Result of operation. */ +public enum SetNetworkProfileStatusEnum { + Accepted, + Rejected, + Failed +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetVariableData.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetVariableData.java new file mode 100644 index 000000000..c12cf96ef --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetVariableData.java @@ -0,0 +1,272 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** SetVariableDataType */ +public final class SetVariableData { + /** Custom data */ + @Nullable private CustomData customData; + + /** Type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. */ + @Nullable private AttributeEnum attributeType; + + /** + * Value to be assigned to attribute of variable. + * + *

The Configuration Variable ConfigurationValueSize can be used to limit + * SetVariableData.attributeValue and VariableCharacteristics.valueList. The max size of these + * values will always remain equal. + */ + private String attributeValue; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** + * Constructor for the SetVariableData class + * + * @param attributeValue Value to be assigned to attribute of variable. + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + */ + public SetVariableData(String attributeValue, Component component, Variable variable) { + setAttributeValue(attributeValue); + setComponent(component); + setVariable(variable); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariableData withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @return Type of attribute: Actual, Target, MinSet, MaxSet + */ + public AttributeEnum getAttributeType() { + return attributeType != null ? attributeType : AttributeEnum.Actual; + } + + /** + * Sets type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @param attributeType Type of attribute: Actual, Target, MinSet, MaxSet + */ + public void setAttributeType(@Nullable AttributeEnum attributeType) { + this.attributeType = attributeType; + } + + /** + * Adds type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @param attributeType Type of attribute: Actual, Target, MinSet, MaxSet + * @return this + */ + public SetVariableData withAttributeType(@Nullable AttributeEnum attributeType) { + setAttributeType(attributeType); + return this; + } + + /** + * Gets value to be assigned to attribute of variable. + * + * @return Value to be assigned to attribute of variable + */ + public String getAttributeValue() { + return attributeValue; + } + + /** + * Sets value to be assigned to attribute of variable. + * + * @param attributeValue Value to be assigned to attribute of variable + */ + public void setAttributeValue(String attributeValue) { + if (!isValidAttributeValue(attributeValue)) { + throw new PropertyConstraintException(attributeValue, "attributeValue is invalid"); + } + this.attributeValue = attributeValue; + } + + /** + * Returns whether the given attributeValue is valid + * + * @param attributeValue the attributeValue to check the validity of + * @return {@code true} if attributeValue is valid, {@code false} if not + */ + private boolean isValidAttributeValue(String attributeValue) { + return attributeValue != null && attributeValue.length() <= 1000; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidAttributeValue(attributeValue) + && isValidComponent(component) + && isValidVariable(variable); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariableData that = (SetVariableData) o; + return Objects.equals(customData, that.customData) + && Objects.equals(attributeType, that.attributeType) + && Objects.equals(attributeValue, that.attributeValue) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable); + } + + @Override + public int hashCode() { + return Objects.hash(customData, attributeType, attributeValue, component, variable); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("attributeType", attributeType) + .add("attributeValue", attributeValue) + .add("component", component) + .add("variable", variable) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetVariableResult.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetVariableResult.java new file mode 100644 index 000000000..7e4ca21f1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetVariableResult.java @@ -0,0 +1,317 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** SetVariableResultType */ +public final class SetVariableResult { + /** Custom data */ + @Nullable private CustomData customData; + + /** Type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. */ + @Nullable private AttributeEnum attributeType; + + /** Result status of setting the variable. */ + private SetVariableStatusEnum attributeStatus; + + /** More information about the status. */ + @Nullable private StatusInfo attributeStatusInfo; + + /** A physical or logical component */ + private Component component; + + /** Reference key to a component-variable. */ + private Variable variable; + + /** + * Constructor for the SetVariableResult class + * + * @param attributeStatus Result status of setting the variable. + * @param component A physical or logical component + * @param variable Reference key to a component-variable. + */ + public SetVariableResult( + SetVariableStatusEnum attributeStatus, Component component, Variable variable) { + setAttributeStatus(attributeStatus); + setComponent(component); + setVariable(variable); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SetVariableResult withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @return Type of attribute: Actual, Target, MinSet, MaxSet + */ + public AttributeEnum getAttributeType() { + return attributeType != null ? attributeType : AttributeEnum.Actual; + } + + /** + * Sets type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @param attributeType Type of attribute: Actual, Target, MinSet, MaxSet + */ + public void setAttributeType(@Nullable AttributeEnum attributeType) { + this.attributeType = attributeType; + } + + /** + * Adds type of attribute: Actual, Target, MinSet, MaxSet. Default is Actual when omitted. + * + * @param attributeType Type of attribute: Actual, Target, MinSet, MaxSet + * @return this + */ + public SetVariableResult withAttributeType(@Nullable AttributeEnum attributeType) { + setAttributeType(attributeType); + return this; + } + + /** + * Gets result status of setting the variable. + * + * @return Result status of setting the variable + */ + public SetVariableStatusEnum getAttributeStatus() { + return attributeStatus; + } + + /** + * Sets result status of setting the variable. + * + * @param attributeStatus Result status of setting the variable + */ + public void setAttributeStatus(SetVariableStatusEnum attributeStatus) { + if (!isValidAttributeStatus(attributeStatus)) { + throw new PropertyConstraintException(attributeStatus, "attributeStatus is invalid"); + } + this.attributeStatus = attributeStatus; + } + + /** + * Returns whether the given attributeStatus is valid + * + * @param attributeStatus the attributeStatus to check the validity of + * @return {@code true} if attributeStatus is valid, {@code false} if not + */ + private boolean isValidAttributeStatus(SetVariableStatusEnum attributeStatus) { + return attributeStatus != null; + } + + /** + * Gets more information about the status. + * + * @return More information about the status + */ + @Nullable + public StatusInfo getAttributeStatusInfo() { + return attributeStatusInfo; + } + + /** + * Sets more information about the status. + * + * @param attributeStatusInfo More information about the status + */ + public void setAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + if (!isValidAttributeStatusInfo(attributeStatusInfo)) { + throw new PropertyConstraintException(attributeStatusInfo, "attributeStatusInfo is invalid"); + } + this.attributeStatusInfo = attributeStatusInfo; + } + + /** + * Returns whether the given attributeStatusInfo is valid + * + * @param attributeStatusInfo the attributeStatusInfo to check the validity of + * @return {@code true} if attributeStatusInfo is valid, {@code false} if not + */ + private boolean isValidAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + return attributeStatusInfo == null || attributeStatusInfo.validate(); + } + + /** + * Adds more information about the status. + * + * @param attributeStatusInfo More information about the status + * @return this + */ + public SetVariableResult withAttributeStatusInfo(@Nullable StatusInfo attributeStatusInfo) { + setAttributeStatusInfo(attributeStatusInfo); + return this; + } + + /** + * Gets a physical or logical component + * + * @return A physical or logical component + */ + public Component getComponent() { + return component; + } + + /** + * Sets a physical or logical component + * + * @param component A physical or logical component + */ + public void setComponent(Component component) { + if (!isValidComponent(component)) { + throw new PropertyConstraintException(component, "component is invalid"); + } + this.component = component; + } + + /** + * Returns whether the given component is valid + * + * @param component the component to check the validity of + * @return {@code true} if component is valid, {@code false} if not + */ + private boolean isValidComponent(Component component) { + return component != null && component.validate(); + } + + /** + * Gets reference key to a component-variable. + * + * @return Reference key to a component-variable + */ + public Variable getVariable() { + return variable; + } + + /** + * Sets reference key to a component-variable. + * + * @param variable Reference key to a component-variable + */ + public void setVariable(Variable variable) { + if (!isValidVariable(variable)) { + throw new PropertyConstraintException(variable, "variable is invalid"); + } + this.variable = variable; + } + + /** + * Returns whether the given variable is valid + * + * @param variable the variable to check the validity of + * @return {@code true} if variable is valid, {@code false} if not + */ + private boolean isValidVariable(Variable variable) { + return variable != null && variable.validate(); + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidAttributeStatus(attributeStatus) + && isValidAttributeStatusInfo(attributeStatusInfo) + && isValidComponent(component) + && isValidVariable(variable); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetVariableResult that = (SetVariableResult) o; + return Objects.equals(customData, that.customData) + && Objects.equals(attributeType, that.attributeType) + && Objects.equals(attributeStatus, that.attributeStatus) + && Objects.equals(attributeStatusInfo, that.attributeStatusInfo) + && Objects.equals(component, that.component) + && Objects.equals(variable, that.variable); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, attributeType, attributeStatus, attributeStatusInfo, component, variable); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("attributeType", attributeType) + .add("attributeStatus", attributeStatus) + .add("attributeStatusInfo", attributeStatusInfo) + .add("component", component) + .add("variable", variable) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetVariableStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetVariableStatusEnum.java new file mode 100644 index 000000000..e8647b21b --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SetVariableStatusEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Result status of setting the variable. */ +public enum SetVariableStatusEnum { + Accepted, + Rejected, + UnknownComponent, + UnknownVariable, + NotSupportedAttributeType, + RebootRequired +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SignedMeterValue.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SignedMeterValue.java new file mode 100644 index 000000000..bf0b35d40 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/SignedMeterValue.java @@ -0,0 +1,285 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A signed version of the meter value. */ +public final class SignedMeterValue { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Base64 encoded, contains the signed data which might contain more then just the meter value. It + * can contain information like timestamps, reference to a customer etc. + */ + private String signedMeterData; + + /** Method used to create the digital signature. */ + private String signingMethod; + + /** Method used to encode the meter values before applying the digital signature algorithm. */ + private String encodingMethod; + + /** Base64 encoded, sending depends on configuration variable PublicKeyWithSignedMeterValue. */ + private String publicKey; + + /** + * Constructor for the SignedMeterValue class + * + * @param signedMeterData Base64 encoded, contains the signed data which might contain more then + * just the meter value. It can contain information like timestamps, reference to a customer + * etc. + * @param signingMethod Method used to create the digital signature. + * @param encodingMethod Method used to encode the meter values before applying the digital + * signature algorithm. + * @param publicKey Base64 encoded, sending depends on configuration variable + * PublicKeyWithSignedMeterValue. + */ + public SignedMeterValue( + String signedMeterData, String signingMethod, String encodingMethod, String publicKey) { + setSignedMeterData(signedMeterData); + setSigningMethod(signingMethod); + setEncodingMethod(encodingMethod); + setPublicKey(publicKey); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public SignedMeterValue withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets base64 encoded, contains the signed data which might contain more then just the meter + * value. It can contain information like timestamps, reference to a customer etc. + * + * @return Base64 encoded, contains the signed data which might contain more then just the meter + * value + */ + public String getSignedMeterData() { + return signedMeterData; + } + + /** + * Sets base64 encoded, contains the signed data which might contain more then just the meter + * value. It can contain information like timestamps, reference to a customer etc. + * + * @param signedMeterData Base64 encoded, contains the signed data which might contain more then + * just the meter value + */ + public void setSignedMeterData(String signedMeterData) { + if (!isValidSignedMeterData(signedMeterData)) { + throw new PropertyConstraintException(signedMeterData, "signedMeterData is invalid"); + } + this.signedMeterData = signedMeterData; + } + + /** + * Returns whether the given signedMeterData is valid + * + * @param signedMeterData the signedMeterData to check the validity of + * @return {@code true} if signedMeterData is valid, {@code false} if not + */ + private boolean isValidSignedMeterData(String signedMeterData) { + return signedMeterData != null && signedMeterData.length() <= 2500; + } + + /** + * Gets method used to create the digital signature. + * + * @return Method used to create the digital signature + */ + public String getSigningMethod() { + return signingMethod; + } + + /** + * Sets method used to create the digital signature. + * + * @param signingMethod Method used to create the digital signature + */ + public void setSigningMethod(String signingMethod) { + if (!isValidSigningMethod(signingMethod)) { + throw new PropertyConstraintException(signingMethod, "signingMethod is invalid"); + } + this.signingMethod = signingMethod; + } + + /** + * Returns whether the given signingMethod is valid + * + * @param signingMethod the signingMethod to check the validity of + * @return {@code true} if signingMethod is valid, {@code false} if not + */ + private boolean isValidSigningMethod(String signingMethod) { + return signingMethod != null && signingMethod.length() <= 50; + } + + /** + * Gets method used to encode the meter values before applying the digital signature algorithm. + * + * @return Method used to encode the meter values before applying the digital signature algorithm + */ + public String getEncodingMethod() { + return encodingMethod; + } + + /** + * Sets method used to encode the meter values before applying the digital signature algorithm. + * + * @param encodingMethod Method used to encode the meter values before applying the digital + * signature algorithm + */ + public void setEncodingMethod(String encodingMethod) { + if (!isValidEncodingMethod(encodingMethod)) { + throw new PropertyConstraintException(encodingMethod, "encodingMethod is invalid"); + } + this.encodingMethod = encodingMethod; + } + + /** + * Returns whether the given encodingMethod is valid + * + * @param encodingMethod the encodingMethod to check the validity of + * @return {@code true} if encodingMethod is valid, {@code false} if not + */ + private boolean isValidEncodingMethod(String encodingMethod) { + return encodingMethod != null && encodingMethod.length() <= 50; + } + + /** + * Gets base64 encoded, sending depends on configuration variable PublicKeyWithSignedMeterValue. + * + * @return Base64 encoded, sending depends on configuration variable PublicKeyWithSignedMeterValue + */ + public String getPublicKey() { + return publicKey; + } + + /** + * Sets base64 encoded, sending depends on configuration variable PublicKeyWithSignedMeterValue. + * + * @param publicKey Base64 encoded, sending depends on configuration variable + * PublicKeyWithSignedMeterValue + */ + public void setPublicKey(String publicKey) { + if (!isValidPublicKey(publicKey)) { + throw new PropertyConstraintException(publicKey, "publicKey is invalid"); + } + this.publicKey = publicKey; + } + + /** + * Returns whether the given publicKey is valid + * + * @param publicKey the publicKey to check the validity of + * @return {@code true} if publicKey is valid, {@code false} if not + */ + private boolean isValidPublicKey(String publicKey) { + return publicKey != null && publicKey.length() <= 2500; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidSignedMeterData(signedMeterData) + && isValidSigningMethod(signingMethod) + && isValidEncodingMethod(encodingMethod) + && isValidPublicKey(publicKey); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SignedMeterValue that = (SignedMeterValue) o; + return Objects.equals(customData, that.customData) + && Objects.equals(signedMeterData, that.signedMeterData) + && Objects.equals(signingMethod, that.signingMethod) + && Objects.equals(encodingMethod, that.encodingMethod) + && Objects.equals(publicKey, that.publicKey); + } + + @Override + public int hashCode() { + return Objects.hash(customData, signedMeterData, signingMethod, encodingMethod, publicKey); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("signedMeterData", signedMeterData) + .add("signingMethod", signingMethod) + .add("encodingMethod", encodingMethod) + .add("publicKey", publicKey) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/StatusInfo.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/StatusInfo.java new file mode 100644 index 000000000..7fca651f1 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/StatusInfo.java @@ -0,0 +1,209 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** More information about the status. */ +public final class StatusInfo { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * A predefined code for the reason why the status is returned in this response. The string is + * case-insensitive. + */ + private String reasonCode; + + /** Additional text to provide detailed information. */ + @Nullable private String additionalInfo; + + /** + * Constructor for the StatusInfo class + * + * @param reasonCode A predefined code for the reason why the status is returned in this response. + * The string is case-insensitive. + */ + public StatusInfo(String reasonCode) { + setReasonCode(reasonCode); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public StatusInfo withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets a predefined code for the reason why the status is returned in this response. The string + * is case-insensitive. + * + * @return A predefined code for the reason why the status is returned in this response + */ + public String getReasonCode() { + return reasonCode; + } + + /** + * Sets a predefined code for the reason why the status is returned in this response. The string + * is case-insensitive. + * + * @param reasonCode A predefined code for the reason why the status is returned in this response + */ + public void setReasonCode(String reasonCode) { + if (!isValidReasonCode(reasonCode)) { + throw new PropertyConstraintException(reasonCode, "reasonCode is invalid"); + } + this.reasonCode = reasonCode; + } + + /** + * Returns whether the given reasonCode is valid + * + * @param reasonCode the reasonCode to check the validity of + * @return {@code true} if reasonCode is valid, {@code false} if not + */ + private boolean isValidReasonCode(String reasonCode) { + return reasonCode != null && reasonCode.length() <= 20; + } + + /** + * Gets additional text to provide detailed information. + * + * @return Additional text to provide detailed information + */ + @Nullable + public String getAdditionalInfo() { + return additionalInfo; + } + + /** + * Sets additional text to provide detailed information. + * + * @param additionalInfo Additional text to provide detailed information + */ + public void setAdditionalInfo(@Nullable String additionalInfo) { + if (!isValidAdditionalInfo(additionalInfo)) { + throw new PropertyConstraintException(additionalInfo, "additionalInfo is invalid"); + } + this.additionalInfo = additionalInfo; + } + + /** + * Returns whether the given additionalInfo is valid + * + * @param additionalInfo the additionalInfo to check the validity of + * @return {@code true} if additionalInfo is valid, {@code false} if not + */ + private boolean isValidAdditionalInfo(@Nullable String additionalInfo) { + return additionalInfo == null || additionalInfo.length() <= 512; + } + + /** + * Adds additional text to provide detailed information. + * + * @param additionalInfo Additional text to provide detailed information + * @return this + */ + public StatusInfo withAdditionalInfo(@Nullable String additionalInfo) { + setAdditionalInfo(additionalInfo); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidReasonCode(reasonCode) + && isValidAdditionalInfo(additionalInfo); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + StatusInfo that = (StatusInfo) o; + return Objects.equals(customData, that.customData) + && Objects.equals(reasonCode, that.reasonCode) + && Objects.equals(additionalInfo, that.additionalInfo); + } + + @Override + public int hashCode() { + return Objects.hash(customData, reasonCode, additionalInfo); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("reasonCode", reasonCode) + .add("additionalInfo", additionalInfo) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Transaction.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Transaction.java new file mode 100644 index 000000000..3510ee467 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Transaction.java @@ -0,0 +1,318 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Transaction */ +public final class Transaction { + /** Custom data */ + @Nullable private CustomData customData; + + /** The Id of the transaction. */ + private String transactionId; + + /** + * Transaction. State. Transaction State Code + * + *

Current charging state, is required when state has changed. + */ + @Nullable private ChargingStateEnum chargingState; + + /** + * Transaction. Time Spent Charging. Elapsed Time + * + *

The total time that energy flowed from EVSE to EV during the transaction (in seconds). Note + * that timeSpentCharging is smaller or equal to the duration of the transaction. + */ + @Nullable private Integer timeSpentCharging; + + /** + * Transaction. Stopped Reason. EOT Reason Code + * + *

The reason why the transaction was stopped. MAY only be omitted when Reason is "Local". + */ + @Nullable private ReasonEnum stoppedReason; + + /** + * The ID given to remote start request (RequestStartTransactionRequest. This enables to CSMS to + * match the started transaction to the given start request. + */ + @Nullable private Integer remoteStartId; + + /** + * Constructor for the Transaction class + * + * @param transactionId The Id of the transaction. + */ + public Transaction(String transactionId) { + setTransactionId(transactionId); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Transaction withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the Id of the transaction. + * + * @return The Id of the transaction + */ + public String getTransactionId() { + return transactionId; + } + + /** + * Sets the Id of the transaction. + * + * @param transactionId The Id of the transaction + */ + public void setTransactionId(String transactionId) { + if (!isValidTransactionId(transactionId)) { + throw new PropertyConstraintException(transactionId, "transactionId is invalid"); + } + this.transactionId = transactionId; + } + + /** + * Returns whether the given transactionId is valid + * + * @param transactionId the transactionId to check the validity of + * @return {@code true} if transactionId is valid, {@code false} if not + */ + private boolean isValidTransactionId(String transactionId) { + return transactionId != null && transactionId.length() <= 36; + } + + /** + * Gets current charging state, is required when state has changed. + * + * @return Current charging state, is required when state has changed + */ + @Nullable + public ChargingStateEnum getChargingState() { + return chargingState; + } + + /** + * Sets current charging state, is required when state has changed. + * + * @param chargingState Current charging state, is required when state has changed + */ + public void setChargingState(@Nullable ChargingStateEnum chargingState) { + this.chargingState = chargingState; + } + + /** + * Adds current charging state, is required when state has changed. + * + * @param chargingState Current charging state, is required when state has changed + * @return this + */ + public Transaction withChargingState(@Nullable ChargingStateEnum chargingState) { + setChargingState(chargingState); + return this; + } + + /** + * Gets the total time that energy flowed from EVSE to EV during the transaction (in seconds). + * Note that timeSpentCharging is smaller or equal to the duration of the transaction. + * + * @return The total time that energy flowed from EVSE to EV during the transaction (in seconds) + */ + @Nullable + public Integer getTimeSpentCharging() { + return timeSpentCharging; + } + + /** + * Sets the total time that energy flowed from EVSE to EV during the transaction (in seconds). + * Note that timeSpentCharging is smaller or equal to the duration of the transaction. + * + * @param timeSpentCharging The total time that energy flowed from EVSE to EV during the + * transaction (in seconds) + */ + public void setTimeSpentCharging(@Nullable Integer timeSpentCharging) { + this.timeSpentCharging = timeSpentCharging; + } + + /** + * Adds the total time that energy flowed from EVSE to EV during the transaction (in seconds). + * Note that timeSpentCharging is smaller or equal to the duration of the transaction. + * + * @param timeSpentCharging The total time that energy flowed from EVSE to EV during the + * transaction (in seconds) + * @return this + */ + public Transaction withTimeSpentCharging(@Nullable Integer timeSpentCharging) { + setTimeSpentCharging(timeSpentCharging); + return this; + } + + /** + * Gets the reason why the transaction was stopped. MAY only be omitted when Reason is "Local". + * + * @return The reason why the transaction was stopped + */ + @Nullable + public ReasonEnum getStoppedReason() { + return stoppedReason; + } + + /** + * Sets the reason why the transaction was stopped. MAY only be omitted when Reason is "Local". + * + * @param stoppedReason The reason why the transaction was stopped + */ + public void setStoppedReason(@Nullable ReasonEnum stoppedReason) { + this.stoppedReason = stoppedReason; + } + + /** + * Adds the reason why the transaction was stopped. MAY only be omitted when Reason is "Local". + * + * @param stoppedReason The reason why the transaction was stopped + * @return this + */ + public Transaction withStoppedReason(@Nullable ReasonEnum stoppedReason) { + setStoppedReason(stoppedReason); + return this; + } + + /** + * Gets the ID given to remote start request (RequestStartTransactionRequest. This enables to CSMS + * to match the started transaction to the given start request. + * + * @return The ID given to remote start request (RequestStartTransactionRequest + */ + @Nullable + public Integer getRemoteStartId() { + return remoteStartId; + } + + /** + * Sets the ID given to remote start request (RequestStartTransactionRequest. This enables to CSMS + * to match the started transaction to the given start request. + * + * @param remoteStartId The ID given to remote start request (RequestStartTransactionRequest + */ + public void setRemoteStartId(@Nullable Integer remoteStartId) { + this.remoteStartId = remoteStartId; + } + + /** + * Adds the ID given to remote start request (RequestStartTransactionRequest. This enables to CSMS + * to match the started transaction to the given start request. + * + * @param remoteStartId The ID given to remote start request (RequestStartTransactionRequest + * @return this + */ + public Transaction withRemoteStartId(@Nullable Integer remoteStartId) { + setRemoteStartId(remoteStartId); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) && isValidTransactionId(transactionId); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Transaction that = (Transaction) o; + return Objects.equals(customData, that.customData) + && Objects.equals(transactionId, that.transactionId) + && Objects.equals(chargingState, that.chargingState) + && Objects.equals(timeSpentCharging, that.timeSpentCharging) + && Objects.equals(stoppedReason, that.stoppedReason) + && Objects.equals(remoteStartId, that.remoteStartId); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, transactionId, chargingState, timeSpentCharging, stoppedReason, remoteStartId); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("transactionId", transactionId) + .add("chargingState", chargingState) + .add("timeSpentCharging", timeSpentCharging) + .add("stoppedReason", stoppedReason) + .add("remoteStartId", remoteStartId) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/TransactionEventEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/TransactionEventEnum.java new file mode 100644 index 000000000..73806d7b6 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/TransactionEventEnum.java @@ -0,0 +1,35 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * The type of this event. The first TransactionEvent of a transaction SHALL contain: "Started" The + * last TransactionEvent of a transaction SHALL contain: "Ended" All others SHALL contain: "Updated" + */ +public enum TransactionEventEnum { + Ended, + Started, + Updated +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/TriggerMessageStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/TriggerMessageStatusEnum.java new file mode 100644 index 000000000..6425564a2 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/TriggerMessageStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the Charging Station will send the requested notification or not. */ +public enum TriggerMessageStatusEnum { + Accepted, + Rejected, + NotImplemented +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/TriggerReasonEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/TriggerReasonEnum.java new file mode 100644 index 000000000..b5cd51066 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/TriggerReasonEnum.java @@ -0,0 +1,50 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Reason the Charging Station sends this message to the CSMS */ +public enum TriggerReasonEnum { + Authorized, + CablePluggedIn, + ChargingRateChanged, + ChargingStateChanged, + Deauthorized, + EnergyLimitReached, + EVCommunicationLost, + EVConnectTimeout, + MeterValueClock, + MeterValuePeriodic, + TimeLimitReached, + Trigger, + UnlockCommand, + StopAuthorized, + EVDeparted, + EVDetected, + RemoteStop, + RemoteStart, + AbnormalCondition, + SignedDataReceived, + ResetCommand +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UnitOfMeasure.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UnitOfMeasure.java new file mode 100644 index 000000000..6abdb1ebb --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UnitOfMeasure.java @@ -0,0 +1,208 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A UnitOfMeasure with a multiplier */ +public final class UnitOfMeasure { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type. This field + * SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices. If an + * applicable unit is available in that list, otherwise a "custom" unit might be used. + */ + @Nullable private String unit; + + /** + * Multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 raised to + * the 3rd power. Default is 0. + */ + @Nullable private Integer multiplier; + + /** Constructor for the UnitOfMeasure class */ + public UnitOfMeasure() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public UnitOfMeasure withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type. This + * field SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices. + * If an applicable unit is available in that list, otherwise a "custom" unit might be used. + * + * @return Unit of the value + */ + public String getUnit() { + return unit != null ? unit : "Wh"; + } + + /** + * Sets unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type. This + * field SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices. + * If an applicable unit is available in that list, otherwise a "custom" unit might be used. + * + * @param unit Unit of the value + */ + public void setUnit(@Nullable String unit) { + if (!isValidUnit(unit)) { + throw new PropertyConstraintException(unit, "unit is invalid"); + } + this.unit = unit; + } + + /** + * Returns whether the given unit is valid + * + * @param unit the unit to check the validity of + * @return {@code true} if unit is valid, {@code false} if not + */ + private boolean isValidUnit(@Nullable String unit) { + return unit == null || unit.length() <= 20; + } + + /** + * Adds unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type. This + * field SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices. + * If an applicable unit is available in that list, otherwise a "custom" unit might be used. + * + * @param unit Unit of the value + * @return this + */ + public UnitOfMeasure withUnit(@Nullable String unit) { + setUnit(unit); + return this; + } + + /** + * Gets multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 + * raised to the 3rd power. Default is 0. + * + * @return Multiplier, this value represents the exponent to base 10 + */ + public Integer getMultiplier() { + return multiplier != null ? multiplier : 0; + } + + /** + * Sets multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 + * raised to the 3rd power. Default is 0. + * + * @param multiplier Multiplier, this value represents the exponent to base 10 + */ + public void setMultiplier(@Nullable Integer multiplier) { + this.multiplier = multiplier; + } + + /** + * Adds multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 + * raised to the 3rd power. Default is 0. + * + * @param multiplier Multiplier, this value represents the exponent to base 10 + * @return this + */ + public UnitOfMeasure withMultiplier(@Nullable Integer multiplier) { + setMultiplier(multiplier); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) && isValidUnit(unit); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UnitOfMeasure that = (UnitOfMeasure) o; + return Objects.equals(customData, that.customData) + && Objects.equals(unit, that.unit) + && Objects.equals(multiplier, that.multiplier); + } + + @Override + public int hashCode() { + return Objects.hash(customData, unit, multiplier); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("unit", unit) + .add("multiplier", multiplier) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UnlockStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UnlockStatusEnum.java new file mode 100644 index 000000000..0be9356c9 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UnlockStatusEnum.java @@ -0,0 +1,33 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the Charging Station has unlocked the connector. */ +public enum UnlockStatusEnum { + Unlocked, + UnlockFailed, + OngoingAuthorizedTransaction, + UnknownConnector +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UnpublishFirmwareStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UnpublishFirmwareStatusEnum.java new file mode 100644 index 000000000..a77c3a3dc --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UnpublishFirmwareStatusEnum.java @@ -0,0 +1,32 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** Whether the Local Controller succeeded in unpublishing the firmware. */ +public enum UnpublishFirmwareStatusEnum { + DownloadOngoing, + NoFirmware, + Unpublished +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UpdateEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UpdateEnum.java new file mode 100644 index 000000000..c9a58e6bf --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UpdateEnum.java @@ -0,0 +1,31 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The type of update (full or differential) of this request. */ +public enum UpdateEnum { + Differential, + Full +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UpdateFirmwareStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UpdateFirmwareStatusEnum.java new file mode 100644 index 000000000..84b53de1f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UpdateFirmwareStatusEnum.java @@ -0,0 +1,34 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** This field indicates whether the Charging Station was able to accept the request. */ +public enum UpdateFirmwareStatusEnum { + Accepted, + Rejected, + AcceptedCanceled, + InvalidCertificate, + RevokedCertificate +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UploadLogStatusEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UploadLogStatusEnum.java new file mode 100644 index 000000000..cf0f5848a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/UploadLogStatusEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** The status of the log upload. */ +public enum UploadLogStatusEnum { + BadMessage, + Idle, + NotSupportedOperation, + PermissionDenied, + Uploaded, + UploadFailure, + Uploading, + AcceptedCanceled +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VPN.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VPN.java new file mode 100644 index 000000000..baf2d7f6d --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VPN.java @@ -0,0 +1,387 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * VPN + * + *

VPN Configuration settings + */ +public final class VPN { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * VPN. Server. URI + * + *

VPN Server Address + */ + private String server; + + /** + * VPN. User. User Name + * + *

VPN User + */ + private String user; + + /** + * VPN. Group. Group Name + * + *

VPN group. + */ + @Nullable private String group; + + /** + * VPN. Password. Password + * + *

VPN Password. + */ + private String password; + + /** + * VPN. Key. VPN Key + * + *

VPN shared secret. + */ + private String key; + + /** + * VPN. Type. VPN Code + * + *

Type of VPN + */ + private VPNEnum type; + + /** + * Constructor for the VPN class + * + * @param server VPN Server Address + * @param user VPN User + * @param password VPN Password. + * @param key VPN shared secret. + * @param type Type of VPN + */ + public VPN(String server, String user, String password, String key, VPNEnum type) { + setServer(server); + setUser(user); + setPassword(password); + setKey(key); + setType(type); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public VPN withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets VPN Server Address + * + * @return VPN Server Address + */ + public String getServer() { + return server; + } + + /** + * Sets VPN Server Address + * + * @param server VPN Server Address + */ + public void setServer(String server) { + if (!isValidServer(server)) { + throw new PropertyConstraintException(server, "server is invalid"); + } + this.server = server; + } + + /** + * Returns whether the given server is valid + * + * @param server the server to check the validity of + * @return {@code true} if server is valid, {@code false} if not + */ + private boolean isValidServer(String server) { + return server != null && server.length() <= 512; + } + + /** + * Gets VPN User + * + * @return VPN User + */ + public String getUser() { + return user; + } + + /** + * Sets VPN User + * + * @param user VPN User + */ + public void setUser(String user) { + if (!isValidUser(user)) { + throw new PropertyConstraintException(user, "user is invalid"); + } + this.user = user; + } + + /** + * Returns whether the given user is valid + * + * @param user the user to check the validity of + * @return {@code true} if user is valid, {@code false} if not + */ + private boolean isValidUser(String user) { + return user != null && user.length() <= 20; + } + + /** + * Gets VPN group. + * + * @return VPN group + */ + @Nullable + public String getGroup() { + return group; + } + + /** + * Sets VPN group. + * + * @param group VPN group + */ + public void setGroup(@Nullable String group) { + if (!isValidGroup(group)) { + throw new PropertyConstraintException(group, "group is invalid"); + } + this.group = group; + } + + /** + * Returns whether the given group is valid + * + * @param group the group to check the validity of + * @return {@code true} if group is valid, {@code false} if not + */ + private boolean isValidGroup(@Nullable String group) { + return group == null || group.length() <= 20; + } + + /** + * Adds VPN group. + * + * @param group VPN group + * @return this + */ + public VPN withGroup(@Nullable String group) { + setGroup(group); + return this; + } + + /** + * Gets VPN Password. + * + * @return VPN Password + */ + public String getPassword() { + return password; + } + + /** + * Sets VPN Password. + * + * @param password VPN Password + */ + public void setPassword(String password) { + if (!isValidPassword(password)) { + throw new PropertyConstraintException(password, "password is invalid"); + } + this.password = password; + } + + /** + * Returns whether the given password is valid + * + * @param password the password to check the validity of + * @return {@code true} if password is valid, {@code false} if not + */ + private boolean isValidPassword(String password) { + return password != null && password.length() <= 20; + } + + /** + * Gets VPN shared secret. + * + * @return VPN shared secret + */ + public String getKey() { + return key; + } + + /** + * Sets VPN shared secret. + * + * @param key VPN shared secret + */ + public void setKey(String key) { + if (!isValidKey(key)) { + throw new PropertyConstraintException(key, "key is invalid"); + } + this.key = key; + } + + /** + * Returns whether the given key is valid + * + * @param key the key to check the validity of + * @return {@code true} if key is valid, {@code false} if not + */ + private boolean isValidKey(String key) { + return key != null && key.length() <= 255; + } + + /** + * Gets type of VPN + * + * @return Type of VPN + */ + public VPNEnum getType() { + return type; + } + + /** + * Sets type of VPN + * + * @param type Type of VPN + */ + public void setType(VPNEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(VPNEnum type) { + return type != null; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidServer(server) + && isValidUser(user) + && isValidGroup(group) + && isValidPassword(password) + && isValidKey(key) + && isValidType(type); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VPN that = (VPN) o; + return Objects.equals(customData, that.customData) + && Objects.equals(server, that.server) + && Objects.equals(user, that.user) + && Objects.equals(group, that.group) + && Objects.equals(password, that.password) + && Objects.equals(key, that.key) + && Objects.equals(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hash(customData, server, user, group, password, key, type); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("server", server) + .add("user", user) + .add("group", group) + .add("password", password) + .add("key", key) + .add("type", type) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VPNEnum.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VPNEnum.java new file mode 100644 index 000000000..265647f58 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VPNEnum.java @@ -0,0 +1,37 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +/** + * VPN. Type. VPN Code + * + *

Type of VPN + */ +public enum VPNEnum { + IKEv2, + IPSec, + L2TP, + PPTP +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Variable.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Variable.java new file mode 100644 index 000000000..53ffde84f --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/Variable.java @@ -0,0 +1,213 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Reference key to a component-variable. */ +public final class Variable { + /** Custom data */ + @Nullable private CustomData customData; + + /** + * Name of the variable. Name should be taken from the list of standardized variable names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + */ + private String name; + + /** + * Name of instance in case the variable exists as multiple instances. Case Insensitive. strongly + * advised to use Camel Case. + */ + @Nullable private String instance; + + /** + * Constructor for the Variable class + * + * @param name Name of the variable. Name should be taken from the list of standardized variable + * names whenever possible. Case Insensitive. strongly advised to use Camel Case. + */ + public Variable(String name) { + setName(name); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public Variable withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets name of the variable. Name should be taken from the list of standardized variable names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + * + * @return Name of the variable + */ + public String getName() { + return name; + } + + /** + * Sets name of the variable. Name should be taken from the list of standardized variable names + * whenever possible. Case Insensitive. strongly advised to use Camel Case. + * + * @param name Name of the variable + */ + public void setName(String name) { + if (!isValidName(name)) { + throw new PropertyConstraintException(name, "name is invalid"); + } + this.name = name; + } + + /** + * Returns whether the given name is valid + * + * @param name the name to check the validity of + * @return {@code true} if name is valid, {@code false} if not + */ + private boolean isValidName(String name) { + return name != null && name.length() <= 50; + } + + /** + * Gets name of instance in case the variable exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @return Name of instance in case the variable exists as multiple instances + */ + @Nullable + public String getInstance() { + return instance; + } + + /** + * Sets name of instance in case the variable exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @param instance Name of instance in case the variable exists as multiple instances + */ + public void setInstance(@Nullable String instance) { + if (!isValidInstance(instance)) { + throw new PropertyConstraintException(instance, "instance is invalid"); + } + this.instance = instance; + } + + /** + * Returns whether the given instance is valid + * + * @param instance the instance to check the validity of + * @return {@code true} if instance is valid, {@code false} if not + */ + private boolean isValidInstance(@Nullable String instance) { + return instance == null || instance.length() <= 50; + } + + /** + * Adds name of instance in case the variable exists as multiple instances. Case Insensitive. + * strongly advised to use Camel Case. + * + * @param instance Name of instance in case the variable exists as multiple instances + * @return this + */ + public Variable withInstance(@Nullable String instance) { + setInstance(instance); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) && isValidName(name) && isValidInstance(instance); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Variable that = (Variable) o; + return Objects.equals(customData, that.customData) + && Objects.equals(name, that.name) + && Objects.equals(instance, that.instance); + } + + @Override + public int hashCode() { + return Objects.hash(customData, name, instance); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("name", name) + .add("instance", instance) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VariableAttribute.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VariableAttribute.java new file mode 100644 index 000000000..2f1241ff5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VariableAttribute.java @@ -0,0 +1,313 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Attribute data of a variable. */ +public final class VariableAttribute { + /** Custom data */ + @Nullable private CustomData customData; + + /** Attribute: Actual, MinSet, MaxSet, etc. Defaults to Actual if absent. */ + @Nullable private AttributeEnum type; + + /** + * Value of the attribute. May only be omitted when mutability is set to 'WriteOnly'. + * + *

The Configuration Variable ReportingValueSize can be used to limit + * GetVariableResult.attributeValue, VariableAttribute.value and EventData.actualValue. The max + * size of these values will always remain equal. + */ + @Nullable private String value; + + /** The mutability of this attribute. Default is ReadWrite when omitted. */ + @Nullable private MutabilityEnum mutability; + + /** + * Whether value will be persistent across system reboots or power down. Default when omitted is + * false. + */ + @Nullable private Boolean persistent; + + /** + * Whether value that will never be changed by the Charging Station at runtime. Default when + * omitted is false. + */ + @Nullable private Boolean constant; + + /** Constructor for the VariableAttribute class */ + public VariableAttribute() {} + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public VariableAttribute withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets attribute: Actual, MinSet, MaxSet, etc. Defaults to Actual if absent. + * + * @return Attribute: Actual, MinSet, MaxSet, etc + */ + public AttributeEnum getType() { + return type != null ? type : AttributeEnum.Actual; + } + + /** + * Sets attribute: Actual, MinSet, MaxSet, etc. Defaults to Actual if absent. + * + * @param type Attribute: Actual, MinSet, MaxSet, etc + */ + public void setType(@Nullable AttributeEnum type) { + this.type = type; + } + + /** + * Adds attribute: Actual, MinSet, MaxSet, etc. Defaults to Actual if absent. + * + * @param type Attribute: Actual, MinSet, MaxSet, etc + * @return this + */ + public VariableAttribute withType(@Nullable AttributeEnum type) { + setType(type); + return this; + } + + /** + * Gets value of the attribute. May only be omitted when mutability is set to 'WriteOnly'. + * + * @return Value of the attribute + */ + @Nullable + public String getValue() { + return value; + } + + /** + * Sets value of the attribute. May only be omitted when mutability is set to 'WriteOnly'. + * + * @param value Value of the attribute + */ + public void setValue(@Nullable String value) { + if (!isValidValue(value)) { + throw new PropertyConstraintException(value, "value is invalid"); + } + this.value = value; + } + + /** + * Returns whether the given value is valid + * + * @param value the value to check the validity of + * @return {@code true} if value is valid, {@code false} if not + */ + private boolean isValidValue(@Nullable String value) { + return value == null || value.length() <= 2500; + } + + /** + * Adds value of the attribute. May only be omitted when mutability is set to 'WriteOnly'. + * + * @param value Value of the attribute + * @return this + */ + public VariableAttribute withValue(@Nullable String value) { + setValue(value); + return this; + } + + /** + * Gets the mutability of this attribute. Default is ReadWrite when omitted. + * + * @return The mutability of this attribute + */ + public MutabilityEnum getMutability() { + return mutability != null ? mutability : MutabilityEnum.ReadWrite; + } + + /** + * Sets the mutability of this attribute. Default is ReadWrite when omitted. + * + * @param mutability The mutability of this attribute + */ + public void setMutability(@Nullable MutabilityEnum mutability) { + this.mutability = mutability; + } + + /** + * Adds the mutability of this attribute. Default is ReadWrite when omitted. + * + * @param mutability The mutability of this attribute + * @return this + */ + public VariableAttribute withMutability(@Nullable MutabilityEnum mutability) { + setMutability(mutability); + return this; + } + + /** + * Gets whether value will be persistent across system reboots or power down. Default when omitted + * is false. + * + * @return Whether value will be persistent across system reboots or power down + */ + public Boolean getPersistent() { + return persistent != null ? persistent : false; + } + + /** + * Sets whether value will be persistent across system reboots or power down. Default when omitted + * is false. + * + * @param persistent Whether value will be persistent across system reboots or power down + */ + public void setPersistent(@Nullable Boolean persistent) { + this.persistent = persistent; + } + + /** + * Adds whether value will be persistent across system reboots or power down. Default when omitted + * is false. + * + * @param persistent Whether value will be persistent across system reboots or power down + * @return this + */ + public VariableAttribute withPersistent(@Nullable Boolean persistent) { + setPersistent(persistent); + return this; + } + + /** + * Gets whether value that will never be changed by the Charging Station at runtime. Default when + * omitted is false. + * + * @return Whether value that will never be changed by the Charging Station at runtime + */ + public Boolean getConstant() { + return constant != null ? constant : false; + } + + /** + * Sets whether value that will never be changed by the Charging Station at runtime. Default when + * omitted is false. + * + * @param constant Whether value that will never be changed by the Charging Station at runtime + */ + public void setConstant(@Nullable Boolean constant) { + this.constant = constant; + } + + /** + * Adds whether value that will never be changed by the Charging Station at runtime. Default when + * omitted is false. + * + * @param constant Whether value that will never be changed by the Charging Station at runtime + * @return this + */ + public VariableAttribute withConstant(@Nullable Boolean constant) { + setConstant(constant); + return this; + } + + public boolean validate() { + return isValidCustomData(customData) && isValidValue(value); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VariableAttribute that = (VariableAttribute) o; + return Objects.equals(customData, that.customData) + && Objects.equals(type, that.type) + && Objects.equals(value, that.value) + && Objects.equals(mutability, that.mutability) + && Objects.equals(persistent, that.persistent) + && Objects.equals(constant, that.constant); + } + + @Override + public int hashCode() { + return Objects.hash(customData, type, value, mutability, persistent, constant); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("type", type) + .add("value", value) + .add("mutability", mutability) + .add("persistent", persistent) + .add("constant", constant) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VariableCharacteristics.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VariableCharacteristics.java new file mode 100644 index 000000000..b603d40b5 --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VariableCharacteristics.java @@ -0,0 +1,389 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** Fixed read-only parameters of a variable. */ +public final class VariableCharacteristics { + /** Custom data */ + @Nullable private CustomData customData; + + /** Unit of the variable. When the transmitted value has a unit, this field SHALL be included. */ + @Nullable private String unit; + + /** Data type of this variable. */ + private DataEnum dataType; + + /** Minimum possible value of this variable. */ + @Nullable private Double minLimit; + + /** + * Maximum possible value of this variable. When the datatype of this Variable is String, + * OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) + * string. + */ + @Nullable private Double maxLimit; + + /** + * Allowed values when variable is Option/Member/SequenceList. + * + *

* OptionList: The (Actual) Variable value must be a single value from the reported (CSV) + * enumeration list. + * + *

* MemberList: The (Actual) Variable value may be an (unordered) (sub-)set of the reported + * (CSV) valid values list. + * + *

* SequenceList: The (Actual) Variable value may be an ordered (priority, etc) (sub-)set of + * the reported (CSV) valid values. + * + *

This is a comma separated list. + * + *

The Configuration Variable ConfigurationValueSize can be used to limit + * SetVariableData.attributeValue and VariableCharacteristics.valueList. The max size of these + * values will always remain equal. + */ + @Nullable private String valuesList; + + /** Flag indicating if this variable supports monitoring. */ + private Boolean supportsMonitoring; + + /** + * Constructor for the VariableCharacteristics class + * + * @param dataType Data type of this variable. + * @param supportsMonitoring Flag indicating if this variable supports monitoring. + */ + public VariableCharacteristics(DataEnum dataType, Boolean supportsMonitoring) { + setDataType(dataType); + setSupportsMonitoring(supportsMonitoring); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public VariableCharacteristics withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets unit of the variable. When the transmitted value has a unit, this field SHALL be included. + * + * @return Unit of the variable + */ + @Nullable + public String getUnit() { + return unit; + } + + /** + * Sets unit of the variable. When the transmitted value has a unit, this field SHALL be included. + * + * @param unit Unit of the variable + */ + public void setUnit(@Nullable String unit) { + if (!isValidUnit(unit)) { + throw new PropertyConstraintException(unit, "unit is invalid"); + } + this.unit = unit; + } + + /** + * Returns whether the given unit is valid + * + * @param unit the unit to check the validity of + * @return {@code true} if unit is valid, {@code false} if not + */ + private boolean isValidUnit(@Nullable String unit) { + return unit == null || unit.length() <= 16; + } + + /** + * Adds unit of the variable. When the transmitted value has a unit, this field SHALL be included. + * + * @param unit Unit of the variable + * @return this + */ + public VariableCharacteristics withUnit(@Nullable String unit) { + setUnit(unit); + return this; + } + + /** + * Gets data type of this variable. + * + * @return Data type of this variable + */ + public DataEnum getDataType() { + return dataType; + } + + /** + * Sets data type of this variable. + * + * @param dataType Data type of this variable + */ + public void setDataType(DataEnum dataType) { + if (!isValidDataType(dataType)) { + throw new PropertyConstraintException(dataType, "dataType is invalid"); + } + this.dataType = dataType; + } + + /** + * Returns whether the given dataType is valid + * + * @param dataType the dataType to check the validity of + * @return {@code true} if dataType is valid, {@code false} if not + */ + private boolean isValidDataType(DataEnum dataType) { + return dataType != null; + } + + /** + * Gets minimum possible value of this variable. + * + * @return Minimum possible value of this variable + */ + @Nullable + public Double getMinLimit() { + return minLimit; + } + + /** + * Sets minimum possible value of this variable. + * + * @param minLimit Minimum possible value of this variable + */ + public void setMinLimit(@Nullable Double minLimit) { + this.minLimit = minLimit; + } + + /** + * Adds minimum possible value of this variable. + * + * @param minLimit Minimum possible value of this variable + * @return this + */ + public VariableCharacteristics withMinLimit(@Nullable Double minLimit) { + setMinLimit(minLimit); + return this; + } + + /** + * Gets maximum possible value of this variable. When the datatype of this Variable is String, + * OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) + * string. + * + * @return Maximum possible value of this variable + */ + @Nullable + public Double getMaxLimit() { + return maxLimit; + } + + /** + * Sets maximum possible value of this variable. When the datatype of this Variable is String, + * OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) + * string. + * + * @param maxLimit Maximum possible value of this variable + */ + public void setMaxLimit(@Nullable Double maxLimit) { + this.maxLimit = maxLimit; + } + + /** + * Adds maximum possible value of this variable. When the datatype of this Variable is String, + * OptionList, SequenceList or MemberList, this field defines the maximum length of the (CSV) + * string. + * + * @param maxLimit Maximum possible value of this variable + * @return this + */ + public VariableCharacteristics withMaxLimit(@Nullable Double maxLimit) { + setMaxLimit(maxLimit); + return this; + } + + /** + * Gets allowed values when variable is Option/Member/SequenceList. + * + * @return Allowed values when variable is Option/Member/SequenceList + */ + @Nullable + public String getValuesList() { + return valuesList; + } + + /** + * Sets allowed values when variable is Option/Member/SequenceList. + * + * @param valuesList Allowed values when variable is Option/Member/SequenceList + */ + public void setValuesList(@Nullable String valuesList) { + if (!isValidValuesList(valuesList)) { + throw new PropertyConstraintException(valuesList, "valuesList is invalid"); + } + this.valuesList = valuesList; + } + + /** + * Returns whether the given valuesList is valid + * + * @param valuesList the valuesList to check the validity of + * @return {@code true} if valuesList is valid, {@code false} if not + */ + private boolean isValidValuesList(@Nullable String valuesList) { + return valuesList == null || valuesList.length() <= 1000; + } + + /** + * Adds allowed values when variable is Option/Member/SequenceList. + * + * @param valuesList Allowed values when variable is Option/Member/SequenceList + * @return this + */ + public VariableCharacteristics withValuesList(@Nullable String valuesList) { + setValuesList(valuesList); + return this; + } + + /** + * Gets flag indicating if this variable supports monitoring. + * + * @return Flag indicating if this variable supports monitoring + */ + public Boolean getSupportsMonitoring() { + return supportsMonitoring; + } + + /** + * Sets flag indicating if this variable supports monitoring. + * + * @param supportsMonitoring Flag indicating if this variable supports monitoring + */ + public void setSupportsMonitoring(Boolean supportsMonitoring) { + if (!isValidSupportsMonitoring(supportsMonitoring)) { + throw new PropertyConstraintException(supportsMonitoring, "supportsMonitoring is invalid"); + } + this.supportsMonitoring = supportsMonitoring; + } + + /** + * Returns whether the given supportsMonitoring is valid + * + * @param supportsMonitoring the supportsMonitoring to check the validity of + * @return {@code true} if supportsMonitoring is valid, {@code false} if not + */ + private boolean isValidSupportsMonitoring(Boolean supportsMonitoring) { + return supportsMonitoring != null; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidUnit(unit) + && isValidDataType(dataType) + && isValidValuesList(valuesList) + && isValidSupportsMonitoring(supportsMonitoring); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VariableCharacteristics that = (VariableCharacteristics) o; + return Objects.equals(customData, that.customData) + && Objects.equals(unit, that.unit) + && Objects.equals(dataType, that.dataType) + && Objects.equals(minLimit, that.minLimit) + && Objects.equals(maxLimit, that.maxLimit) + && Objects.equals(valuesList, that.valuesList) + && Objects.equals(supportsMonitoring, that.supportsMonitoring); + } + + @Override + public int hashCode() { + return Objects.hash( + customData, unit, dataType, minLimit, maxLimit, valuesList, supportsMonitoring); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("unit", unit) + .add("dataType", dataType) + .add("minLimit", minLimit) + .add("maxLimit", maxLimit) + .add("valuesList", valuesList) + .add("supportsMonitoring", supportsMonitoring) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VariableMonitoring.java b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VariableMonitoring.java new file mode 100644 index 000000000..c8c73da3a --- /dev/null +++ b/ocpp-v2/src/main/java/eu/chargetime/ocpp/v201/model/types/VariableMonitoring.java @@ -0,0 +1,356 @@ +/* + ChargeTime.eu - Java-OCA-OCPP + + MIT License + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package eu.chargetime.ocpp.v201.model.types; + +import eu.chargetime.ocpp.PropertyConstraintException; +import eu.chargetime.ocpp.utilities.MoreObjects; +import java.util.Objects; +import javax.annotation.Nullable; + +/** A monitoring setting for a variable. */ +public final class VariableMonitoring { + /** Custom data */ + @Nullable private CustomData customData; + + /** The identifier of the monitor. */ + private Integer id; + + /** + * Monitor only active when a transaction is ongoing on a component relevant to this transaction. + */ + private Boolean transaction; + + /** + * Value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + */ + private Double value; + + /** The type of this monitor, e.g. a threshold, delta or periodic monitor. */ + private MonitorEnum type; + + /** + * The severity that will be assigned to an event that is triggered by this monitor. The severity + * range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + *

+   * The severity levels have the following meaning: +
+   * *0-Danger* +
+   * Lives are potentially in danger. Urgent attention is needed and action should be taken immediately. +
+   * *1-Hardware Failure* +
+   * That the Charging Station is unable to continue regular operations due to Hardware issues. Action is required. +
+   * *2-System Failure* +
+   * That the Charging Station is unable to continue regular operations due to software or minor hardware issues. Action is required. +
+   * *3-Critical* +
+   * A critical error. Action is required. +
+   * *4-Error* +
+   * A non-urgent error. Action is required. +
+   * *5-Alert* +
+   * An alert event. Default severity for any type of monitoring event. +
+   * *6-Warning* +
+   * A warning event. Action may be required. +
+   * *7-Notice* +
+   * An unusual event. No immediate action is required. +
+   * *8-Informational* +
+   * A regular operational event. May be used for reporting, measuring throughput, etc. No action is required. +
+   * *9-Debug* +
+   * Information useful to developers for debugging, not useful during operations.
+   * 
+ */ + private Integer severity; + + /** + * Constructor for the VariableMonitoring class + * + * @param id The identifier of the monitor. + * @param transaction Monitor only active when a transaction is ongoing on a component relevant to + * this transaction. + * @param value Value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this + * is the interval in seconds. + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor. + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor. The severity range is 0-9, with 0 as the highest and 9 as the lowest severity + * level. + */ + public VariableMonitoring( + Integer id, Boolean transaction, Double value, MonitorEnum type, Integer severity) { + setId(id); + setTransaction(transaction); + setValue(value); + setType(type); + setSeverity(severity); + } + + /** + * Gets custom data + * + * @return Custom data + */ + @Nullable + public CustomData getCustomData() { + return customData; + } + + /** + * Sets custom data + * + * @param customData Custom data + */ + public void setCustomData(@Nullable CustomData customData) { + if (!isValidCustomData(customData)) { + throw new PropertyConstraintException(customData, "customData is invalid"); + } + this.customData = customData; + } + + /** + * Returns whether the given customData is valid + * + * @param customData the customData to check the validity of + * @return {@code true} if customData is valid, {@code false} if not + */ + private boolean isValidCustomData(@Nullable CustomData customData) { + return customData == null || customData.validate(); + } + + /** + * Adds custom data + * + * @param customData Custom data + * @return this + */ + public VariableMonitoring withCustomData(@Nullable CustomData customData) { + setCustomData(customData); + return this; + } + + /** + * Gets the identifier of the monitor. + * + * @return The identifier of the monitor + */ + public Integer getId() { + return id; + } + + /** + * Sets the identifier of the monitor. + * + * @param id The identifier of the monitor + */ + public void setId(Integer id) { + if (!isValidId(id)) { + throw new PropertyConstraintException(id, "id is invalid"); + } + this.id = id; + } + + /** + * Returns whether the given id is valid + * + * @param id the id to check the validity of + * @return {@code true} if id is valid, {@code false} if not + */ + private boolean isValidId(Integer id) { + return id != null; + } + + /** + * Gets monitor only active when a transaction is ongoing on a component relevant to this + * transaction. + * + * @return Monitor only active when a transaction is ongoing on a component relevant to this + * transaction + */ + public Boolean getTransaction() { + return transaction; + } + + /** + * Sets monitor only active when a transaction is ongoing on a component relevant to this + * transaction. + * + * @param transaction Monitor only active when a transaction is ongoing on a component relevant to + * this transaction + */ + public void setTransaction(Boolean transaction) { + if (!isValidTransaction(transaction)) { + throw new PropertyConstraintException(transaction, "transaction is invalid"); + } + this.transaction = transaction; + } + + /** + * Returns whether the given transaction is valid + * + * @param transaction the transaction to check the validity of + * @return {@code true} if transaction is valid, {@code false} if not + */ + private boolean isValidTransaction(Boolean transaction) { + return transaction != null; + } + + /** + * Gets value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + * + * @return Value for threshold or delta monitoring + */ + public Double getValue() { + return value; + } + + /** + * Sets value for threshold or delta monitoring. For Periodic or PeriodicClockAligned this is the + * interval in seconds. + * + * @param value Value for threshold or delta monitoring + */ + public void setValue(Double value) { + if (!isValidValue(value)) { + throw new PropertyConstraintException(value, "value is invalid"); + } + this.value = value; + } + + /** + * Returns whether the given value is valid + * + * @param value the value to check the validity of + * @return {@code true} if value is valid, {@code false} if not + */ + private boolean isValidValue(Double value) { + return value != null; + } + + /** + * Gets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @return The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public MonitorEnum getType() { + return type; + } + + /** + * Sets the type of this monitor, e.g. a threshold, delta or periodic monitor. + * + * @param type The type of this monitor, e.g. a threshold, delta or periodic monitor + */ + public void setType(MonitorEnum type) { + if (!isValidType(type)) { + throw new PropertyConstraintException(type, "type is invalid"); + } + this.type = type; + } + + /** + * Returns whether the given type is valid + * + * @param type the type to check the validity of + * @return {@code true} if type is valid, {@code false} if not + */ + private boolean isValidType(MonitorEnum type) { + return type != null; + } + + /** + * Gets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @return The severity that will be assigned to an event that is triggered by this monitor + */ + public Integer getSeverity() { + return severity; + } + + /** + * Sets the severity that will be assigned to an event that is triggered by this monitor. The + * severity range is 0-9, with 0 as the highest and 9 as the lowest severity level. + * + * @param severity The severity that will be assigned to an event that is triggered by this + * monitor + */ + public void setSeverity(Integer severity) { + if (!isValidSeverity(severity)) { + throw new PropertyConstraintException(severity, "severity is invalid"); + } + this.severity = severity; + } + + /** + * Returns whether the given severity is valid + * + * @param severity the severity to check the validity of + * @return {@code true} if severity is valid, {@code false} if not + */ + private boolean isValidSeverity(Integer severity) { + return severity != null; + } + + public boolean validate() { + return isValidCustomData(customData) + && isValidId(id) + && isValidTransaction(transaction) + && isValidValue(value) + && isValidType(type) + && isValidSeverity(severity); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VariableMonitoring that = (VariableMonitoring) o; + return Objects.equals(customData, that.customData) + && Objects.equals(id, that.id) + && Objects.equals(transaction, that.transaction) + && Objects.equals(value, that.value) + && Objects.equals(type, that.type) + && Objects.equals(severity, that.severity); + } + + @Override + public int hashCode() { + return Objects.hash(customData, id, transaction, value, type, severity); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("customData", customData) + .add("id", id) + .add("transaction", transaction) + .add("value", value) + .add("type", type) + .add("severity", severity) + .add("isValid", validate()) + .toString(); + } +} diff --git a/ocpp-v2/src/test/java/eu/chargetime/ocpp/v201/model/messages/BootNotificationRequestTest.java b/ocpp-v2/src/test/java/eu/chargetime/ocpp/v201/model/messages/BootNotificationRequestTest.java new file mode 100644 index 000000000..08ce2b571 --- /dev/null +++ b/ocpp-v2/src/test/java/eu/chargetime/ocpp/v201/model/messages/BootNotificationRequestTest.java @@ -0,0 +1,67 @@ +/* + * ChargeTime.eu - Java-OCA-OCPP + * + * Copyright (C) 2023 Robert Schlabbach (robert.schlabbach@ubitricity.com) + * + * MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package eu.chargetime.ocpp.v201.model.messages; + +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +import eu.chargetime.ocpp.JSONCommunicator; +import eu.chargetime.ocpp.v201.model.types.BootReasonEnum; +import eu.chargetime.ocpp.v201.model.types.ChargingStation; +import eu.chargetime.ocpp.v201.model.types.Modem; +import org.junit.Test; + +/** unit tests for OCPP 2.0.1 BootNotificationRequest serialization and deserialization */ +public class BootNotificationRequestTest { + @Test + public void testSerializationAndDeserialization() throws Exception { + JSONCommunicator communicator = new JSONCommunicator(null); + BootNotificationRequest originalRequest = + new BootNotificationRequest( + new ChargingStation("model", "vendor") + .withSerialNumber("123456789") + .withFirmwareVersion("0.0.1") + .withModem(new Modem().withImsi("1851").withIccid("16610")), + BootReasonEnum.Unknown); + String json = communicator.packPayload(originalRequest).toString(); + BootNotificationRequest deserializedRequest = + communicator.unpackPayload(json, BootNotificationRequest.class); + assertThat(deserializedRequest, notNullValue()); + assertThat(deserializedRequest, is(originalRequest)); + } + + @Test + public void testInvalidBootNotificationCanBeDeserialized() throws Exception { + JSONCommunicator communicator = new JSONCommunicator(null); + String json = "{}"; + BootNotificationRequest bootNotificationRequest = + communicator.unpackPayload(json, BootNotificationRequest.class); + assertThat(bootNotificationRequest, notNullValue()); + assertThat(bootNotificationRequest.validate(), is(false)); + } +} diff --git a/ocpp-v2_0-test/pom.xml b/ocpp-v2_0-test/pom.xml index 82a829d4d..b5f24fe32 100644 --- a/ocpp-v2_0-test/pom.xml +++ b/ocpp-v2_0-test/pom.xml @@ -6,7 +6,7 @@ eu.chargetime.ocpp v2_0-test - 1.0.2 + 1.2.0 jar Java-OCA-OCPP v2.0 - Integration test @@ -50,47 +50,47 @@ eu.chargetime.ocpp common - 1.0.2 + 1.2.0 eu.chargetime.ocpp v2_0 - 1.0.2 + 1.2.0 junit junit - 4.13.1 + 4.13.2 test org.spockframework spock-core - 1.0-groovy-2.4 + 2.3-groovy-4.0 test org.hamcrest hamcrest-core - 1.3 + 2.2 test ch.qos.logback logback-core - 1.2.9 + 1.4.14 test ch.qos.logback logback-classic - 1.2.0 + 1.4.13 test org.slf4j jul-to-slf4j - 1.7.10 + 2.0.12 test @@ -100,7 +100,7 @@ org.codehaus.gmavenplus gmavenplus-plugin - 1.13.1 + 3.0.2 @@ -113,7 +113,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.5.1 + 3.11.0 1.8 1.8 @@ -122,7 +122,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.2.5 true diff --git a/ocpp-v2_0/build.gradle b/ocpp-v2_0/build.gradle index 1026b166d..2d831fe5d 100644 --- a/ocpp-v2_0/build.gradle +++ b/ocpp-v2_0/build.gradle @@ -6,8 +6,8 @@ dependencies { compile project(':common') compile project(':OCPP-J') compile 'org.java-websocket:Java-WebSocket:1.5.3' - testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:1.10.19' + testCompile 'junit:junit:4.13.2' + testCompile 'org.mockito:mockito-core:4.11.0' testCompile 'org.hamcrest:hamcrest-core:1.3' } diff --git a/ocpp-v2_0/pom.xml b/ocpp-v2_0/pom.xml index 42a3cb2dc..344e10d02 100644 --- a/ocpp-v2_0/pom.xml +++ b/ocpp-v2_0/pom.xml @@ -6,7 +6,7 @@ eu.chargetime.ocpp v2_0 - 1.0.2 + 1.2.0 jar Java-OCA-OCPP v2.0 @@ -50,34 +50,34 @@ eu.chargetime.ocpp common - 1.0.2 + 1.2.0 eu.chargetime.ocpp OCPP-J - 1.0.2 + 1.2.0 org.java-websocket Java-WebSocket - 1.5.3 + 1.5.4 junit junit - 4.13.1 + 4.13.2 test org.mockito mockito-core - 1.10.19 + 4.11.0 test org.hamcrest hamcrest-core - 1.3 + 2.2 test @@ -91,12 +91,12 @@ 1.8 1.8 - 3.5.1 + 3.11.0 org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.3.0 attach-sources @@ -110,7 +110,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.6.3 attach-javadocs diff --git a/ocpp-v2_0/src/main/java/eu/chargetime/ocpp/JSONClient.java b/ocpp-v2_0/src/main/java/eu/chargetime/ocpp/JSONClient.java index 4ca00386c..c38eb6894 100644 --- a/ocpp-v2_0/src/main/java/eu/chargetime/ocpp/JSONClient.java +++ b/ocpp-v2_0/src/main/java/eu/chargetime/ocpp/JSONClient.java @@ -70,7 +70,7 @@ public JSONClient(String identity, JSONConfiguration configuration) { JSONCommunicator communicator = new JSONCommunicator(transmitter); featureRepository = new FeatureRepository(); ISession session = new SessionFactory(featureRepository).createSession(communicator); - client = new Client(session, featureRepository, new PromiseRepository()); + client = new Client(session, new PromiseRepository()); } /** diff --git a/ocpp-v2_0/src/main/java/eu/chargetime/ocpp/JSONServer.java b/ocpp-v2_0/src/main/java/eu/chargetime/ocpp/JSONServer.java index 0a8a35233..ba38c90fe 100644 --- a/ocpp-v2_0/src/main/java/eu/chargetime/ocpp/JSONServer.java +++ b/ocpp-v2_0/src/main/java/eu/chargetime/ocpp/JSONServer.java @@ -67,7 +67,7 @@ public JSONServer(JSONConfiguration configuration) { draftOcppOnly = new Draft_6455(Collections.emptyList(), protocols); logger.info("JSONServer 2.0 without HttpHealthCheckDraft"); this.listener = new WebSocketListener(sessionFactory, configuration, draftOcppOnly); - server = new Server(this.listener, featureRepository, new PromiseRepository()); + server = new Server(this.listener, new PromiseRepository()); } /** The constructor creates WS-ready server. */ diff --git a/ocpp-v2_0/src/test/java/eu/chargetime/ocpp/model/basic/test/BootNotificationRequestTest.java b/ocpp-v2_0/src/test/java/eu/chargetime/ocpp/model/basic/test/BootNotificationRequestTest.java index 6999c66d7..bd001be6e 100644 --- a/ocpp-v2_0/src/test/java/eu/chargetime/ocpp/model/basic/test/BootNotificationRequestTest.java +++ b/ocpp-v2_0/src/test/java/eu/chargetime/ocpp/model/basic/test/BootNotificationRequestTest.java @@ -35,7 +35,7 @@ of this software and associated documentation files (the "Software"), to deal import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public class BootNotificationRequestTest { diff --git a/pom.xml b/pom.xml index 0413d4941..64678f702 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ eu.chargetime.ocpp all - 1.1 + 1.2 pom Java-OCA-OCPP @@ -42,6 +42,8 @@ ocpp-v1_6-test ocpp-v2_0 ocpp-v2_0-test + ocpp-v2 + ocpp-v2-test @@ -64,7 +66,7 @@ 1.8 1.8 - 3.5.1 + 3.11.0 @@ -78,7 +80,7 @@ org.jacoco jacoco-maven-plugin - 0.8.5 + 0.8.11 prepare-agent diff --git a/settings.gradle b/settings.gradle index b39223e8d..d406ec038 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,6 +6,8 @@ rootProject.name = 'all' include(':common') project(':common').projectDir = file('ocpp-common') include(':OCPP-J') +include(':ocpp-v2') +include(':ocpp-v2-test') include(':v2_0') include(':v2_0-test') project(':v2_0').projectDir = file('ocpp-v2_0')