1111import java .util .Set ;
1212
1313/**
14- * A base class for entities.
14+ * A base class for entities to hold the properties .
1515 */
1616abstract class BaseEntity extends Serializable <DatastoreV1 .Entity > {
1717
@@ -36,72 +36,78 @@ protected B self() {
3636 return (B ) this ;
3737 }
3838
39- public B clearProperties () {
39+ /**
40+ * Clears all the properties.
41+ */
42+ public B clear () {
4043 properties .clear ();
4144 return self ();
4245 }
4346
44- public B removeProperty (String name ) {
47+ /**
48+ * Removes a property with the given {@code name}.
49+ */
50+ public B remove (String name ) {
4551 properties .remove (name );
4652 return self ();
4753 }
4854
49- public B setProperty (String name , Value <?> value ) {
55+ public B set (String name , Value <?> value ) {
5056 properties .put (name , value );
5157 return self ();
5258 }
5359
54- public B setNullProperty (String name ) {
60+ public B setNull (String name ) {
5561 properties .put (name , new NullValue ());
5662 return self ();
5763 }
5864
59- public B setStringProperty (String name , String value ) {
65+ public B set (String name , String value ) {
6066 properties .put (name , new StringValue (value ));
6167 return self ();
6268 }
6369
64- public B setLongProperty (String name , long value ) {
70+ public B set (String name , long value ) {
6571 properties .put (name , new LongValue (value ));
6672 return self ();
6773 }
6874
69- public B setDoubleProperty (String name , double value ) {
75+ public B set (String name , double value ) {
7076 properties .put (name , new DoubleValue (value ));
7177 return self ();
7278 }
7379
74- public B setBooleanProperty (String name , boolean value ) {
80+ public B set (String name , boolean value ) {
7581 properties .put (name , new BooleanValue (value ));
7682 return self ();
7783 }
7884
79- public B setDateTimeProperty (String name , DateTime value ) {
85+ public B set (String name , DateTime value ) {
8086 properties .put (name , new DateTimeValue (value ));
8187 return self ();
8288 }
8389
84- public B setKeyProperty (String name , Key value ) {
90+ public B set (String name , Key value ) {
8591 properties .put (name , new KeyValue (value ));
8692 return self ();
8793 }
8894
89- public B setEntityProperty (String name , PartialEntity value ) {
95+ public B set (String name , PartialEntity value ) {
9096 properties .put (name , new EntityValue (value ));
9197 return self ();
9298 }
9399
94- public B setListProperty (String name , List <? extends Value <?>> values ) {
100+ public B set (String name , List <? extends Value <?>> values ) {
95101 properties .put (name , new ListValue (values ));
96102 return self ();
97103 }
98104
99- public B setListProperty (String name , Value <?>... value ) {
105+ public B set (String name , Value <?>... value ) {
100106 properties .put (name , new ListValue (Arrays .asList (value )));
101107 return self ();
102108 }
103109
104- public B setBlobProperty (String name , Blob value ) {
110+ public B set (String name , Blob value ) {
105111 properties .put (name , new BlobValue (value ));
106112 return self ();
107113 }
@@ -118,18 +124,18 @@ protected BaseEntity(ImmutableSortedMap<String, Value<?>> properties) {
118124 }
119125
120126 /**
121- * Returns {@code true} if there is such property with the given {@code name}.
127+ * Returns {@code true} if the entity contains a property with the given {@code name}.
122128 */
123- public boolean hasProperty (String name ) {
129+ public boolean contains (String name ) {
124130 return properties .containsKey (name );
125131 }
126132
127133 /**
128- * Returns the {@link Value} of property with the given {@code name}.
134+ * Returns the {@link Value} for the given property {@code name}.
129135 *
130136 * @throws DatastoreServiceException if not such property.
131137 */
132- public <V extends Value <?>> V property (String name ) {
138+ public <V extends Value <?>> V getValue (String name ) {
133139 @ SuppressWarnings ("unchecked" )
134140 V property = (V ) properties .get (name );
135141 if (property == null ) {
@@ -138,63 +144,66 @@ public <V extends Value<?>> V property(String name) {
138144 return property ;
139145 }
140146
141- public Type propertyType (String name ) {
142- return property (name ).type ();
147+ public Type type (String name ) {
148+ return getValue (name ).type ();
143149 }
144150
145- public boolean isNullProperty (String name ) {
146- return property (name ) instanceof NullValue ;
151+ public boolean isNull (String name ) {
152+ return getValue (name ) instanceof NullValue ;
147153 }
148154
149- public String stringProperty (String name ) {
150- return ((StringValue ) property (name )).get ();
155+ public String getString (String name ) {
156+ return ((StringValue ) getValue (name )).get ();
151157 }
152158
153- public long longProperty (String name ) {
154- return ((LongValue ) property (name )).get ();
159+ public long getLong (String name ) {
160+ return ((LongValue ) getValue (name )).get ();
155161 }
156162
157- public double doubleProperty (String name ) {
158- return ((DoubleValue ) property (name )).get ();
163+ public double getDouble (String name ) {
164+ return ((DoubleValue ) getValue (name )).get ();
159165 }
160166
161- public boolean booleanProperty (String name ) {
162- return ((BooleanValue ) property (name )).get ();
167+ public boolean getBoolean (String name ) {
168+ return ((BooleanValue ) getValue (name )).get ();
163169 }
164170
165- public DateTime dateTimeProperty (String name ) {
166- return ((DateTimeValue ) property (name )).get ();
171+ public DateTime getDateTime (String name ) {
172+ return ((DateTimeValue ) getValue (name )).get ();
167173 }
168174
169- public Key keyProperty (String name ) {
170- return ((KeyValue ) property (name )).get ();
175+ public Key getKey (String name ) {
176+ return ((KeyValue ) getValue (name )).get ();
171177 }
172178
173179 @ SuppressWarnings ("unchecked" )
174- public <T extends PartialEntity > T entityProperty (String name ) {
175- return (T ) ((EntityValue ) property (name )).get ();
180+ public <T extends PartialEntity > T getEntity (String name ) {
181+ return (T ) ((EntityValue ) getValue (name )).get ();
176182 }
177183
178- public List <? extends Value <?>> listProperty (String name ) {
179- return ((ListValue ) property (name )).get ();
184+ public List <? extends Value <?>> getList (String name ) {
185+ return ((ListValue ) getValue (name )).get ();
180186 }
181187
182- public Blob blobProperty (String name ) {
183- return ((BlobValue ) property (name )).get ();
188+ public Blob getBlob (String name ) {
189+ return ((BlobValue ) getValue (name )).get ();
184190 }
185191
186192 /**
187193 * Returns the property's value as a {@link RawValue}.
188194 */
189- public RawValue asRawValueProperty (String name ) {
190- Value <?> value = property (name );
195+ public RawValue asRawValue (String name ) {
196+ Value <?> value = getValue (name );
191197 if (value instanceof RawValue ) {
192198 return (RawValue ) value ;
193199 }
194200 return new RawValue (value .toPb ());
195201 }
196202
197- public Set <String > propertyNames () {
203+ /**
204+ * Returns the properties name.
205+ */
206+ public Set <String > names () {
198207 return properties .keySet ();
199208 }
200209
0 commit comments