Skip to content

Commit a0a72dd

Browse files
committed
Format source codes.
1 parent 3416d67 commit a0a72dd

File tree

18 files changed

+7596
-5368
lines changed

18 files changed

+7596
-5368
lines changed

src/main/java/com/github/underscore/MemoizeFunction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
public abstract class MemoizeFunction<F, T> implements Function<F, T> {
88
private final Map<F, T> cache = new LinkedHashMap<>();
9+
910
public abstract T calc(final F n);
1011

1112
public T apply(final F key) {

src/main/java/com/github/underscore/Optional.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ public static <T> Optional<T> of(final T arg) {
2525
}
2626

2727
public static <T> Optional<T> fromNullable(final T nullableReference) {
28-
return nullableReference == null ? Optional.<T>empty()
29-
: new Optional<>(nullableReference);
28+
return nullableReference == null ? Optional.<T>empty() : new Optional<>(nullableReference);
3029
}
3130

3231
@SuppressWarnings("unchecked")

src/main/java/com/github/underscore/Trie.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static class TrieNode {
2828
// Initialize your data structure here.
2929
TrieNode[] children;
3030
boolean isWord;
31+
3132
public TrieNode() {
3233
children = new TrieNode[1071];
3334
}

src/main/java/com/github/underscore/U.java

Lines changed: 415 additions & 272 deletions
Large diffs are not rendered by default.

src/main/java/com/github/underscore/lodash/Json.java

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,40 +34,54 @@ public final class Json {
3434

3535
public static class JsonStringBuilder {
3636
public enum Step {
37-
TWO_SPACES(2), THREE_SPACES(3), FOUR_SPACES(4), COMPACT(0), TABS(1);
37+
TWO_SPACES(2),
38+
THREE_SPACES(3),
39+
FOUR_SPACES(4),
40+
COMPACT(0),
41+
TABS(1);
3842
private final int ident;
43+
3944
Step(int ident) {
4045
this.ident = ident;
4146
}
47+
4248
public int getIdent() {
4349
return ident;
4450
}
4551
}
52+
4653
public enum Type {
47-
PURE("", "\n", "", "\""), JAVA("\"", "\\n\"\n + \"", "\";", "\\\"");
54+
PURE("", "\n", "", "\""),
55+
JAVA("\"", "\\n\"\n + \"", "\";", "\\\"");
4856
private final String initial;
4957
private final String newLine;
5058
private final String tailLine;
5159
private final String wrapLine;
60+
5261
Type(String initial, String newLine, String tailLine, String wrapLine) {
5362
this.initial = initial;
5463
this.newLine = newLine;
5564
this.tailLine = tailLine;
5665
this.wrapLine = wrapLine;
5766
}
67+
5868
public String getInitial() {
5969
return initial;
6070
}
71+
6172
public String getNewLine() {
6273
return newLine;
6374
}
75+
6476
public String getTailLine() {
6577
return tailLine;
6678
}
79+
6780
public String getWrapLine() {
6881
return wrapLine;
6982
}
7083
}
84+
7185
private final StringBuilder builder;
7286
private final Step identStep;
7387
private final Type type;
@@ -358,7 +372,8 @@ public static void writeJson(Object value, JsonStringBuilder builder) {
358372
builder.append(NULL);
359373
} else if (value instanceof String) {
360374
builder.append(builder.type.getWrapLine())
361-
.append(escape((String) value)).append(builder.type.getWrapLine());
375+
.append(escape((String) value))
376+
.append(builder.type.getWrapLine());
362377
} else if (value instanceof Double) {
363378
if (((Double) value).isInfinite() || ((Double) value).isNaN()) {
364379
builder.append(NULL);
@@ -441,8 +456,9 @@ private static void escape(String s, StringBuilder sb) {
441456
sb.append("€");
442457
break;
443458
default:
444-
if (ch <= '\u001F' || ch >= '\u007F' && ch <= '\u009F'
445-
|| ch >= '\u2000' && ch <= '\u20FF') {
459+
if (ch <= '\u001F'
460+
|| ch >= '\u007F' && ch <= '\u009F'
461+
|| ch >= '\u2000' && ch <= '\u20FF') {
446462
String ss = Integer.toHexString(ch);
447463
sb.append("\\u");
448464
for (int k = 0; k < 4 - ss.length(); k++) {
@@ -675,8 +691,12 @@ private void readEscape() {
675691
if (isHexCharsDigits) {
676692
captureBuffer.append((char) Integer.parseInt(new String(hexChars), 16));
677693
} else {
678-
captureBuffer.append("\\u").append(hexChars[0]).append(hexChars[1]).append(hexChars[2])
679-
.append(hexChars[3]);
694+
captureBuffer
695+
.append("\\u")
696+
.append(hexChars[0])
697+
.append(hexChars[1])
698+
.append(hexChars[2])
699+
.append(hexChars[3]);
680700
}
681701
break;
682702
default:
@@ -693,17 +713,16 @@ private Number readNumber() {
693713
throw expected(DIGIT);
694714
}
695715
if (firstDigit != '0') {
696-
while (readDigit()) {
697-
}
716+
while (readDigit()) {}
698717
}
699718
readFraction();
700719
readExponent();
701720
final String number = endCapture();
702721
final Number result;
703722
if (number.contains(".") || number.contains("e") || number.contains("E")) {
704-
if (number.length() > 9 || (number.contains(".")
705-
&& number.length() - number.lastIndexOf('.') > 2)
706-
&& number.charAt(number.length() - 1) == '0') {
723+
if (number.length() > 9
724+
|| (number.contains(".") && number.length() - number.lastIndexOf('.') > 2)
725+
&& number.charAt(number.length() - 1) == '0') {
707726
result = new java.math.BigDecimal(number);
708727
} else {
709728
result = Double.valueOf(number);
@@ -725,8 +744,7 @@ private boolean readFraction() {
725744
if (!readDigit()) {
726745
throw expected(DIGIT);
727746
}
728-
while (readDigit()) {
729-
}
747+
while (readDigit()) {}
730748
return true;
731749
}
732750

@@ -740,8 +758,7 @@ private boolean readExponent() {
740758
if (!readDigit()) {
741759
throw expected(DIGIT);
742760
}
743-
while (readDigit()) {
744-
}
761+
while (readDigit()) {}
745762
return true;
746763
}
747764

@@ -828,14 +845,14 @@ private boolean isDigit() {
828845
}
829846

830847
private boolean isHexDigit() {
831-
return isDigit() || current >= 'a' && current <= 'f' || current >= 'A'
832-
&& current <= 'F';
848+
return isDigit()
849+
|| current >= 'a' && current <= 'f'
850+
|| current >= 'A' && current <= 'F';
833851
}
834852

835853
private boolean isEndOfText() {
836854
return current == -1;
837855
}
838-
839856
}
840857

841858
public static String toJson(Collection collection, JsonStringBuilder.Step identStep) {

0 commit comments

Comments
 (0)