1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package tools.gsf.properties;
17
18 import com.fatwire.assetapi.data.AssetId;
19 import tools.gsf.facade.assetapi.AssetIdUtils;
20 import org.apache.commons.lang3.StringUtils;
21
22 import java.io.Serializable;
23
24
25
26
27
28
29
30 final class PropertyImpl implements Property, Serializable {
31
32
33
34 private static final long serialVersionUID = 692797066527955686L;
35 String name;
36 String description;
37 String value;
38 String propertyAssetType;
39
40 PropertyImpl(String propertyAssetType, String name, String description, String value) {
41 this.name = name;
42 this.value = value;
43 this.propertyAssetType = propertyAssetType;
44 }
45
46 public String getName() {
47 return name;
48 }
49
50 public String getDescription() {
51 return description;
52 }
53
54 public boolean isNull() {
55 return value == null;
56 }
57
58 public boolean asBoolean() {
59 return Boolean.getBoolean(value);
60 }
61
62 public String asString() {
63 return value;
64 }
65
66 public long asLong() {
67 return Long.valueOf(value);
68 }
69
70 public int asInt() {
71 return Integer.valueOf(value);
72 }
73
74 public AssetId asAssetId() {
75 return AssetIdUtils.fromString(value);
76 }
77
78 public String toString() {
79
80 if (!StringUtils.isEmpty(name) &&
81 (name.startsWith("password") ||
82 name.startsWith("pwd"))) {
83 return this.propertyAssetType + ":" + name + "= (value blanked by password protection mechanism)";
84 } else {
85 return this.propertyAssetType + ":" + name + "=" + value;
86 }
87 }
88 }