org.cyclonedx.model.Component Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cyclonedx-core-java Show documentation
Show all versions of cyclonedx-core-java Show documentation
The CycloneDX core module provides a model representation of the BOM along with utilities to assist in creating, parsing, and validating BOMs.
/*
* 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) Steve Springett. All Rights Reserved.
*/
package org.cyclonedx.model;
import com.github.packageurl.PackageURL;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@SuppressWarnings("unused")
public class Component extends ExtensibleElement {
public enum Type {
APPLICATION("application"),
FRAMEWORK("framework"),
LIBRARY("library"),
OPERATING_SYSTEM("operating-system"),
DEVICE("device"),
FILE("file");
private String name;
public String getTypeName() {
return this.name;
}
Type(String name) {
this.name = name;
}
}
public enum Scope {
REQUIRED("required"),
OPTIONAL("optional"),
EXCLUDED("excluded");
private String name;
public String getScopeName() {
return this.name;
}
Scope(String name) {
this.name = name;
}
}
private String bomRef;
private String publisher;
private String group;
private String name;
private String version;
private String description;
private Scope scope;
private List hashes;
private LicenseChoice licenseChoice;
private String copyright;
private String cpe;
private String purl;
private boolean modified;
private Pedigree pedigree;
private List externalReferences;
private List components;
private Type type;
public String getBomRef() {
return bomRef;
}
public void setBomRef(String bomRef) {
this.bomRef = bomRef;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
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;
}
public Scope getScope() {
return scope;
}
public void setScope(Scope scope) {
this.scope = scope;
}
public List getHashes() {
return hashes;
}
public void setHashes(List hashes) {
this.hashes = hashes;
}
public void addHash(Hash hash) {
if (this.hashes == null) {
this.hashes = new ArrayList<>();
}
this.hashes.add(hash);
}
public LicenseChoice getLicenseChoice() {
return licenseChoice;
}
public void setLicenseChoice(LicenseChoice licenseChoice) {
this.licenseChoice = licenseChoice;
}
public String getCopyright() {
return copyright;
}
public void setCopyright(String copyright) {
this.copyright = copyright;
}
/**
* @deprecated CPE will be removed in a future version of the CycloneDX specification/
* @return the Common Platform Enumeration of the component
*/
@Deprecated
public String getCpe() {
return cpe;
}
/**
* @deprecated CPE will be removed in a future version of the CycloneDX specification/
*/
@Deprecated
public void setCpe(String cpe) {
this.cpe = cpe;
}
public String getPurl() {
return purl;
}
public void setPurl(String purl) {
this.purl = purl;
}
public void setPurl(PackageURL purl) {
this.purl = purl.canonicalize();
}
public boolean isModified() {
return modified;
}
public void setModified(boolean modified) {
this.modified = modified;
}
public Pedigree getPedigree() {
return pedigree;
}
public void setPedigree(Pedigree pedigree) {
this.pedigree = pedigree;
}
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;
}
public List getComponents() {
return components;
}
public void setComponents(List components) {
this.components = components;
}
public void addComponent(Component component) {
if (this.components == null) {
this.components = new ArrayList<>();
}
this.components.add(component);
}
public Type getType() {
return type;
}
public void setType(Type type) {
this.type = type;
}
@Override
public int hashCode() {
return Objects.hash(publisher, group, name, version, description, scope, hashes, licenseChoice, copyright, cpe, purl, modified, components, type);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Component component = (Component) o;
return modified == component.modified &&
Objects.equals(publisher, component.publisher) &&
Objects.equals(group, component.group) &&
Objects.equals(name, component.name) &&
Objects.equals(version, component.version) &&
Objects.equals(description, component.description) &&
Objects.equals(scope, component.scope) &&
Objects.equals(hashes, component.hashes) &&
Objects.equals(licenseChoice, component.licenseChoice) &&
Objects.equals(copyright, component.copyright) &&
Objects.equals(cpe, component.cpe) &&
Objects.equals(purl, component.purl) &&
Objects.equals(components, component.components) &&
Objects.equals(type, component.type);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy