Skip to content

Commit

Permalink
Minlopro: Storage Helper WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomeandrey committed Dec 5, 2024
1 parent a6e455d commit 3a5c99c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/minlopro-core/main/classes/util/Lists.cls
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public inherited sharing class Lists {
return !isEmpty(values);
}

public static Boolean isEmpty(List<SObject> values) {
if (values == null) {
return true;
}
return values.isEmpty();
}
// Randomizer;

public static Boolean isNotEmpty(List<SObject> values) {
return !isEmpty(values);
public static Object getRandomItem(List<Object> values) {
if (isEmpty(values)) {
return null;
}
// Generate a random index between 0 and items.size() - 1
Integer randomIndex = Math.floor(Math.random() * values.size()).intValue();
return values[randomIndex];
}

// Working with 'String's;
Expand Down
16 changes: 7 additions & 9 deletions src/minlopro-core/main/classes/util/Sets.cls
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ public inherited sharing class Sets {

// Verify SET emptiness;

public static Boolean isEmpty(Set<Id> recordIds) {
return recordIds == null || recordIds.isEmpty();
public static Boolean isEmpty(Set<Object> values) {
return values == null || values.isEmpty();
}

public static Boolean isNotEmpty(Set<Id> recordIds) {
return !isEmpty(recordIds);
public static Boolean isNotEmpty(Set<Object> values) {
return !isEmpty(values);
}

public static Boolean isEmpty(Set<String> values) {
return values == null || values.isEmpty();
}
// Randomizer;

public static Boolean isNotEmpty(Set<String> values) {
return !isEmpty(values);
public static Object getRandomItem(Set<Object> values) {
return Lists.getRandomItem(new List<Object>(values));
}

// Working with 'Id's;
Expand Down

0 comments on commit 3a5c99c

Please sign in to comment.