Skip to content

Commit

Permalink
git add --all
Browse files Browse the repository at this point in the history
  • Loading branch information
Petersburg2020 committed Dec 26, 2022
1 parent f5f214b commit ab40b96
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 48 additions & 6 deletions src/main/java/nx/peter/java/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ else if (isObject(value))
else if (isArray(value))
value = format ? toPrettyJson((List<Object>) value, indent + 1) : toJson((List<Object>) value, indent + 1);
return (format ? "\n" + tab(indent + 1) : "") + value;
}).toList().toString();
}).collect(Collectors.toList()).toString();
}

public static String toJson(Map<String, Object> json, int indent, boolean format) {
Expand All @@ -160,7 +160,7 @@ else if (isObject(value))
else if (isArray(value))
value = format ? toPrettyJson((List<Object>) value, indent + 1) : toJson((List<Object>) value, indent + 1);
return (format ? "\n" + tab(indent + 1) : "") + "\"" + e.getKey() + "\": " + value;
}).toList().toString();
}).collect(Collectors.toList()).toString();
}


Expand Down Expand Up @@ -1104,8 +1104,10 @@ public String toString() {
}
}

public record MinMax<N extends Number>(N min, N max) {
public MinMax {
public static class MinMax<N extends Number> {
protected N max, min;

public MinMax(N min, N max) {
N a = min, b = max;
if (a != null && b != null) {
if (a instanceof Integer) {
Expand Down Expand Up @@ -1218,6 +1220,8 @@ public record MinMax<N extends Number>(N min, N max) {
}
}
}
this.max = max;
this.min = min;
}

public N diff() {
Expand Down Expand Up @@ -1294,6 +1298,14 @@ public boolean isLong() {
return max instanceof Long;
}

public N min() {
return min;
}

public N max() {
return max;
}

@Override
public String toString() {
return "[min=" + min + ", max=" + max + ']';
Expand Down Expand Up @@ -1493,7 +1505,22 @@ public String toString() {

}

public record DataCount<D extends Number>(D data, int count) implements Comparable<DataCount<D>> {
public static class DataCount<D extends Number> implements Comparable<DataCount<D>> {
protected int count;
protected D data;

public DataCount(D data, int count) {
this.data = data;
this.count = count;
}

public D data() {
return data;
}

public int count() {
return count;
}

public boolean equals(DataCount<?> other) {
return other != null && equals(other.data()) && count == other.count;
Expand Down Expand Up @@ -1644,7 +1671,22 @@ public String toString() {
}


public record TrimmedLine(String line, String trimmed) {
public static class TrimmedLine {
protected String line, trimmed;

public TrimmedLine(String line, String trimmed) {
this.line = line;
this.trimmed = trimmed;
}

public String line() {
return line;
}

public String trimmed() {
return trimmed;
}

}

public enum Position {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/nx/peter/java/util/data/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public double getIndex() {
ind.append('.');
else
ind.append(getIndex(c));
return ind.isEmpty() ? 0 : (index > 0 ? -1 : 1) * Double.parseDouble(ind.toString());
return ind.toString().isEmpty() ? 0 : (index > 0 ? -1 : 1) * Double.parseDouble(ind.toString());
}

public Fraction toFraction() {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/nx/peter/java/util/data/Letters.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.stream.Stream;


Expand Down Expand Up @@ -975,9 +976,9 @@ private int endIndexOf(CharSequence delimiter, int start, CharSequence ifContain
// System.out.println(substring(start, end));
Word sub = new Word(substring(start, end));
if (containsAll(sub.get(), mustContain))
if (!ifContain.isEmpty() && sub.contains(ifContain)) {
if (!ifContain.toString().isEmpty() && sub.contains(ifContain)) {
String ender = getEndDelimiter(sub.get(), delimiter);
if (mustEnd.isEmpty() || (ender != null ? sub.subLetters(0, sub.lastIndexOf(ender)) : sub.trim()).endsWith(mustEnd.toString()))
if (mustEnd.toString().isEmpty() || (ender != null ? sub.subLetters(0, sub.lastIndexOf(ender)) : sub.trim()).endsWith(mustEnd.toString()))
return end;
} else return end;
}
Expand Down Expand Up @@ -1196,7 +1197,7 @@ public Letters getParent() {
}

public List<D> toList() {
return stream().toList();
return new ArrayList<>(items);
}

public List<String> toStringList() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/nx/peter/java/util/data/Subscript.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected static String toSubscript(char data) {

protected static String toSubscript(CharSequence data) {
StringBuilder sub = new StringBuilder();
if (data != null && !data.isEmpty())
if (data != null && !data.toString().isEmpty())
for (char c : data.toString().toCharArray())
if (!isSubscript(c)) {
sub.append(toSubscript(c));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/nx/peter/java/util/data/Superscript.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ protected static String toSuperscript(char data) {

protected static String toSuperscript(CharSequence data) {
StringBuilder sub = new StringBuilder();
if (data != null && !data.isEmpty())
if (data != null && !data.toString().isEmpty())
for (char c : data.toString().toCharArray())
if (!isSuperscript(c)) {
sub.append(toSuperscript(c));
Expand Down

0 comments on commit ab40b96

Please sign in to comment.