-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
public with sharing class ObjectCollection { | ||
private List<Object> 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()); | ||
} | ||
} | ||
|
||
public List<Object> asList(Type listType) { | ||
List<Object> typedObjects = (List<Object>) listType.newInstance(); | ||
typedObjects.addAll(objects); | ||
return typedObjects; | ||
} | ||
|
||
public Set<Object> asSet(Type setType) { | ||
Set<Object> typedObjects = (Set<Object>) setType.newInstance(); | ||
typedObjects.addAll(objects); | ||
return typedObjects; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/classes/collection/ObjectCollection.cls-meta.xml
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,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>58.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |
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