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

com.labs64.netlicensing.domain.vo.ValidationResult Maven / Gradle / Ivy

There is a newer version: 2.10.0-jdk17
Show newest version
/* 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.labs64.netlicensing.domain.vo;

import java.io.Serializable;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;

import com.labs64.netlicensing.domain.Constants;

public class ValidationResult implements Serializable {

    private static final long serialVersionUID = -4160421171524379008L;

    private Map validations;

    private Calendar ttl;

    public Map getValidations() {
        if (validations == null) {
            validations = new HashMap();
        }
        return validations;
    }

    public Calendar getTtl() {
        return ttl;
    }

    public void setTtl(final Calendar ttl) {
        this.ttl = ttl;
    }

    public ValidationResult() {
        ttl = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        ttl.add(Calendar.MINUTE, Constants.ValidationResult.DEFAULT_TTL_MINUTES);
    }

    public Composition getProductModuleValidation(final String productModuleNumber) {
        return getValidations().get(productModuleNumber);
    }

    public void setProductModuleValidation(final String productModuleNumber,
            final Composition productModuleValidation) {
        getValidations().put(productModuleNumber, productModuleValidation);
    }

    public void put(final String productModuleNumber, final String key, final String value) {
        getProductModuleValidation(productModuleNumber).put(key, value);
    }

    @Override
    public String toString() {
        final StringBuilder builder = new StringBuilder();
        builder.append("ValidationResult [");
        boolean first = true;
        for (final Map.Entry validationEntry : getValidations().entrySet()) {
            if (first) {
                first = false;
            } else {
                builder.append(", ");
            }
            builder.append("ProductModule<");
            builder.append(validationEntry.getKey());
            builder.append(">");
            builder.append(validationEntry.getValue().toString());
        }
        builder.append("]");
        return builder.toString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy