Skip to content

Commit 2377830

Browse files
committed
Custom properties handling unified. Old methods kept for backwards compatibility, but marked deprecated.
1 parent 7b1cae6 commit 2377830

18 files changed

Lines changed: 67 additions & 250 deletions

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/BaseEntity.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package com.labs64.netlicensing.domain.entity;
1414

1515
import java.io.Serializable;
16+
import java.util.Map;
1617

1718
import javax.ws.rs.core.Form;
1819

@@ -21,6 +22,8 @@
2122
*/
2223
public interface BaseEntity extends Serializable {
2324

25+
// Methods for working with properties
26+
2427
String getNumber();
2528

2629
void setNumber(String number);
@@ -29,6 +32,14 @@ public interface BaseEntity extends Serializable {
2932

3033
void setActive(Boolean active);
3134

35+
// Methods for working with custom properties
36+
37+
Map<String, String> getProperties();
38+
39+
void addProperty(String property, String value);
40+
41+
void removeProperty(final String property);
42+
3243
/**
3344
* Converts properties of the entity to the body of POST request
3445
*

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/License.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ public interface License extends BaseEntity {
6464

6565
void setHidden(Boolean hidden);
6666

67-
Map<String, String> getLicenseProperties();
68-
69-
void addProperty(String property, String value);
67+
// Methods for working with custom properties
7068

71-
void removeProperty(String property);
69+
@Deprecated
70+
Map<String, String> getLicenseProperties();
7271

7372
// Methods for interacting with other entities
7473

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/LicenseTemplate.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@ public interface LicenseTemplate extends BaseEntity {
8181

8282
void setHideLicenses(Boolean hideLicenses);
8383

84-
Map<String, String> getLicenseTemplateProperties();
85-
86-
void addProperty(String property, String value);
84+
// Methods for working with custom properties
8785

88-
void removeProperty(String property);
86+
@Deprecated
87+
Map<String, String> getLicenseTemplateProperties();
8988

9089
// Methods for interacting with other entities
9190

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/Licensee.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,11 @@
3333
*/
3434
public interface Licensee extends BaseEntity {
3535

36-
// Methods for working with properties
36+
// Methods for working with custom properties
3737

38+
@Deprecated
3839
Map<String, String> getLicenseeProperties();
3940

40-
void addProperty(String property, String value);
41-
42-
void removeProperty(String property);
43-
4441
// Methods for interacting with other entities
4542

4643
Product getProduct();

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/PaymentMethod.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@
1919
*/
2020
public interface PaymentMethod extends BaseEntity {
2121

22-
// Methods for working with properties
22+
// Methods for working with custom properties
2323

24+
@Deprecated
2425
Map<String, String> getPaymentMethodProperties();
2526

26-
void addProperty(String property, String value);
27-
28-
void removeProperty(String property);
29-
3027
}

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/Product.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ public interface Product extends BaseEntity {
6464

6565
void setLicensingInfo(String licensingInfo);
6666

67-
Map<String, String> getProductProperties();
68-
69-
void addProperty(String property, String value);
67+
// Methods for working with custom properties
7068

71-
void removeProperty(String property);
69+
@Deprecated
70+
Map<String, String> getProductProperties();
7271

7372
// Methods for interacting with other entities
7473

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/ProductModule.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ public interface ProductModule extends BaseEntity {
4444

4545
void setLicensingModel(String licensingModel);
4646

47-
Map<String, String> getProductModuleProperties();
48-
49-
void addProperty(String property, String value);
47+
// Methods for working with custom properties
5048

51-
void removeProperty(String property);
49+
@Deprecated
50+
Map<String, String> getProductModuleProperties();
5251

5352
// Methods for interacting with other entities
5453

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/Token.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ public interface Token extends BaseEntity {
3636

3737
void setTokenType(TokenType tokenType);
3838

39-
Map<String, String> getTokenProperties();
40-
41-
void addProperty(String property, String value);
39+
// Methods for working with custom properties
4240

43-
void removeProperty(String property);
41+
@Deprecated
42+
Map<String, String> getTokenProperties();
4443

4544
}

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/Transaction.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@ public interface Transaction extends BaseEntity {
7373

7474
void setDateClosed(Date dateClosed);
7575

76-
Map<String, String> getTransactionProperties();
77-
78-
void addProperty(String property, String value);
76+
// Methods for working with custom properties
7977

80-
void removeProperty(final String property);
78+
@Deprecated
79+
Map<String, String> getTransactionProperties();
8180

8281
}

NetLicensingClient/src/main/java/com/labs64/netlicensing/domain/entity/impl/BaseEntityImpl.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import java.util.ArrayList;
1616
import java.util.Collection;
17+
import java.util.HashMap;
1718
import java.util.LinkedHashMap;
1819
import java.util.List;
1920
import java.util.Map;
@@ -35,6 +36,8 @@ public abstract class BaseEntityImpl extends Visitable implements BaseEntity {
3536

3637
private Boolean active;
3738

39+
private Map<String, String> properties;
40+
3841
/**
3942
* List of reserved properties is used for handling of custom properties. Property name that is included in the list
4043
* can not be used as custom property name. The list is extended by each derived entity class until the final
@@ -71,6 +74,24 @@ public void setActive(final Boolean active) {
7174
this.active = active;
7275
}
7376

77+
@Override
78+
public Map<String, String> getProperties() {
79+
if (properties == null) {
80+
properties = new HashMap<String, String>();
81+
}
82+
return properties;
83+
}
84+
85+
@Override
86+
public void addProperty(final String property, final String value) {
87+
getProperties().put(property, value);
88+
}
89+
90+
@Override
91+
public void removeProperty(final String property) {
92+
getProperties().remove(property);
93+
}
94+
7495
@Override
7596
public String toString() {
7697
return toString(asPropertiesMap());
@@ -93,6 +114,11 @@ protected Map<String, Object> asPropertiesMap() {
93114
final Map<String, Object> map = new LinkedHashMap<String, Object>();
94115
map.put(Constants.NUMBER, getNumber());
95116
map.put(Constants.ACTIVE, getActive());
117+
if (properties != null) {
118+
for (final Map.Entry<String, String> lp : properties.entrySet()) {
119+
map.put(lp.getKey(), lp.getValue());
120+
}
121+
}
96122
return map;
97123
}
98124

0 commit comments

Comments
 (0)