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

com.labs64.netlicensing.domain.entity.impl.ProductModuleImpl 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.entity.impl;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import javax.ws.rs.core.MultivaluedMap;

import com.labs64.netlicensing.domain.Constants;
import com.labs64.netlicensing.domain.entity.LicenseTemplate;
import com.labs64.netlicensing.domain.entity.Product;
import com.labs64.netlicensing.domain.entity.ProductModule;

/**
 * Default implementation of {@link com.labs64.netlicensing.domain.entity.ProductModule}.
 */
public class ProductModuleImpl extends BaseEntityImpl implements ProductModule {

    private static final long serialVersionUID = 6327895102315403718L;

    private Product product;

    private String name;

    private String licensingModel;

    private Collection licenseTemplates;

    /**
     * @see BaseEntityImpl#getReservedProps()
     */
    public static List getReservedProps() {
        final List reserved = BaseEntityImpl.getReservedProps();
        reserved.add(Constants.NAME);
        reserved.add(Constants.ProductModule.LICENSING_MODEL);
        reserved.add(Constants.Product.PRODUCT_NUMBER);
        reserved.add(Constants.IN_USE);
        return reserved;
    }

    @Override
    public Product getProduct() {
        return product;
    }

    @Override
    public void setProduct(final Product product) {
        product.getProductModules().add(this);
        this.product = product;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(final String name) {
        this.name = name;
    }

    @Override
    public String getLicensingModel() {
        return licensingModel;
    }

    @Override
    public void setLicensingModel(final String licensingModel) {
        this.licensingModel = licensingModel;
    }

    @Override
    public Collection getLicenseTemplates() {
        if (licenseTemplates == null) {
            licenseTemplates = new ArrayList();
        }
        return licenseTemplates;
    }

    public void setLicenseTemplates(final Collection licenseTemplates) {
        this.licenseTemplates = licenseTemplates;
    }

    @Override
    public Map getProductModuleProperties() {
        return getProperties();
    }

    @Override
    protected MultivaluedMap asPropertiesMap() {
        final MultivaluedMap map = super.asPropertiesMap();
        map.add(Constants.NAME, getName());
        map.add(Constants.ProductModule.LICENSING_MODEL, getLicensingModel());
        return map;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy