com.labs64.netlicensing.domain.entity.impl.LicenseTemplateImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of netlicensing-client Show documentation
Show all versions of netlicensing-client Show documentation
Java wrapper for Labs64 NetLicensing RESTful API
The 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
*
* https://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.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import com.labs64.netlicensing.domain.Constants;
import com.labs64.netlicensing.domain.entity.License;
import com.labs64.netlicensing.domain.entity.LicenseTemplate;
import com.labs64.netlicensing.domain.entity.ProductModule;
import com.labs64.netlicensing.domain.vo.Currency;
import com.labs64.netlicensing.domain.vo.LicenseType;
/**
* Default implementation of {@link com.labs64.netlicensing.domain.entity.LicenseTemplate}.
*/
public class LicenseTemplateImpl extends BaseEntityImpl implements LicenseTemplate {
private static final long serialVersionUID = -6957717868558780419L;
private ProductModule productModule;
private String name;
private LicenseType licenseType;
private BigDecimal price;
private Currency currency;
private Boolean automatic = Boolean.FALSE;
private Boolean hidden = Boolean.FALSE;
private Boolean hideLicenses = Boolean.FALSE;
private Collection licenses;
/**
* @see BaseEntityImpl#getReservedProps()
*/
public static List getReservedProps() {
final List reserved = BaseEntityImpl.getReservedProps();
reserved.add(Constants.ProductModule.PRODUCT_MODULE_NUMBER); // maps to 'productModule'
reserved.add(Constants.ProductModule.PRODUCT_MODULE_NAME); // maps to 'productModule'
reserved.add(Constants.NAME);
reserved.add(Constants.LicenseTemplate.LICENSE_TYPE);
reserved.add(Constants.PRICE);
reserved.add(Constants.CURRENCY);
reserved.add(Constants.IN_USE);
reserved.add(Constants.LicenseTemplate.AUTOMATIC);
reserved.add(Constants.LicenseTemplate.HIDDEN);
reserved.add(Constants.LicenseTemplate.HIDE_LICENSES);
reserved.add(Constants.Shop.PROP_SHOP_LICENSE_ID); // used by shop in licenses, therefore disallowed for user
reserved.add(Constants.Shop.PROP_SHOPPING_CART); // used by shop in licenses, therefore disallowed for user
return reserved;
}
@Override
public ProductModule getProductModule() {
return productModule;
}
@Override
public void setProductModule(final ProductModule productModule) {
productModule.getLicenseTemplates().add(this);
this.productModule = productModule;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(final String name) {
this.name = name;
}
@Override
public LicenseType getLicenseType() {
return licenseType;
}
@Override
public void setLicenseType(final LicenseType licenseType) {
this.licenseType = licenseType;
}
@Override
public BigDecimal getPrice() {
return price;
}
@Override
public void setPrice(final BigDecimal price) {
this.price = price;
}
@Override
public Currency getCurrency() {
return currency;
}
@Override
public void setCurrency(final Currency currency) {
this.currency = currency;
}
@Override
public Boolean getAutomatic() {
return automatic;
}
@Override
public void setAutomatic(final Boolean automatic) {
this.automatic = automatic;
}
@Override
public Boolean getHidden() {
return hidden;
}
@Override
public void setHidden(final Boolean hidden) {
this.hidden = hidden;
}
@Override
public Boolean getHideLicenses() {
return hideLicenses;
}
@Override
public void setHideLicenses(final Boolean hideLicenses) {
this.hideLicenses = hideLicenses;
}
@Override
public Collection getLicenses() {
if (licenses == null) {
licenses = new ArrayList();
}
return licenses;
}
public void setLicenses(final Collection licenses) {
this.licenses = licenses;
}
@Override
public Map getLicenseTemplateProperties() {
return getProperties();
}
@Override
public Map asMap() {
final Map map = super.asMap();
map.put(Constants.NAME, getName());
map.put(Constants.LicenseTemplate.LICENSE_TYPE, getLicenseType());
map.put(Constants.PRICE, getPrice());
map.put(Constants.CURRENCY, getCurrency());
map.put(Constants.LicenseTemplate.AUTOMATIC, getAutomatic());
map.put(Constants.LicenseTemplate.HIDDEN, getHidden());
map.put(Constants.LicenseTemplate.HIDE_LICENSES, getHideLicenses());
return map;
}
}