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

com.swak.license.api.LicenseFunctionComposition Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2005 - 2019 Schlichtherle IT Services.
 * All rights reserved. Use is subject to license terms.
 */
package com.swak.license.api;

/**
 * A strategy for composing two {@link LicenseInitialization}s or
 * {@link LicenseValidation}s.
 */
public enum LicenseFunctionComposition {

    override {

        @Override
        public LicenseInitialization compose(LicenseInitialization first, LicenseInitialization second) {
            return first;
        }

        @Override
        public LicenseValidation compose(LicenseValidation first, LicenseValidation second) { return first; }
    },

    decorate {

        @Override
        public LicenseInitialization compose(final LicenseInitialization first, final LicenseInitialization second) {
            return bean -> {
                first.initialize(bean);
                second.initialize(bean);
            };
        }

        @Override
        public LicenseValidation compose(final LicenseValidation first, final LicenseValidation second) {
            return bean -> {
                first.validate(bean);
                second.validate(bean);
            };
        }
    };

    public abstract LicenseInitialization compose(LicenseInitialization first, LicenseInitialization second);

    public abstract LicenseValidation compose(LicenseValidation first, LicenseValidation second);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy