Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr PG Gajek <[email protected]>
  • Loading branch information
pgajek2 committed Mar 26, 2024
1 parent 8d60a2b commit 2d8edb3
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions force-app/main/default/classes/SOQL.cls
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
**/
@SuppressWarnings('PMD.ExcessivePublicCount, PMD.ExcessiveClassLength, PMD.CyclomaticComplexity, PMD.CognitiveComplexity, PMD.PropertyNamingConventions, PMD.FieldDeclarationsShouldBeAtStart, PMD.ApexDoc, PMD.ExcessiveParameterList')
public virtual inherited sharing class SOQL implements Queryable {

public static SubQuery SubQuery {
get {
return new SoqlSubQuery();
Expand Down Expand Up @@ -860,16 +859,15 @@ public virtual inherited sharing class SOQL implements Queryable {
public override String toString() {
binder = new Binder();

List<String> soqlParts = new List<String>();
String query = '';

for (QueryClause clause : clauses) {
if (clause == null) {
continue;
if (clause != null) {
query += ' ' + clause.toString();
}
soqlParts.add(clause.toString());
}

return String.join(soqlParts, ' ').trim();
return query.trim();
}
}

Expand Down Expand Up @@ -1222,8 +1220,8 @@ public virtual inherited sharing class SOQL implements Queryable {
}
}

public interface FilterClause {
Boolean isEmpty();
private interface FilterClause {
Boolean hasValue();
}

private virtual class SoqlFilterGroup implements FilterGroup {
Expand All @@ -1244,10 +1242,9 @@ public virtual inherited sharing class SOQL implements Queryable {
}

public FilterGroup add(FilterClause condition) {
if (condition.isEmpty()) {
return this;
if (condition.hasValue()) {
queryConditions.add(condition);
}
queryConditions.add(condition);
return this;
}

Expand Down Expand Up @@ -1322,8 +1319,8 @@ public virtual inherited sharing class SOQL implements Queryable {
this.filterGroup = filterGroup;
}

public Boolean isEmpty() {
return !filterGroup.hasValues();
public Boolean hasValue() {
return filterGroup.hasValues();
}

public override String toString() {
Expand All @@ -1338,8 +1335,8 @@ public virtual inherited sharing class SOQL implements Queryable {
this.filter = filter;
}

public Boolean isEmpty() {
return !filter.hasValue();
public Boolean hasValue() {
return filter.hasValue();
}

public override String toString() {
Expand All @@ -1354,8 +1351,8 @@ public virtual inherited sharing class SOQL implements Queryable {
conditionString = dynamicCondition;
}

public Boolean isEmpty() {
return String.isEmpty(conditionString);
public Boolean hasValue() {
return String.isNotEmpty(conditionString);
}

public override String toString() {
Expand Down

0 comments on commit 2d8edb3

Please sign in to comment.