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

io.cloudslang.content.xml.entities.inputs.ConvertXmlToJsonInputs Maven / Gradle / Ivy

The newest version!
/*
 * (c) Copyright 2019 EntIT Software LLC, a Micro Focus company, L.P.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Apache License v2.0 which accompany this distribution.
 *
 * The Apache License is available 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.cloudslang.content.xml.entities.inputs;

import io.cloudslang.content.xml.utils.Constants.Defaults;

import static io.cloudslang.content.xml.utils.Constants.EMPTY_STRING;
import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
import static org.apache.commons.lang3.StringUtils.defaultIfEmpty;

/**
 * Created by victor on 10.08.2016.
 */
public class ConvertXmlToJsonInputs {
    private String xml;
    private String textElementsName;
    private boolean includeRootElement;
    private boolean includeAttributes;
    private boolean prettyPrint;
    private String parsingFeatures;

    public ConvertXmlToJsonInputs(ConvertXmlToJsonInputsBuilder builder) {
        this.xml = builder.xml;
        this.textElementsName = builder.textElementsName;
        this.includeRootElement = builder.includeRootElement;
        this.includeAttributes = builder.includeAttributes;
        this.prettyPrint = builder.prettyPrint;
        this.parsingFeatures = builder.parsingFeatures;
    }

    public String getXml() {
        return xml;
    }

    public String getTextElementsName() {
        return textElementsName;
    }

    public boolean getIncludeRootElement() {
        return includeRootElement;
    }

    public boolean getIncludeAttributes() {
        return includeAttributes;
    }

    public boolean getPrettyPrint() {
        return prettyPrint;
    }

    public String getParsingFeatures() {
        return parsingFeatures;
    }

    public static class ConvertXmlToJsonInputsBuilder {
        private String xml;
        private String textElementsName;
        private boolean includeRootElement;
        private boolean includeAttributes;
        private boolean prettyPrint;
        private String parsingFeatures;

        public ConvertXmlToJsonInputs build() {
            return new ConvertXmlToJsonInputs(this);
        }

        public ConvertXmlToJsonInputsBuilder withXml(final String xml) {
            this.xml = defaultIfBlank(xml, EMPTY_STRING);
            return this;
        }

        public ConvertXmlToJsonInputsBuilder withTextElementsName(final String textElementsName) {
            this.textElementsName = defaultIfEmpty(textElementsName, Defaults.DEFAULT_TEXT_ELEMENTS_NAME);
            return this;
        }

        public ConvertXmlToJsonInputsBuilder withIncludeRootElement(final boolean includeRootElement) {
            this.includeRootElement = includeRootElement;
            return this;
        }

        public ConvertXmlToJsonInputsBuilder withIncludeAttributes(final boolean includeAttributes) {
            this.includeAttributes = includeAttributes;
            return this;
        }

        public ConvertXmlToJsonInputsBuilder withPrettyPrint(final boolean prettyPrint) {
            this.prettyPrint = prettyPrint;
            return this;
        }

        public ConvertXmlToJsonInputsBuilder withParsingFeatures(final String parsingFeatures) {
            this.parsingFeatures = parsingFeatures;
            return this;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy