Skip to content

Commit

Permalink
Data object conversion helper
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Jul 27, 2015
1 parent 5368c54 commit 0ef6658
Show file tree
Hide file tree
Showing 58 changed files with 2,293 additions and 199 deletions.
14 changes: 14 additions & 0 deletions pom.xml
Expand Up @@ -60,6 +60,7 @@
<junit.version>4.11</junit.version>
<apacheds-protocol-dns.version>1.5.7</apacheds-protocol-dns.version>
<asciidoc.dir>${project.basedir}/src/main/asciidoc</asciidoc.dir>
<generated.dir>${project.basedir}/src/main/generated</generated.dir>
<stack.version>3.1.0-SNAPSHOT</stack.version>

</properties>
Expand Down Expand Up @@ -168,6 +169,18 @@
<arg>-Adocgen.output=${asciidoc.dir}/java</arg>
<arg>-AoutputDirectory=${project.basedir}/src/main</arg>
</compilerArgs>
<generatedSourcesDirectory>${generated.dir}</generatedSourcesDirectory>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<configuration>
<annotationProcessors>
<annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
</annotationProcessors>
<compilerArgs>
<arg>-AoutputDirectory=${project.basedir}/src/test</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -235,6 +248,7 @@
<filesets>
<fileset>
<directory>${asciidoc.dir}</directory>
<directory>${generated.dir}</directory>
</fileset>
</filesets>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion src/main/asciidoc/cheatsheet/HttpServerOptions.adoc
Expand Up @@ -136,7 +136,7 @@ Set the trust options in jks format, aka Java trustore+++
|+++
Set whether Netty pooled buffers are enabled+++

|[[websocketSubProtocol]]`websocketSubProtocol`
|[[websocketSubProtocols]]`websocketSubProtocols`
|`String`
|+++
Set the websocket subprotocols supported by the server.+++
Expand Down
12 changes: 0 additions & 12 deletions src/main/asciidoc/cheatsheet/KeyCertOptions.adoc

This file was deleted.

8 changes: 4 additions & 4 deletions src/main/asciidoc/cheatsheet/OpenOptions.adoc
Expand Up @@ -20,15 +20,15 @@ Set whether the file should be created if it does not already exist.+++
|+++
Set whether the file should be created and fail if it does exist already.+++

|[[dSync]]`dSync`
|[[deleteOnClose]]`deleteOnClose`
|`Boolean`
|+++
Set whether every write to the file's content ill be written synchronously to the underlying hardware.+++
Set whether the file should be deleted when it's closed, or the JVM is shutdown.+++

|[[deleteOnClose]]`deleteOnClose`
|[[dsync]]`dsync`
|`Boolean`
|+++
Set whether the file should be deleted when it's closed, or the JVM is shutdown.+++
Set whether every write to the file's content ill be written synchronously to the underlying hardware.+++

|[[perms]]`perms`
|`String`
Expand Down
12 changes: 0 additions & 12 deletions src/main/asciidoc/cheatsheet/TrustOptions.adoc

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/asciidoc/java/filesystem.adoc
Expand Up @@ -200,7 +200,7 @@ close or when the JVM is shutdown with `link:../../apidocs/io/vertx/core/file/Op
==== Flushing data to underlying storage.

In the `OpenOptions`, you can enable/disable the automatic synchronisation of the content on every write using
`link:../../apidocs/io/vertx/core/file/OpenOptions.html#setDSync-boolean-[setDSync]`. In that case, you can manually flush any writes from the OS
`link:../../apidocs/io/vertx/core/file/OpenOptions.html#setDsync-boolean-[setDsync]`. In that case, you can manually flush any writes from the OS
cache by calling the `link:../../apidocs/io/vertx/core/file/AsyncFile.html#flush--[flush]` method.

This method can also be called with an handler which will be called when the flush is complete.
Expand Down
69 changes: 69 additions & 0 deletions src/main/generated/io/vertx/core/DeploymentOptionsHelper.java
@@ -0,0 +1,69 @@
package io.vertx.core;

import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;

public class DeploymentOptionsHelper {

public static void fromJson(JsonObject json, DeploymentOptions obj) {
if (json.getValue("config") instanceof JsonObject) {
obj.setConfig(((JsonObject)json.getValue("config")).copy());
}
if (json.getValue("extraClasspath") instanceof JsonArray) {
obj.setExtraClasspath(
((java.util.List<?>)json.getJsonArray("extraClasspath").getList()).
stream().
map(item -> (String)item).
collect(java.util.stream.Collectors.toList()));
}
if (json.getValue("ha") instanceof Boolean) {
obj.setHa((Boolean)json.getValue("ha"));
}
if (json.getValue("instances") instanceof Number) {
obj.setInstances(((Number)json.getValue("instances")).intValue());
}
if (json.getValue("isolatedClasses") instanceof JsonArray) {
obj.setIsolatedClasses(
((java.util.List<?>)json.getJsonArray("isolatedClasses").getList()).
stream().
map(item -> (String)item).
collect(java.util.stream.Collectors.toList()));
}
if (json.getValue("isolationGroup") instanceof String) {
obj.setIsolationGroup((String)json.getValue("isolationGroup"));
}
if (json.getValue("multiThreaded") instanceof Boolean) {
obj.setMultiThreaded((Boolean)json.getValue("multiThreaded"));
}
if (json.getValue("worker") instanceof Boolean) {
obj.setWorker((Boolean)json.getValue("worker"));
}
}

public static void toJson(DeploymentOptions obj, JsonObject json) {
if (obj.getConfig() != null) {
json.put("config", obj.getConfig());
}
if (obj.getExtraClasspath() != null) {
json.put("extraClasspath", new JsonArray(
obj.getExtraClasspath().
stream().
map(item -> item).
collect(java.util.stream.Collectors.toList())));
}
json.put("ha", obj.isHa());
json.put("instances", obj.getInstances());
if (obj.getIsolatedClasses() != null) {
json.put("isolatedClasses", new JsonArray(
obj.getIsolatedClasses().
stream().
map(item -> item).
collect(java.util.stream.Collectors.toList())));
}
if (obj.getIsolationGroup() != null) {
json.put("isolationGroup", obj.getIsolationGroup());
}
json.put("multiThreaded", obj.isMultiThreaded());
json.put("worker", obj.isWorker());
}
}
83 changes: 83 additions & 0 deletions src/main/generated/io/vertx/core/VertxOptionsHelper.java
@@ -0,0 +1,83 @@
package io.vertx.core;

import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;

public class VertxOptionsHelper {

public static void fromJson(JsonObject json, VertxOptions obj) {
if (json.getValue("blockedThreadCheckInterval") instanceof Number) {
obj.setBlockedThreadCheckInterval(((Number)json.getValue("blockedThreadCheckInterval")).longValue());
}
if (json.getValue("clusterHost") instanceof String) {
obj.setClusterHost((String)json.getValue("clusterHost"));
}
if (json.getValue("clusterPingInterval") instanceof Number) {
obj.setClusterPingInterval(((Number)json.getValue("clusterPingInterval")).longValue());
}
if (json.getValue("clusterPingReplyInterval") instanceof Number) {
obj.setClusterPingReplyInterval(((Number)json.getValue("clusterPingReplyInterval")).longValue());
}
if (json.getValue("clusterPort") instanceof Number) {
obj.setClusterPort(((Number)json.getValue("clusterPort")).intValue());
}
if (json.getValue("clustered") instanceof Boolean) {
obj.setClustered((Boolean)json.getValue("clustered"));
}
if (json.getValue("eventLoopPoolSize") instanceof Number) {
obj.setEventLoopPoolSize(((Number)json.getValue("eventLoopPoolSize")).intValue());
}
if (json.getValue("haEnabled") instanceof Boolean) {
obj.setHAEnabled((Boolean)json.getValue("haEnabled"));
}
if (json.getValue("haGroup") instanceof String) {
obj.setHAGroup((String)json.getValue("haGroup"));
}
if (json.getValue("internalBlockingPoolSize") instanceof Number) {
obj.setInternalBlockingPoolSize(((Number)json.getValue("internalBlockingPoolSize")).intValue());
}
if (json.getValue("maxEventLoopExecuteTime") instanceof Number) {
obj.setMaxEventLoopExecuteTime(((Number)json.getValue("maxEventLoopExecuteTime")).longValue());
}
if (json.getValue("maxWorkerExecuteTime") instanceof Number) {
obj.setMaxWorkerExecuteTime(((Number)json.getValue("maxWorkerExecuteTime")).longValue());
}
if (json.getValue("metricsOptions") instanceof JsonObject) {
obj.setMetricsOptions(new io.vertx.core.metrics.MetricsOptions((JsonObject)json.getValue("metricsOptions")));
}
if (json.getValue("quorumSize") instanceof Number) {
obj.setQuorumSize(((Number)json.getValue("quorumSize")).intValue());
}
if (json.getValue("warningExceptionTime") instanceof Number) {
obj.setWarningExceptionTime(((Number)json.getValue("warningExceptionTime")).longValue());
}
if (json.getValue("workerPoolSize") instanceof Number) {
obj.setWorkerPoolSize(((Number)json.getValue("workerPoolSize")).intValue());
}
}

public static void toJson(VertxOptions obj, JsonObject json) {
json.put("blockedThreadCheckInterval", obj.getBlockedThreadCheckInterval());
if (obj.getClusterHost() != null) {
json.put("clusterHost", obj.getClusterHost());
}
json.put("clusterPingInterval", obj.getClusterPingInterval());
json.put("clusterPingReplyInterval", obj.getClusterPingReplyInterval());
json.put("clusterPort", obj.getClusterPort());
json.put("clustered", obj.isClustered());
json.put("eventLoopPoolSize", obj.getEventLoopPoolSize());
json.put("haEnabled", obj.isHAEnabled());
if (obj.getHAGroup() != null) {
json.put("haGroup", obj.getHAGroup());
}
json.put("internalBlockingPoolSize", obj.getInternalBlockingPoolSize());
json.put("maxEventLoopExecuteTime", obj.getMaxEventLoopExecuteTime());
json.put("maxWorkerExecuteTime", obj.getMaxWorkerExecuteTime());
if (obj.getMetricsOptions() != null) {
json.put("metricsOptions", obj.getMetricsOptions().toJson());
}
json.put("quorumSize", obj.getQuorumSize());
json.put("warningExceptionTime", obj.getWarningExceptionTime());
json.put("workerPoolSize", obj.getWorkerPoolSize());
}
}
@@ -0,0 +1,35 @@
package io.vertx.core.datagram;

import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;

public class DatagramSocketOptionsHelper {

public static void fromJson(JsonObject json, DatagramSocketOptions obj) {
if (json.getValue("broadcast") instanceof Boolean) {
obj.setBroadcast((Boolean)json.getValue("broadcast"));
}
if (json.getValue("ipV6") instanceof Boolean) {
obj.setIpV6((Boolean)json.getValue("ipV6"));
}
if (json.getValue("loopbackModeDisabled") instanceof Boolean) {
obj.setLoopbackModeDisabled((Boolean)json.getValue("loopbackModeDisabled"));
}
if (json.getValue("multicastNetworkInterface") instanceof String) {
obj.setMulticastNetworkInterface((String)json.getValue("multicastNetworkInterface"));
}
if (json.getValue("multicastTimeToLive") instanceof Number) {
obj.setMulticastTimeToLive(((Number)json.getValue("multicastTimeToLive")).intValue());
}
}

public static void toJson(DatagramSocketOptions obj, JsonObject json) {
json.put("broadcast", obj.isBroadcast());
json.put("ipV6", obj.isIpV6());
json.put("loopbackModeDisabled", obj.isLoopbackModeDisabled());
if (obj.getMulticastNetworkInterface() != null) {
json.put("multicastNetworkInterface", obj.getMulticastNetworkInterface());
}
json.put("multicastTimeToLive", obj.getMulticastTimeToLive());
}
}
@@ -0,0 +1,23 @@
package io.vertx.core.eventbus;

import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;

public class DeliveryOptionsHelper {

public static void fromJson(JsonObject json, DeliveryOptions obj) {
if (json.getValue("codecName") instanceof String) {
obj.setCodecName((String)json.getValue("codecName"));
}
if (json.getValue("sendTimeout") instanceof Number) {
obj.setSendTimeout(((Number)json.getValue("sendTimeout")).longValue());
}
}

public static void toJson(DeliveryOptions obj, JsonObject json) {
if (obj.getCodecName() != null) {
json.put("codecName", obj.getCodecName());
}
json.put("sendTimeout", obj.getSendTimeout());
}
}
55 changes: 55 additions & 0 deletions src/main/generated/io/vertx/core/file/OpenOptionsHelper.java
@@ -0,0 +1,55 @@
package io.vertx.core.file;

import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;

public class OpenOptionsHelper {

public static void fromJson(JsonObject json, OpenOptions obj) {
if (json.getValue("create") instanceof Boolean) {
obj.setCreate((Boolean)json.getValue("create"));
}
if (json.getValue("createNew") instanceof Boolean) {
obj.setCreateNew((Boolean)json.getValue("createNew"));
}
if (json.getValue("deleteOnClose") instanceof Boolean) {
obj.setDeleteOnClose((Boolean)json.getValue("deleteOnClose"));
}
if (json.getValue("dsync") instanceof Boolean) {
obj.setDsync((Boolean)json.getValue("dsync"));
}
if (json.getValue("perms") instanceof String) {
obj.setPerms((String)json.getValue("perms"));
}
if (json.getValue("read") instanceof Boolean) {
obj.setRead((Boolean)json.getValue("read"));
}
if (json.getValue("sparse") instanceof Boolean) {
obj.setSparse((Boolean)json.getValue("sparse"));
}
if (json.getValue("sync") instanceof Boolean) {
obj.setSync((Boolean)json.getValue("sync"));
}
if (json.getValue("truncateExisting") instanceof Boolean) {
obj.setTruncateExisting((Boolean)json.getValue("truncateExisting"));
}
if (json.getValue("write") instanceof Boolean) {
obj.setWrite((Boolean)json.getValue("write"));
}
}

public static void toJson(OpenOptions obj, JsonObject json) {
json.put("create", obj.isCreate());
json.put("createNew", obj.isCreateNew());
json.put("deleteOnClose", obj.isDeleteOnClose());
json.put("dsync", obj.isDsync());
if (obj.getPerms() != null) {
json.put("perms", obj.getPerms());
}
json.put("read", obj.isRead());
json.put("sparse", obj.isSparse());
json.put("sync", obj.isSync());
json.put("truncateExisting", obj.isTruncateExisting());
json.put("write", obj.isWrite());
}
}

0 comments on commit 0ef6658

Please sign in to comment.