io.apiman.gateway.platforms.vertx3.common.config.InheritingHttpServerOptionsConverter.java Source code

Java tutorial

Introduction

Here is the source code for io.apiman.gateway.platforms.vertx3.common.config.InheritingHttpServerOptionsConverter.java

Source

/*
 * Copyright 2017 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.apiman.gateway.platforms.vertx3.common.config;

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

/**
 * Converter for {@link io.apiman.gateway.platforms.vertx3.common.config.InheritingHttpServerOptions}.
 *
 * NOTE: This class has been automatically generated from the {@link io.apiman.gateway.platforms.vertx3.common.config.InheritingHttpServerOptions} original class using Vert.x codegen.
 */
@SuppressWarnings({ "nls", "deprecation" })
public class InheritingHttpServerOptionsConverter {

    public static void fromJson(JsonObject json, InheritingHttpServerOptions obj) {
        if (json.getValue("acceptBacklog") instanceof Number) {
            obj.setAcceptBacklog(((Number) json.getValue("acceptBacklog")).intValue());
        }
        if (json.getValue("acceptUnmaskedFrames") instanceof Boolean) {
            obj.setAcceptUnmaskedFrames((Boolean) json.getValue("acceptUnmaskedFrames"));
        }
        if (json.getValue("alpnVersions") instanceof JsonArray) {
            java.util.ArrayList<io.vertx.core.http.HttpVersion> list = new java.util.ArrayList<>();
            json.getJsonArray("alpnVersions").forEach(item -> {
                if (item instanceof String)
                    list.add(io.vertx.core.http.HttpVersion.valueOf((String) item));
            });
            obj.setAlpnVersions(list);
        }
        if (json.getValue("clientAuth") instanceof String) {
            obj.setClientAuth(io.vertx.core.http.ClientAuth.valueOf((String) json.getValue("clientAuth")));
        }
        if (json.getValue("clientAuthRequired") instanceof Boolean) {
            obj.setClientAuthRequired((Boolean) json.getValue("clientAuthRequired"));
        }
        if (json.getValue("compressionLevel") instanceof Number) {
            obj.setCompressionLevel(((Number) json.getValue("compressionLevel")).intValue());
        }
        if (json.getValue("compressionSupported") instanceof Boolean) {
            obj.setCompressionSupported((Boolean) json.getValue("compressionSupported"));
        }
        if (json.getValue("crlPaths") instanceof JsonArray) {
            json.getJsonArray("crlPaths").forEach(item -> {
                if (item instanceof String)
                    obj.addCrlPath((String) item);
            });
        }
        if (json.getValue("crlValues") instanceof JsonArray) {
            json.getJsonArray("crlValues").forEach(item -> {
                if (item instanceof String)
                    obj.addCrlValue(io.vertx.core.buffer.Buffer
                            .buffer(java.util.Base64.getDecoder().decode((String) item)));
            });
        }
        if (json.getValue("decompressionSupported") instanceof Boolean) {
            obj.setDecompressionSupported((Boolean) json.getValue("decompressionSupported"));
        }
        if (json.getValue("enabledCipherSuites") instanceof JsonArray) {
            json.getJsonArray("enabledCipherSuites").forEach(item -> {
                if (item instanceof String)
                    obj.addEnabledCipherSuite((String) item);
            });
        }
        if (json.getValue("enabledSecureTransportProtocols") instanceof JsonArray) {
            json.getJsonArray("enabledSecureTransportProtocols").forEach(item -> {
                if (item instanceof String)
                    obj.addEnabledSecureTransportProtocol((String) item);
            });
        }
        if (json.getValue("handle100ContinueAutomatically") instanceof Boolean) {
            obj.setHandle100ContinueAutomatically((Boolean) json.getValue("handle100ContinueAutomatically"));
        }
        if (json.getValue("host") instanceof String) {
            obj.setHost((String) json.getValue("host"));
        }
        if (json.getValue("http2ConnectionWindowSize") instanceof Number) {
            obj.setHttp2ConnectionWindowSize(((Number) json.getValue("http2ConnectionWindowSize")).intValue());
        }
        if (json.getValue("idleTimeout") instanceof Number) {
            obj.setIdleTimeout(((Number) json.getValue("idleTimeout")).intValue());
        }
        if (json.getValue("initialSettings") instanceof JsonObject) {
            obj.setInitialSettings(
                    new io.vertx.core.http.Http2Settings((JsonObject) json.getValue("initialSettings")));
        }
        if (json.getValue("jdkSslEngineOptions") instanceof JsonObject) {
            obj.setJdkSslEngineOptions(
                    new io.vertx.core.net.JdkSSLEngineOptions((JsonObject) json.getValue("jdkSslEngineOptions")));
        }
        if (json.getValue("keyStoreOptions") instanceof JsonObject) {
            obj.setKeyStoreOptions(new io.vertx.core.net.JksOptions((JsonObject) json.getValue("keyStoreOptions")));
        }
        if (json.getValue("logActivity") instanceof Boolean) {
            obj.setLogActivity((Boolean) json.getValue("logActivity"));
        }
        if (json.getValue("maxChunkSize") instanceof Number) {
            obj.setMaxChunkSize(((Number) json.getValue("maxChunkSize")).intValue());
        }
        if (json.getValue("maxHeaderSize") instanceof Number) {
            obj.setMaxHeaderSize(((Number) json.getValue("maxHeaderSize")).intValue());
        }
        if (json.getValue("maxInitialLineLength") instanceof Number) {
            obj.setMaxInitialLineLength(((Number) json.getValue("maxInitialLineLength")).intValue());
        }
        if (json.getValue("maxWebsocketFrameSize") instanceof Number) {
            obj.setMaxWebsocketFrameSize(((Number) json.getValue("maxWebsocketFrameSize")).intValue());
        }
        if (json.getValue("maxWebsocketMessageSize") instanceof Number) {
            obj.setMaxWebsocketMessageSize(((Number) json.getValue("maxWebsocketMessageSize")).intValue());
        }
        if (json.getValue("openSslEngineOptions") instanceof JsonObject) {
            obj.setOpenSslEngineOptions(
                    new io.vertx.core.net.OpenSSLEngineOptions((JsonObject) json.getValue("openSslEngineOptions")));
        }
        if (json.getValue("pemKeyCertOptions") instanceof JsonObject) {
            obj.setPemKeyCertOptions(
                    new io.vertx.core.net.PemKeyCertOptions((JsonObject) json.getValue("pemKeyCertOptions")));
        }
        if (json.getValue("pemTrustOptions") instanceof JsonObject) {
            obj.setPemTrustOptions(
                    new io.vertx.core.net.PemTrustOptions((JsonObject) json.getValue("pemTrustOptions")));
        }
        if (json.getValue("pfxKeyCertOptions") instanceof JsonObject) {
            obj.setPfxKeyCertOptions(
                    new io.vertx.core.net.PfxOptions((JsonObject) json.getValue("pfxKeyCertOptions")));
        }
        if (json.getValue("pfxTrustOptions") instanceof JsonObject) {
            obj.setPfxTrustOptions(new io.vertx.core.net.PfxOptions((JsonObject) json.getValue("pfxTrustOptions")));
        }
        if (json.getValue("port") instanceof Number) {
            obj.setPort(((Number) json.getValue("port")).intValue());
        }
        if (json.getValue("receiveBufferSize") instanceof Number) {
            obj.setReceiveBufferSize(((Number) json.getValue("receiveBufferSize")).intValue());
        }
        if (json.getValue("reuseAddress") instanceof Boolean) {
            obj.setReuseAddress((Boolean) json.getValue("reuseAddress"));
        }
        if (json.getValue("sendBufferSize") instanceof Number) {
            obj.setSendBufferSize(((Number) json.getValue("sendBufferSize")).intValue());
        }
        if (json.getValue("soLinger") instanceof Number) {
            obj.setSoLinger(((Number) json.getValue("soLinger")).intValue());
        }
        if (json.getValue("ssl") instanceof Boolean) {
            obj.setSsl((Boolean) json.getValue("ssl"));
        }
        if (json.getValue("tcpKeepAlive") instanceof Boolean) {
            obj.setTcpKeepAlive((Boolean) json.getValue("tcpKeepAlive"));
        }
        if (json.getValue("tcpNoDelay") instanceof Boolean) {
            obj.setTcpNoDelay((Boolean) json.getValue("tcpNoDelay"));
        }
        if (json.getValue("trafficClass") instanceof Number) {
            obj.setTrafficClass(((Number) json.getValue("trafficClass")).intValue());
        }
        if (json.getValue("trustStoreOptions") instanceof JsonObject) {
            obj.setTrustStoreOptions(
                    new io.vertx.core.net.JksOptions((JsonObject) json.getValue("trustStoreOptions")));
        }
        if (json.getValue("useAlpn") instanceof Boolean) {
            obj.setUseAlpn((Boolean) json.getValue("useAlpn"));
        }
        if (json.getValue("usePooledBuffers") instanceof Boolean) {
            obj.setUsePooledBuffers((Boolean) json.getValue("usePooledBuffers"));
        }
        if (json.getValue("websocketSubProtocols") instanceof String) {
            obj.setWebsocketSubProtocols((String) json.getValue("websocketSubProtocols"));
        }
    }

    public static void toJson(InheritingHttpServerOptions obj, JsonObject json) {
        json.put("acceptBacklog", obj.getAcceptBacklog());
        json.put("acceptUnmaskedFrames", obj.isAcceptUnmaskedFrames());
        if (obj.getAlpnVersions() != null) {
            JsonArray array = new JsonArray();
            obj.getAlpnVersions().forEach(item -> array.add(item.name()));
            json.put("alpnVersions", array);
        }
        if (obj.getClientAuth() != null) {
            json.put("clientAuth", obj.getClientAuth().name());
        }
        json.put("clientAuthRequired", obj.isClientAuthRequired());
        json.put("compressionLevel", obj.getCompressionLevel());
        json.put("compressionSupported", obj.isCompressionSupported());
        if (obj.getCrlPaths() != null) {
            JsonArray array = new JsonArray();
            obj.getCrlPaths().forEach(item -> array.add(item));
            json.put("crlPaths", array);
        }
        if (obj.getCrlValues() != null) {
            JsonArray array = new JsonArray();
            obj.getCrlValues().forEach(item -> array.add(item.getBytes()));
            json.put("crlValues", array);
        }
        json.put("decompressionSupported", obj.isDecompressionSupported());
        if (obj.getEnabledCipherSuites() != null) {
            JsonArray array = new JsonArray();
            obj.getEnabledCipherSuites().forEach(item -> array.add(item));
            json.put("enabledCipherSuites", array);
        }
        if (obj.getEnabledSecureTransportProtocols() != null) {
            JsonArray array = new JsonArray();
            obj.getEnabledSecureTransportProtocols().forEach(item -> array.add(item));
            json.put("enabledSecureTransportProtocols", array);
        }
        json.put("handle100ContinueAutomatically", obj.isHandle100ContinueAutomatically());
        if (obj.getHost() != null) {
            json.put("host", obj.getHost());
        }
        json.put("http2ConnectionWindowSize", obj.getHttp2ConnectionWindowSize());
        json.put("idleTimeout", obj.getIdleTimeout());
        if (obj.getInitialSettings() != null) {
            json.put("initialSettings", obj.getInitialSettings().toJson());
        }
        if (obj.getJdkSslEngineOptions() != null) {
            json.put("jdkSslEngineOptions", obj.getJdkSslEngineOptions().toJson());
        }
        if (obj.getKeyStoreOptions() != null) {
            json.put("keyStoreOptions", obj.getKeyStoreOptions().toJson());
        }
        json.put("logActivity", obj.getLogActivity());
        json.put("maxChunkSize", obj.getMaxChunkSize());
        json.put("maxHeaderSize", obj.getMaxHeaderSize());
        json.put("maxInitialLineLength", obj.getMaxInitialLineLength());
        json.put("maxWebsocketFrameSize", obj.getMaxWebsocketFrameSize());
        json.put("maxWebsocketMessageSize", obj.getMaxWebsocketMessageSize());
        if (obj.getOpenSslEngineOptions() != null) {
            json.put("openSslEngineOptions", obj.getOpenSslEngineOptions().toJson());
        }
        if (obj.getPemKeyCertOptions() != null) {
            json.put("pemKeyCertOptions", obj.getPemKeyCertOptions().toJson());
        }
        if (obj.getPemTrustOptions() != null) {
            json.put("pemTrustOptions", obj.getPemTrustOptions().toJson());
        }
        if (obj.getPfxKeyCertOptions() != null) {
            json.put("pfxKeyCertOptions", obj.getPfxKeyCertOptions().toJson());
        }
        if (obj.getPfxTrustOptions() != null) {
            json.put("pfxTrustOptions", obj.getPfxTrustOptions().toJson());
        }
        json.put("port", obj.getPort());
        json.put("receiveBufferSize", obj.getReceiveBufferSize());
        json.put("reuseAddress", obj.isReuseAddress());
        json.put("sendBufferSize", obj.getSendBufferSize());
        json.put("soLinger", obj.getSoLinger());
        json.put("ssl", obj.isSsl());
        json.put("tcpKeepAlive", obj.isTcpKeepAlive());
        json.put("tcpNoDelay", obj.isTcpNoDelay());
        json.put("trafficClass", obj.getTrafficClass());
        if (obj.getTrustStoreOptions() != null) {
            json.put("trustStoreOptions", obj.getTrustStoreOptions().toJson());
        }
        json.put("useAlpn", obj.isUseAlpn());
        json.put("usePooledBuffers", obj.isUsePooledBuffers());
        if (obj.getWebsocketSubProtocols() != null) {
            json.put("websocketSubProtocols", obj.getWebsocketSubProtocols());
        }
    }
}