All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.chibchasoft.vertx.verticle.deployment.DependentsDeployment Maven / Gradle / Ivy

There is a newer version: 1.0.3
Show newest version
/*
 * Copyright (c) 2017 chibchasoft.com
 * ------------------------------------------------------
 * All rights reserved. This program and the accompanying materials are made
 * available under the terms of the Apache License v2.0 which accompanies
 * this distribution.
 *
 *      The Apache License v2.0 is available at
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Author Juan Velez
 */
package com.chibchasoft.vertx.verticle.deployment;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

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

/**
 * 

Settings for configuring one or more verticle deployments. Each verticle deployment may have * zero or more verticles(dependents) that will be deployed upon successful deployment of this * verticle.

*

Each verticle may have its own {@link DeploymentOptions} and a list of zero or more * dependent {@code DependentDeployment}

*

It provides capabilities to convert from/to JsonObject.

* * @see DeploymentConfiguration * * @author Juan Velez */ public class DependentsDeployment { private List configurations = new ArrayList<>(); /** * Default constructor */ public DependentsDeployment() { } /** * Constructor for creating a instance from JSON * * @param json the JSON */ public DependentsDeployment(JsonObject json) { Objects.requireNonNull(json, "json is required"); fromJson(json); } /** * Returns the (non-null) list of {@link DeploymentConfiguration}s * @return The (non-null) list of {@link DeploymentConfiguration}s */ public List getConfigurations() { return configurations; } /** * Populates this object with the information from the supplied JsonObject * @param json The JSON Object */ public void fromJson(JsonObject json) { Objects.requireNonNull(json, "json is required"); if (json.getValue("configurations") instanceof JsonArray) { json.getJsonArray("configurations").forEach(item -> { if (item instanceof JsonObject) { DeploymentConfiguration cfg = new DeploymentConfiguration(); cfg.fromJson((JsonObject) item); getConfigurations().add(cfg); } }); } } /** * Returns a JsonObject populated with the information from this object * @return The JsonObject */ public JsonObject toJson() { JsonObject json = new JsonObject(); if (this.getConfigurations() != null) { JsonArray array = new JsonArray(); this.getConfigurations().forEach(item -> array.add(item.toJson())); json.put("configurations", array); } return json; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("DependentsDeployment [configurations=").append(configurations).append("]"); return builder.toString(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy