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

com.metaeffekt.artifact.enrichment.configurations.EolEnrichmentConfiguration 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.enrichment.configurations;

import org.metaeffekt.core.inventory.processor.configuration.ProcessConfiguration;
import org.metaeffekt.core.inventory.processor.configuration.ProcessMisconfiguration;

import java.util.LinkedHashMap;
import java.util.List;

public class EolEnrichmentConfiguration extends ProcessConfiguration {

    private int warningThresholdDaysSupport = 180;
    private int warningThresholdDaysExtendedSupport = 180;

    @Override
    public LinkedHashMap getProperties() {
        final LinkedHashMap properties = new LinkedHashMap<>();

        properties.put("warningThresholdDaysSupport", warningThresholdDaysSupport);
        properties.put("warningThresholdDaysExtendedSupport", warningThresholdDaysExtendedSupport);

        return properties;
    }

    @Override
    public void setProperties(LinkedHashMap properties) {
        super.loadIntegerProperty(properties, "warningThresholdDaysSupport", this::setWarningThresholdDaysSupport);
        super.loadIntegerProperty(properties, "warningThresholdDaysExtendedSupport", this::setWarningThresholdDaysExtendedSupport);
    }

    public EolEnrichmentConfiguration setWarningThresholdDaysSupport(int warningThresholdDaysSupport) {
        this.warningThresholdDaysSupport = warningThresholdDaysSupport;
        return this;
    }

    public int getWarningThresholdDaysSupport() {
        return warningThresholdDaysSupport;
    }

    public long getWarningThresholdMillisSupport() {
        return warningThresholdDaysSupport * 24L * 60L * 60L * 1000L;
    }

    public EolEnrichmentConfiguration setWarningThresholdDaysExtendedSupport(int warningThresholdDaysExtendedSupport) {
        this.warningThresholdDaysExtendedSupport = warningThresholdDaysExtendedSupport;
        return this;
    }

    public int getWarningThresholdDaysExtendedSupport() {
        return warningThresholdDaysExtendedSupport;
    }

    public long getWarningThresholdMillisExtendedSupport() {
        return warningThresholdDaysExtendedSupport * 24L * 60L * 60L * 1000L;
    }

    @Override
    protected void collectMisconfigurations(List misconfigurations) {
        if (warningThresholdDaysSupport < 0) {
            misconfigurations.add(new ProcessMisconfiguration("warningThresholdDaysSupport", "must be >= 0"));
        }
        if (warningThresholdDaysExtendedSupport < 0) {
            misconfigurations.add(new ProcessMisconfiguration("warningThresholdDaysExtendedSupport", "must be >= 0"));
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy