Skip to content

Commit 5220da6

Browse files
committed
Code comment fixes
1 parent 6f67e80 commit 5220da6

File tree

2 files changed

+80
-86
lines changed

2 files changed

+80
-86
lines changed

sfdx-source/apex-common/main/classes/fflib_SObjects.cls

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -90,40 +90,40 @@ public virtual class fflib_SObjects
9090
/**
9191
* Adds an error message to the a field records in the domain
9292
*
93-
* @param sObjectField The field where the error should be reported
93+
* @param field The field where the error should be reported
9494
* @param message The error message to add to the given field on each record
9595
*/
9696
@TestVisible
97-
protected virtual void addError(Schema.SObjectField sObjectField, String message)
97+
protected virtual void addError(Schema.SObjectField field, String message)
9898
{
9999
for (SObject record : getRecords())
100100
{
101-
record.addError(sObjectField, error(message, record, sObjectField));
101+
record.addError(field, error(message, record, field));
102102
}
103103
}
104104

105105
/**
106106
* Clear the field value on all the records of the domain
107-
* @param sObjectField The field to nullify
107+
* @param field The field to nullify
108108
*/
109109
@TestVisible
110-
protected virtual void clearField(Schema.SObjectField sObjectField)
110+
protected virtual void clearField(Schema.SObjectField field)
111111
{
112-
clearFields(new Set<Schema.SObjectField>{ sObjectField });
112+
clearFields(new Set<Schema.SObjectField>{ field });
113113
}
114114

115115
/**
116116
* Clear the field values on all the records of the domain
117-
* @param sObjectFields The fields to nullify
117+
* @param fields The fields to nullify
118118
*/
119119
@TestVisible
120-
protected virtual void clearFields(Set<Schema.SObjectField> sObjectFields)
120+
protected virtual void clearFields(Set<Schema.SObjectField> fields)
121121
{
122122
for (SObject record : getRecords())
123123
{
124-
for (SObjectField sObjectField : sObjectFields)
124+
for (SObjectField field : fields)
125125
{
126-
record.put(sObjectField, null);
126+
record.put(field, null);
127127
}
128128
}
129129
}
@@ -156,76 +156,76 @@ public virtual class fflib_SObjects
156156
}
157157

158158
/**
159-
* @param sObjectField The SObjectField reference of the type Id
159+
* @param field The SObjectField reference of the type Id
160160
*
161161
* @return Return a set with all the Id values of the given field
162162
*/
163163
@TestVisible
164-
protected Set<Id> getIdFieldValues(Schema.SObjectField sObjectField)
164+
protected Set<Id> getIdFieldValues(Schema.SObjectField field)
165165
{
166166
Set<Id> result = new Set<Id>();
167167
for (SObject record : getRecords())
168168
{
169-
result.add((Id) record.get(sObjectField));
169+
result.add((Id) record.get(field));
170170
}
171171
return result;
172172
}
173173

174174
/**
175-
* @param sObjectField The SObjectField reference of the type String
175+
* @param field The SObjectField reference of the type String
176176
*
177177
* @return Return a set with all the String values of the given field
178178
*/
179179
@TestVisible
180-
protected Set<String> getStringFieldValues(Schema.SObjectField sObjectField)
180+
protected Set<String> getStringFieldValues(Schema.SObjectField field)
181181
{
182182
Set<String> result = new Set<String>();
183183
for (SObject record : getRecords())
184184
{
185-
result.add((String) record.get(sObjectField));
185+
result.add((String) record.get(field));
186186
}
187187
return result;
188188
}
189189

190190
/**
191-
* @param sObjectField The SObjectField reference
191+
* @param field The SObjectField reference
192192
*
193193
* @return Return a set with all the values of the given field
194194
*/
195195
@TestVisible
196-
protected virtual Set<Object> getFieldValues(Schema.SObjectField sObjectField)
196+
protected virtual Set<Object> getFieldValues(Schema.SObjectField field)
197197
{
198198
Set<Object> result = new Set<Object>();
199199
for (SObject record : getRecords())
200200
{
201-
result.add(record.get(sObjectField));
201+
result.add(record.get(field));
202202
}
203203
return result;
204204
}
205205

206206
/**
207-
* @param sObjectField The Schema.SObjectField to compare against the given value
208-
* @param value The given value of the records sObjectField to include in the return
207+
* @param field The Schema.SObjectField to compare against the given value
208+
* @param value The given value of the records field to include in the return
209209
*
210-
* @return A list with only the SObjects where the given sObjectField has the provided value
210+
* @return A list with only the SObjects where the given field has the provided value
211211
*/
212-
protected virtual List<SObject> getRecordsByFieldValue(Schema.SObjectField sObjectField, Object value)
212+
protected virtual List<SObject> getRecordsByFieldValue(Schema.SObjectField field, Object value)
213213
{
214-
return getRecordsByFieldValues(sObjectField, new Set<Object>{value});
214+
return getRecordsByFieldValues(field, new Set<Object>{value});
215215
}
216216

217217
/**
218-
* @param sObjectField The Schema.SObjectField to compare against the given value
219-
* @param values The given values of the records sObjectField to include in the return
218+
* @param field The Schema.SObjectField to compare against the given value
219+
* @param values The given values of the records field to include in the return
220220
*
221-
* @return A list with only the SObjects where the given sObjectField value is part of the provided values
221+
* @return A list with only the SObjects where the given field value is part of the provided values
222222
*/
223-
protected virtual List<SObject> getRecordsByFieldValues(Schema.SObjectField sObjectField, Set<Object> values)
223+
protected virtual List<SObject> getRecordsByFieldValues(Schema.SObjectField field, Set<Object> values)
224224
{
225225
List<SObject> result = new List<SObject>();
226226
for (SObject record : getRecords())
227227
{
228-
if (values?.contains(record.get(sObjectField)))
228+
if (values?.contains(record.get(field)))
229229
{
230230
result.add(record);
231231
}
@@ -234,30 +234,30 @@ public virtual class fflib_SObjects
234234
}
235235

236236
/**
237-
* @param sObjectField The Schema.SObjectField to check its value for a Blank value
237+
* @param field The Schema.SObjectField to check its value for a Blank value
238238
*
239-
* @return A list with only the SObjects where the given sObjectField value is either null or '')
239+
* @return A list with only the SObjects where the given field value is either null or '')
240240
*/
241-
protected virtual List<SObject> getRecordsWithBlankFieldValues(Schema.SObjectField sObjectField)
241+
protected virtual List<SObject> getRecordsWithBlankFieldValues(Schema.SObjectField field)
242242
{
243243
return getRecordsWithBlankFieldValues(
244-
new Set<Schema.SObjectField> {sObjectField}
244+
new Set<Schema.SObjectField> {field}
245245
);
246246
}
247247

248248
/**
249-
* @param sObjectFields The Schema.SObjectFields to check their value for a Blank value
249+
* @param fields The Schema.SObjectFields to check their value for a Blank value
250250
*
251-
* @return A list with only the SObjects where the at least one given sObjectField value is either null or '')
251+
* @return A list with only the SObjects where the at least one given field value is either null or '')
252252
*/
253-
protected virtual List<SObject> getRecordsWithBlankFieldValues(Set<Schema.SObjectField> sObjectFields)
253+
protected virtual List<SObject> getRecordsWithBlankFieldValues(Set<Schema.SObjectField> fields)
254254
{
255255
List<SObject> result = new List<SObject>();
256256
for (SObject record : getRecords())
257257
{
258-
for (SObjectField sObjectField : sObjectFields)
258+
for (SObjectField field : fields)
259259
{
260-
if (String.isNotBlank((String) record.get(sObjectField))) continue;
260+
if (String.isNotBlank((String) record.get(field))) continue;
261261

262262
result.add(record);
263263
break;
@@ -267,19 +267,19 @@ public virtual class fflib_SObjects
267267
}
268268

269269
/**
270-
* @param sObjectFields The Schema.SObjectFields to check their value for a Blank value
270+
* @param fields The Schema.SObjectFields to check their value for a Blank value
271271
*
272-
* @return A list with only the SObjects where all given sObjectField values are either null or ''
272+
* @return A list with only the SObjects where all given field values are either null or ''
273273
*/
274-
protected virtual List<SObject> getRecordsWithAllBlankFieldValues(Set<Schema.SObjectField> sObjectFields)
274+
protected virtual List<SObject> getRecordsWithAllBlankFieldValues(Set<Schema.SObjectField> fields)
275275
{
276276
List<SObject> result = new List<SObject>();
277277
for (SObject record : getRecords())
278278
{
279279
Boolean allBlank = true;
280-
for (SObjectField sObjectField : sObjectFields)
280+
for (SObjectField field : fields)
281281
{
282-
if (String.isNotBlank((String) record.get(sObjectField)))
282+
if (String.isNotBlank((String) record.get(field)))
283283
{
284284
allBlank = false;
285285
break;
@@ -291,30 +291,30 @@ public virtual class fflib_SObjects
291291
}
292292

293293
/**
294-
* @param sObjectField The Schema.SObjectField to check its value for a Non-Blank value
294+
* @param field The Schema.SObjectField to check its value for a Non-Blank value
295295
*
296-
* @return A list with only the SObjects where the given sObjectField value is not null or ''
296+
* @return A list with only the SObjects where the given field value is not null or ''
297297
*/
298-
protected virtual List<SObject> getRecordsWithNotBlankFieldValues(Schema.SObjectField sObjectField)
298+
protected virtual List<SObject> getRecordsWithNotBlankFieldValues(Schema.SObjectField field)
299299
{
300300
return getRecordsWithNotBlankFieldValues(
301-
new Set<Schema.SObjectField> {sObjectField}
301+
new Set<Schema.SObjectField> {field}
302302
);
303303
}
304304

305305
/**
306-
* @param sObjectFields The Schema.SObjectFields to check their value for a Non-Blank value
306+
* @param fields The Schema.SObjectFields to check their value for a Non-Blank value
307307
*
308-
* @return A list with only the SObjects where the at least one given sObjectField value not null or ''
308+
* @return A list with only the SObjects where the at least one given field value not null or ''
309309
*/
310-
protected virtual List<SObject> getRecordsWithNotBlankFieldValues(Set<Schema.SObjectField> sObjectFields)
310+
protected virtual List<SObject> getRecordsWithNotBlankFieldValues(Set<Schema.SObjectField> fields)
311311
{
312312
List<SObject> result = new List<SObject>();
313313
for (SObject record : getRecords())
314314
{
315-
for (SObjectField sObjectField : sObjectFields)
315+
for (SObjectField field : fields)
316316
{
317-
if (String.isNotBlank((String) record.get(sObjectField)))
317+
if (String.isNotBlank((String) record.get(field)))
318318
{
319319
result.add(record);
320320
break;
@@ -325,19 +325,19 @@ public virtual class fflib_SObjects
325325
}
326326

327327
/**
328-
* @param sObjectFields The Schema.SObjectFields to check their value for a Non-Blank value
328+
* @param fields The Schema.SObjectFields to check their value for a Non-Blank value
329329
*
330-
* @return A list with only the SObjects where all given sObjectField values are not null or ''
330+
* @return A list with only the SObjects where all given field values are not null or ''
331331
*/
332-
protected virtual List<SObject> getRecordsWithAllNotBlankFieldValues(Set<Schema.SObjectField> sObjectFields)
332+
protected virtual List<SObject> getRecordsWithAllNotBlankFieldValues(Set<Schema.SObjectField> fields)
333333
{
334334
List<SObject> result = new List<SObject>();
335335
for (SObject record : getRecords())
336336
{
337337
Boolean allNonBlank = true;
338-
for (SObjectField sObjectField : sObjectFields)
338+
for (SObjectField field : fields)
339339
{
340-
if (String.isBlank((String) record.get(sObjectField)))
340+
if (String.isBlank((String) record.get(field)))
341341
{
342342
allNonBlank = false;
343343
break;
@@ -351,33 +351,33 @@ public virtual class fflib_SObjects
351351
/**
352352
* Modifies a value of a field for all records in the domain
353353
*
354-
* @param sObjectField The reference to the SObjectField to be modified
354+
* @param field The reference to the SObjectField to be modified
355355
* @param value The value to store in the given SObjectField
356356
*/
357-
protected virtual void setFieldValue(Schema.SObjectField sObjectField, Object value)
357+
protected virtual void setFieldValue(Schema.SObjectField field, Object value)
358358
{
359359
for (SObject record : getRecords())
360360
{
361-
record.put(sObjectField, value);
361+
record.put(field, value);
362362
}
363363
}
364364

365365
/**
366-
* @param sObjectFieldToCheck The SObjectField to match the key against in the provided map
367-
* @param sObjectFieldToUpdate The SObjectField to store the mapped value when the key matches the value in the sObjectFieldToUpdate field
368-
* @param values Map of values to store by the sObjectFieldToCheck fields value
366+
* @param fieldToCheck The SObjectField to match the key against in the provided map
367+
* @param fieldToUpdate The SObjectField to store the mapped value when the key matches the value in the fieldToUpdate field
368+
* @param values Map of values to store by the fieldToCheck fields value
369369
*/
370370
protected virtual void setFieldValueByMap(
371-
Schema.SObjectField sObjectFieldToCheck,
372-
Schema.SObjectField sObjectFieldToUpdate,
371+
Schema.SObjectField fieldToCheck,
372+
Schema.SObjectField fieldToUpdate,
373373
Map<Object, Object> values)
374374
{
375375
for (SObject record : getRecords())
376376
{
377-
Object keyValue = record.get(sObjectFieldToCheck);
377+
Object keyValue = record.get(fieldToCheck);
378378
if (values?.containsKey(keyValue))
379379
{
380-
record.put(sObjectFieldToUpdate, values.get(keyValue));
380+
record.put(fieldToUpdate, values.get(keyValue));
381381
}
382382
}
383383
}

sfdx-source/apex-common/test/classes/fflib_SObjectsTest.cls

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ private class fflib_SObjectsTest
7777

7878
Set<Id> recordIds = new Set<Id> {idA, idB, idC};
7979
System.assert(
80-
domain.getRecordIds().containsAll(recordIds),
80+
domain.getRecordIds().equals(recordIds),
8181
'The domain should return all the record Ids'
8282
);
8383

8484
System.assert(
85-
domain.getIdFieldValues(Schema.Account.Id).containsAll(recordIds),
85+
domain.getIdFieldValues(Schema.Account.Id).equals(recordIds),
8686
'The domain should return all the record Ids'
8787
);
8888
}
@@ -132,28 +132,22 @@ private class fflib_SObjectsTest
132132
{
133133
DomainAccounts domain = generateDomain();
134134

135+
final Set<String> expected = new Set<String>
136+
{
137+
null,
138+
'',
139+
'Canada',
140+
'Ireland',
141+
'UK',
142+
'USA'
143+
};
135144
System.assert(
136-
domain.getStringFieldValues(Schema.Account.ShippingCountry)
137-
.containsAll(
138-
new Set<String>{
139-
'USA',
140-
'Ireland',
141-
'UK',
142-
''
143-
}
144-
)
145+
domain.getStringFieldValues(Schema.Account.ShippingCountry).equals(expected)
145146
);
146147

147148
System.assert(
148149
domain.getFieldValues(Schema.Account.ShippingCountry)
149-
.containsAll(
150-
new Set<Object>{
151-
'USA',
152-
'Ireland',
153-
'UK',
154-
''
155-
}
156-
)
150+
.equals(expected)
157151
);
158152
}
159153

0 commit comments

Comments
 (0)