-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up. Add SObjectFunction interface to DebugSObject. Rename noun-…
…like functions to verb-like.
- Loading branch information
Showing
39 changed files
with
149 additions
and
207 deletions.
There are no files selected for viewing
42 changes: 21 additions & 21 deletions
42
force-app/main/default/classes/collection/ObjectCollection.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
public with sharing class ObjectCollection { | ||
private List<Object> objects; | ||
private List<Object> objects; | ||
|
||
public static ObjectCollection of(Iterable<Object> objects) { | ||
return new ObjectCOllection(objects); | ||
} | ||
public static ObjectCollection of(Iterable<Object> objects) { | ||
return new ObjectCollection(objects); | ||
} | ||
|
||
private ObjectCollection(Iterable<Object> objects) { | ||
this.objects = new List<Object>(); | ||
Iterator<Object> iter = objects.iterator(); | ||
while (iter.hasNext()) { | ||
this.objects.add(iter.next()); | ||
} | ||
} | ||
private ObjectCollection(Iterable<Object> objects) { | ||
this.objects = new List<Object>(); | ||
Iterator<Object> iter = objects.iterator(); | ||
while (iter.hasNext()) { | ||
this.objects.add(iter.next()); | ||
} | ||
} | ||
|
||
public List<Object> asList(Type listType) { | ||
List<Object> typedObjects = (List<Object>) listType.newInstance(); | ||
typedObjects.addAll(this.objects); | ||
return typedObjects; | ||
} | ||
public List<Object> asList(Type listType) { | ||
List<Object> typedObjects = (List<Object>) listType.newInstance(); | ||
typedObjects.addAll(this.objects); | ||
return typedObjects; | ||
} | ||
|
||
public Set<Object> asSet(Type setType) { | ||
Set<Object> typedObjects = (Set<Object>) setType.newInstance(); | ||
typedObjects.addAll(this.objects); | ||
return typedObjects; | ||
} | ||
public Set<Object> asSet(Type setType) { | ||
Set<Object> typedObjects = (Set<Object>) setType.newInstance(); | ||
typedObjects.addAll(this.objects); | ||
return typedObjects; | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
force-app/main/default/classes/collection/SObjectCollection.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 0 additions & 84 deletions
84
force-app/main/default/classes/function/IncompleteFieldsMatch.cls
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
force-app/main/default/classes/function/IncompleteMatchFields.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
public class IncompleteMatchFields { | ||
private final MatchFields baseMatch; | ||
private final String fieldPath; | ||
|
||
public IncompleteMatchFields(MatchFields baseMatch, Schema.SObjectField field) { | ||
this.baseMatch = baseMatch; | ||
this.fieldPath = field.getDescribe().getName(); | ||
} | ||
|
||
public IncompleteMatchFields(MatchFields baseMatch, String fieldPath) { | ||
this.baseMatch = baseMatch; | ||
this.fieldPath = fieldPath; | ||
} | ||
|
||
// helper for all other methods | ||
private MatchFields filterWith(BinaryRelation relation, Object value) { | ||
this.baseMatch.addCondition(new MatchFieldCondition(this.fieldPath, relation, value)); | ||
return this.baseMatch; | ||
} | ||
|
||
public MatchFields equals(Object value) { | ||
return filterWith(BinaryRelation.EQUALS, value); | ||
} | ||
|
||
public MatchFields eq(Object value) { | ||
return equals(value); | ||
} | ||
|
||
public MatchFields notEquals(Object value) { | ||
return filterWith(BinaryRelation.NOT_EQUALS, value); | ||
} | ||
|
||
public MatchFields neq(Object value) { | ||
return notEquals(value); | ||
} | ||
|
||
public MatchFields lessThan(Object value) { | ||
return filterWith(BinaryRelation.LESS_THAN, value); | ||
} | ||
|
||
public MatchFields lt(Object value) { | ||
return lessThan(value); | ||
} | ||
|
||
public MatchFields lessThanOrEquals(Object value) { | ||
return filterWith(BinaryRelation.LESS_THAN_OR_EQUALS, value); | ||
} | ||
|
||
public MatchFields leq(Object value) { | ||
return lessThanOrEquals(value); | ||
} | ||
|
||
public MatchFields greaterThan(Object value) { | ||
return filterWith(BinaryRelation.GREATER_THAN, value); | ||
} | ||
|
||
public MatchFields gt(Object value) { | ||
return greaterThan(value); | ||
} | ||
|
||
public MatchFields greaterThanOrEquals(Object value) { | ||
return filterWith(BinaryRelation.GREATER_THAN_OR_EQUALS, value); | ||
} | ||
|
||
public MatchFields geq(Object value) { | ||
return greaterThanOrEquals(value); | ||
} | ||
|
||
public MatchFields hasValue() { | ||
return notEquals(null); | ||
} | ||
|
||
public MatchFields isIn(Object value) { | ||
return filterWith(BinaryRelation.IS_IN, value); | ||
} | ||
|
||
public MatchFields notIn(Object value) { | ||
return filterWith(BinaryRelation.NOT_IN, value); | ||
} | ||
|
||
public MatchFields isNotIn(Object value) { | ||
return notIn(value); | ||
} | ||
} |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
.../classes/function/FieldMatchCondition.cls → .../classes/function/MatchFieldCondition.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...lt/classes/function/RecordFieldsMatch.cls → ...lt/classes/function/MatchRecordFields.cls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
public with sharing class MatchSObject { | ||
public RecordFieldsMatch recordFields(SObject prototype) { | ||
return new RecordFieldsMatch(prototype); | ||
public MatchRecordFields recordFields(SObject prototype) { | ||
return new MatchRecordFields(prototype); | ||
} | ||
|
||
public IncompleteFieldsMatch field(Schema.SObjectField field) { | ||
return new IncompleteFieldsMatch(new FieldsMatch(), field); | ||
public IncompleteMatchFields field(Schema.SObjectField field) { | ||
return new IncompleteMatchFields(new MatchFields(), field); | ||
} | ||
|
||
public IncompleteFieldsMatch field(String fieldPath) { | ||
return new IncompleteFieldsMatch(new FieldsMatch(), fieldPath); | ||
public IncompleteMatchFields field(String fieldPath) { | ||
return new IncompleteMatchFields(new MatchFields(), fieldPath); | ||
} | ||
} |
Oops, something went wrong.