Rule
Do not useOptional
for constructor or method parameters.
Rule
Do not declare instance variables asOptional
.
Suggestion
{ | |
"existingAccountNumber": "A00000065", | |
"orderDate": "2018-07-09", | |
"previewOptions": { | |
"previewThruType": "SpecificDate", | |
"previewTypes": [ | |
"ChargeMetrics", | |
"BillingDocs", | |
"OrderMetrics" | |
], |
{ | |
"orderDate": "2018-06-26", | |
"previewAccountInfo": { | |
"billCycleDay": 0, | |
"currency": "USD", | |
"customFields": { | |
"YextBusinessID__c": "0" | |
}, | |
"soldToContact": { | |
"city": "new york", |
{ | |
"newAccount": { | |
"autoPay": true, | |
"batch": "Batch1", | |
"billCycleDay": 0, | |
"billToContact": { | |
"address1": "1 madison ave", | |
"address2": "5th floor", | |
"city": "new york", | |
"country": "US", |
/** | |
* Determines if the given objects have the specified color. | |
*/ | |
public class MatchesColorSpec { | |
private final Color color; | |
public MatchesColorSpec(Color color) { | |
this.color = color; | |
} | |
/** | |
* Determines if the given objects have the specified color. | |
*/ | |
public class MatchesColorSpec { | |
public static boolean isSatisfiedBy(Color color, Collection<Colored> objects) { | |
return objects.stream() | |
.allMatch(object -> object.hasColor(color)); | |
} | |
} |
public static String int2String(int n) { | |
if (n == 0) { | |
return "0"; | |
} | |
List<String> digits = new ArrayList<>(); | |
boolean isNegative = n < 0; | |
if (isNegative) { | |
n = n * -1; | |
} |
public static String int2String(int n) { | |
if (n == 0) { | |
return "0"; | |
} | |
List<String> digits = new ArrayList<>(); | |
while (n > 0) { | |
int digit = n % 10; | |
digits.add(digit2String(digit)); |
public static String int2String(int n) { | |
List<String> digits = new ArrayList<>(); | |
while (n > 0) { | |
int digit = n % 10; | |
digits.add(digit2String(digit)); | |
n = n / 10; | |
} | |
String result = ""; |