/** * Creates a new {@code Connection} object from the specified JSON object. * * @param jsonObject a JSON object which provides the data for the Connection to be created. * @return a new Connection which is initialised with the extracted data from {@code jsonObject}. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if {@code jsonObject} is not an appropriate JSON object. */ public static Connection fromJson(final JsonObject jsonObject) { final ConnectionType type = getConnectionTypeOrThrow(jsonObject); final ConnectionBuilder builder = new Builder(type) .id(jsonObject.getValueOrThrow(JsonFields.ID)) .connectionStatus(getConnectionStatusOrThrow(jsonObject)) .uri(jsonObject.getValueOrThrow(JsonFields.URI)) .sources(getSources(jsonObject, type)) .targets(getTargets(jsonObject, type)) .name(jsonObject.getValue(JsonFields.NAME).orElse(null)) .mappingContext(jsonObject.getValue(JsonFields.MAPPING_CONTEXT) .map(ConnectivityModelFactory::mappingContextFromJson) .orElse(null)) .specificConfig(getSpecificConfiguration(jsonObject)) .tags(getTags(jsonObject)); jsonObject.getValue(JsonFields.CREDENTIALS).ifPresent(builder::credentialsFromJson); jsonObject.getValue(JsonFields.CLIENT_COUNT).ifPresent(builder::clientCount); jsonObject.getValue(JsonFields.FAILOVER_ENABLED).ifPresent(builder::failoverEnabled); jsonObject.getValue(JsonFields.VALIDATE_CERTIFICATES).ifPresent(builder::validateCertificate); jsonObject.getValue(JsonFields.PROCESSOR_POOL_SIZE).ifPresent(builder::processorPoolSize); jsonObject.getValue(JsonFields.TRUSTED_CERTIFICATES).ifPresent(builder::trustedCertificates); return builder.build(); }
/** * Creates a new {@code Connection} object from the specified JSON object. * * @param jsonObject a JSON object which provides the data for the Connection to be created. * @return a new Connection which is initialised with the extracted data from {@code jsonObject}. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws org.eclipse.ditto.json.JsonParseException if {@code jsonObject} is not an appropriate JSON object. */ public static Connection fromJson(final JsonObject jsonObject) { final ConnectionType type = getConnectionTypeOrThrow(jsonObject); final ConnectionBuilder builder = new Builder(type) .id(jsonObject.getValueOrThrow(JsonFields.ID)) .connectionStatus(getConnectionStatusOrThrow(jsonObject)) .uri(jsonObject.getValueOrThrow(JsonFields.URI)) .sources(getSources(jsonObject, type)) .targets(getTargets(jsonObject, type)) .name(jsonObject.getValue(JsonFields.NAME).orElse(null)) .mappingContext(jsonObject.getValue(JsonFields.MAPPING_CONTEXT) .map(ConnectivityModelFactory::mappingContextFromJson) .orElse(null)) .specificConfig(getSpecificConfiguration(jsonObject)) .tags(getTags(jsonObject)); jsonObject.getValue(JsonFields.CREDENTIALS).ifPresent(builder::credentialsFromJson); jsonObject.getValue(JsonFields.CLIENT_COUNT).ifPresent(builder::clientCount); jsonObject.getValue(JsonFields.FAILOVER_ENABLED).ifPresent(builder::failoverEnabled); jsonObject.getValue(JsonFields.VALIDATE_CERTIFICATES).ifPresent(builder::validateCertificate); jsonObject.getValue(JsonFields.PROCESSOR_POOL_SIZE).ifPresent(builder::processorPoolSize); jsonObject.getValue(JsonFields.TRUSTED_CERTIFICATES).ifPresent(builder::trustedCertificates); return builder.build(); }
/** * Returns a new {@code ConnectionBuilder} object. * * @param connection the connection to use for initializing the builder. * @return new instance of {@code ImmutableConnectionBuilder}. * @throws NullPointerException if {@code connection} is {@code null}. */ public static ConnectionBuilder getBuilder(final Connection connection) { checkNotNull(connection, "Connection"); return new Builder(connection.getConnectionType()) .id(connection.getId()) .connectionStatus(connection.getConnectionStatus()) .credentials(connection.getCredentials().orElse(null)) .uri(connection.getUri()) .trustedCertificates(connection.getTrustedCertificates().orElse(null)) .failoverEnabled(connection.isFailoverEnabled()) .validateCertificate(connection.isValidateCertificates()) .processorPoolSize(connection.getProcessorPoolSize()) .sources(connection.getSources()) .targets(connection.getTargets()) .clientCount(connection.getClientCount()) .specificConfig(connection.getSpecificConfig()) .mappingContext(connection.getMappingContext().orElse(null)) .name(connection.getName().orElse(null)) .tags(connection.getTags()); }
/** * Returns a new {@code ConnectionBuilder} object. * * @param connection the connection to use for initializing the builder. * @return new instance of {@code ImmutableConnectionBuilder}. * @throws NullPointerException if {@code connection} is {@code null}. */ public static ConnectionBuilder getBuilder(final Connection connection) { checkNotNull(connection, "Connection"); return new Builder(connection.getConnectionType()) .id(connection.getId()) .connectionStatus(connection.getConnectionStatus()) .credentials(connection.getCredentials().orElse(null)) .uri(connection.getUri()) .trustedCertificates(connection.getTrustedCertificates().orElse(null)) .failoverEnabled(connection.isFailoverEnabled()) .validateCertificate(connection.isValidateCertificates()) .processorPoolSize(connection.getProcessorPoolSize()) .sources(connection.getSources()) .targets(connection.getTargets()) .clientCount(connection.getClientCount()) .specificConfig(connection.getSpecificConfig()) .mappingContext(connection.getMappingContext().orElse(null)) .name(connection.getName().orElse(null)) .tags(connection.getTags()); }
/** * Returns a new {@code ConnectionBuilder} object. * * @param id the connection ID. * @param connectionType the connection type. * @param connectionStatus the connection status. * @param uri the URI. * @return new instance of {@code ConnectionBuilder}. * @throws NullPointerException if any argument is {@code null}. */ public static ConnectionBuilder getBuilder(final String id, final ConnectionType connectionType, final ConnectionStatus connectionStatus, final String uri) { return new Builder(connectionType) .id(id) .connectionStatus(connectionStatus) .uri(uri); }
/** * Returns a new {@code ConnectionBuilder} object. * * @param id the connection ID. * @param connectionType the connection type. * @param connectionStatus the connection status. * @param uri the URI. * @return new instance of {@code ConnectionBuilder}. * @throws NullPointerException if any argument is {@code null}. */ public static ConnectionBuilder getBuilder(final String id, final ConnectionType connectionType, final ConnectionStatus connectionStatus, final String uri) { return new Builder(connectionType) .id(id) .connectionStatus(connectionStatus) .uri(uri); }