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

com.metaeffekt.artifact.analysis.bom.spdx.DocumentSpec Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2021-2024 the original author or authors.
 *
 * 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.
 */
package com.metaeffekt.artifact.analysis.bom.spdx;

import com.metaeffekt.artifact.analysis.bom.BomConstants;
import lombok.Getter;

@Getter
public class DocumentSpec {

    private String documentName;

    private String description;

    // The Id of the document, either a uuid for cyclonedx or uri for spdx
    private String documentId;

    private String organization;

    private String organizationUrl;

    private String person;

    private String tool;

    private String comment;

    private String spdxLicenseListVersion;

    private BomConstants.Format format = BomConstants.Format.JSON;

    // The current iteration of this bom
    private int documentIteration = 1;

    // Switch to decide if relationship structures should be included or "pressed flat" / omitted.
    private boolean mapRelationships = true;

    // Switch to decide if license expressions or full single licenses should be used.
    private boolean useLicenseExpressions = true;

    // Switch to decide if license texts should be omitted or not.
    private boolean includeLicenseTexts = true;

    // Switch to decide if assets should be removed as a pre-step before exporting.
    private boolean includeAssets = true;

    // Switch to decide if additional properties needed for lossless importing, not in inventory, should be added.
    private boolean includeTechnicalProperties = true;

    public DocumentSpec(String documentName, String documentId, String organization, String organizationUrl) {

        if (documentId == null) {
            throw new IllegalArgumentException("The document URI in the document spec cannot be null.");
        }
        if (organizationUrl == null) {
            throw new IllegalArgumentException("The organization URL in the document spec cannot be null.");
        }

        this.documentName = documentName;
        this.documentId = documentId;
        this.organization = organization;
        this.organizationUrl = organizationUrl;
    }

    public DocumentSpec withDescription(String description) {
        this.description = description;
        return this;
    }

    public DocumentSpec withComment(String comment) {
        this.comment = comment;
        return this;
    }

    public DocumentSpec withSpdxLicenseListVersion(String spdxLicenseListVersion) {
        this.spdxLicenseListVersion = spdxLicenseListVersion;
        return this;
    }

    public DocumentSpec byPerson(String person) {
        this.person = person;
        return this;
    }

    public DocumentSpec usingTool(String tool) {
        this.tool = tool;
        return this;
    }

    public DocumentSpec usingFormat(BomConstants.Format format) {
        this.format = format;
        return this;
    }

    public DocumentSpec setDocumentIteration(int documentIteration) {
        this.documentIteration = documentIteration;
        return this;
    }

    // Switches
    public DocumentSpec mapRelationships(boolean mapRelationships) {
        this.mapRelationships = mapRelationships;
        return this;
    }

    public DocumentSpec useLicenseExpressions(boolean useLicenseExpressions) {
        this.useLicenseExpressions = useLicenseExpressions;
        return this;
    }

    public DocumentSpec includeLicenseTexts(boolean includeLicenseTexts) {
        this.includeLicenseTexts = includeLicenseTexts;
        return this;
    }

    public DocumentSpec includeAssets(boolean includeAssets) {
        this.includeAssets = includeAssets;
        return this;
    }

    public DocumentSpec includeTechnicalProperties(boolean includeTechnicalProperties) {
        this.includeTechnicalProperties = includeTechnicalProperties;
        return this;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy