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

org.cyclonedx.model.Service Maven / Gradle / Ivy

Go to download

The CycloneDX core module provides a model representation of the BOM along with utilities to assist in creating, parsing, and validating BOMs.

There is a newer version: 9.1.0
Show newest version
/*
 * This file is part of CycloneDX Core (Java).
 *
 * Licensed 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.
 *
 * SPDX-License-Identifier: Apache-2.0
 * Copyright (c) OWASP Foundation. All Rights Reserved.
 */
package org.cyclonedx.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import org.cyclonedx.Version;
import org.cyclonedx.model.component.Tags;
import org.cyclonedx.util.deserializer.ExternalReferencesDeserializer;
import org.cyclonedx.util.deserializer.LicenseDeserializer;
import org.cyclonedx.util.deserializer.StringListDeserializer;

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

@SuppressWarnings("unused")
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonPropertyOrder({
        "bom-ref",
        "provider",
        "group",
        "name",
        "version",
        "description",
        "endpoints",
        "authenticated",
        "xTrustBoundary",
        "data",
        "licenses",
        "externalReferences",
        "properties",
        "tags",
        "services",
        "releaseNotes",
        "signature"
})
public class Service extends ExtensibleElement {

    @JacksonXmlProperty(isAttribute = true, localName = "bom-ref")
    @JsonProperty("bom-ref")
    private String bomRef;
    private OrganizationalEntity provider;
    private String group;
    private String name;
    private String version;
    private String description;
    private List endpoints;
    private Boolean authenticated;
    @JacksonXmlProperty(localName = "x-trust-boundary")
    @JsonProperty("x-trust-boundary")
    private Boolean xTrustBoundary;
    private List data;
    private LicenseChoice licenses;
    private List externalReferences;
    @VersionFilter(Version.VERSION_13)
    private List properties;
    @VersionFilter(Version.VERSION_16)
    @JsonUnwrapped
    private Tags tags;
    private List services;
    private ReleaseNotes releaseNotes;
    @JsonOnly
    @VersionFilter(Version.VERSION_14)
    private Signature signature;

    public String getBomRef() {
        return bomRef;
    }

    public void setBomRef(String bomRef) {
        this.bomRef = bomRef;
    }

    public OrganizationalEntity getProvider() {
        return provider;
    }

    public void setProvider(OrganizationalEntity provider) {
        this.provider = provider;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @JacksonXmlElementWrapper(localName = "endpoints")
    @JacksonXmlProperty(localName = "endpoint")
    @JsonDeserialize(using = StringListDeserializer.class)
    public List getEndpoints() {
        return endpoints;
    }

    public void addEndpoint(String endpoint) {
        if (this.endpoints == null) {
            this.endpoints = new ArrayList<>();
        }
        this.endpoints.add(endpoint);
    }

    public void setEndpoints(List endpoints) {
        this.endpoints = endpoints;
    }

    public Boolean getAuthenticated() {
        return authenticated;
    }

    public void setAuthenticated(Boolean authenticated) {
        this.authenticated = authenticated;
    }

    public Boolean getxTrustBoundary() {
        return xTrustBoundary;
    }

    public void setxTrustBoundary(Boolean xTrustBoundary) {
        this.xTrustBoundary = xTrustBoundary;
    }

    @JacksonXmlElementWrapper(localName = "data")
    @JacksonXmlProperty(localName = "classification")
    public List getData() {
        return data;
    }

    public void addServiceData(ServiceData data) {
        if (this.data == null) {
            this.data = new ArrayList<>();
        }
        this.data.add(data);
    }

    public void setData(List data) {
        this.data = data;
    }

    @Deprecated
    public LicenseChoice getLicense() {
        return getLicenses();
    }

    @Deprecated
    @JsonIgnore
    public void setLicense(LicenseChoice licenseChoice) {
        setLicenses(licenseChoice);
    }

    @JsonDeserialize(using = LicenseDeserializer.class)
    public LicenseChoice getLicenses() {
        return licenses;
    }

    @JacksonXmlElementWrapper (useWrapping = false)
    public void setLicenses(LicenseChoice licenses) {
        this.licenses = licenses;
    }

    @JacksonXmlElementWrapper(localName = "externalReferences")
    @JacksonXmlProperty(localName = "reference")
    @JsonDeserialize(using = ExternalReferencesDeserializer.class)
    public List getExternalReferences() {
        return externalReferences;
    }

    public void addExternalReference(ExternalReference externalReference) {
        if (externalReferences == null) {
            externalReferences = new ArrayList<>();
        }
        externalReferences.add(externalReference);
    }

    public void setExternalReferences(List externalReferences) {
        this.externalReferences = externalReferences;
    }

    @JacksonXmlElementWrapper(localName = "properties")
    @JacksonXmlProperty(localName = "property")
    public List getProperties() {
        return properties;
    }

    public void setProperties(List properties) {
        this.properties = properties;
    }

    public void addProperty(Property property) {
        if (this.properties == null) {
            this.properties = new ArrayList<>();
        }
        this.properties.add(property);
    }

    @JacksonXmlElementWrapper(localName = "services")
    @JacksonXmlProperty(localName = "service")
    public List getServices() {
        return services;
    }

    public void setServices(List services) {
        this.services = services;
    }

    public ReleaseNotes getReleaseNotes() { return releaseNotes; }

    public void setReleaseNotes(ReleaseNotes releaseNotes) { this.releaseNotes = releaseNotes; }

    public Signature getSignature() { return signature; }

    public void setSignature(Signature signature) { this.signature = signature; }

    public Tags getTags() {
        return tags;
    }

    public void setTags(final Tags tags) {
        this.tags = tags;
    }

    @Override
    public boolean equals(final Object object) {
        if (this == object) {
            return true;
        }
        if (!(object instanceof Service)) {
            return false;
        }
        Service service = (Service) object;
        return Objects.equals(bomRef, service.bomRef) && Objects.equals(provider, service.provider) &&
            Objects.equals(group, service.group) && Objects.equals(name, service.name) &&
            Objects.equals(version, service.version) &&
            Objects.equals(description, service.description) &&
            Objects.equals(endpoints, service.endpoints) &&
            Objects.equals(authenticated, service.authenticated) &&
            Objects.equals(xTrustBoundary, service.xTrustBoundary) &&
            Objects.equals(data, service.data) && Objects.equals(licenses, service.licenses) &&
            Objects.equals(externalReferences, service.externalReferences) &&
            Objects.equals(properties, service.properties) && Objects.equals(tags, service.tags) &&
            Objects.equals(services, service.services) &&
            Objects.equals(releaseNotes, service.releaseNotes) &&
            Objects.equals(signature, service.signature);
    }

    @Override
    public int hashCode() {
        return Objects.hash(bomRef, provider, group, name, version, description, endpoints, authenticated,
            xTrustBoundary,
            data, licenses, externalReferences, properties, tags, services, releaseNotes, signature);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy