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

com.metaeffekt.artifact.terms.model.Variables 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.terms.model;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class Variables {
    private Map values;
    private String license;

    public Map getValues() {
        return values;
    }

    public void setValues(Map values) {
        this.values = values;
    }

    public void putValues(String key, String value) {
        if (values == null) {
            values = new HashMap<>();
            values.put(key, value);
        } else {
            values.put(key, value);
        }
    }

    /*
        Interface Comparable  
     */
    public String getLicense() {
        return license;
    }

    public void setLicense(String license) {
        this.license = license;
    }

    public boolean listContains(List list) {
        if (list == null) return false;
        return this.getFromList(list) != null;
    }

    public Variables getFromList(List list) {
        if (list == null) return null;
        for (Variables variable : list) {
            if (this.hashCode() == variable.hashCode()) {
                if (this.equals(variable)) {
                    return variable;
                }
            }
        }
        return null;
    }


    @Override
    public int hashCode() {
        return Objects.hash(license, values);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Variables variable = (Variables) o;
        return Objects.equals(values, variable.values) && license.equals(variable.license);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy