Skip to content

Instantly share code, notes, and snippets.

View vple's full-sized avatar

Vincent vple

  • Brooklyn, New York
View GitHub Profile
{
"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",

Optionals

Where To Use Optionals

Rule
Do not use Optional for constructor or method parameters.

Rule
Do not declare instance variables as Optional.

Suggestion

Optionals

Where To Use Optionals

Rule
Do not use Optional for constructor or method parameters.

Rule

Do not declare instance variables as Optional.

{
"newAccount": {
"autoPay": true,
"batch": "Batch1",
"billCycleDay": 0,
"billToContact": {
"address1": "1 madison ave",
"address2": "5th floor",
"city": "new york",
"country": "US",
@vple
vple / MatchesColorSpec.java
Last active May 27, 2018 15:16
Reusable matches color spec
/**
* Determines if the given objects have the specified color.
*/
public class MatchesColorSpec {
private final Color color;
public MatchesColorSpec(Color color) {
this.color = color;
}
@vple
vple / MatchesColorSpec.java
Created May 27, 2018 15:06
Initial matches color spec
/**
* 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 = "";