Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
usfalami committed Aug 27, 2024
1 parent c5521a9 commit aa5b5ad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/usf/jquery/core/JDBCType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.util.Objects.isNull;
import static java.util.Optional.empty;
import static java.util.Optional.ofNullable;

/**
*
Expand Down Expand Up @@ -72,8 +73,8 @@ public Class<?> typeClass() {

@Override
public boolean accept(Object o) {
if(o instanceof Typed) {
var t = ((Typed) o).getType();
if(o instanceof Typed v) {
var t = v.getType();
return t == this || isNull(t) || superType.isAssignableFrom(t.typeClass());
}
return isNull(o) || matcher.test(o);
Expand All @@ -99,7 +100,7 @@ public static Optional<JDBCType> typeOf(Object o) {
if(o instanceof Typed to) {
return Optional.of(to.getType());
}
return Optional.of(o).flatMap(v-> findType(e-> e.typeClass().isInstance(o)));
return ofNullable(o).flatMap(v-> findType(e-> e.typeClass().isInstance(o)));
}

public static Optional<JDBCType> fromDataType(int value) {
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/usf/jquery/web/RequestParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class RequestParser {
private char c;

private RequestParser(String s) {
this.s = requireNonNull(s, "value is null");
this.s = s;
this.size = s.length();
this.c = size == 0 ? 0 : s.charAt(idx);
}
Expand All @@ -31,15 +31,17 @@ public static RequestEntryChain parseEntry(String s) {
}

public static List<RequestEntryChain> parseEntries(String s) {
return s.isEmpty() ? emptyList() : new RequestParser(s).parseEntries(true, c-> false);
return requireNonNull(s, "value is null").isEmpty()
? emptyList()
: new RequestParser(s).parseEntries(true, c-> false);
}

private List<RequestEntryChain> parseEntries(boolean multiple, CharPredicate until) {
var entries = new ArrayList<RequestEntryChain>();
entries.add(parseEntry());
if(multiple) {
while(c == ',') {
nextChar(true);
nextChar(false); //null parameter
entries.add(parseEntry());
}
}
Expand Down Expand Up @@ -77,7 +79,7 @@ private RequestEntryChain parseEntry() {
nextChar(false);
return new RequestEntryChain(txt, true); //no next, no args, no tag
}
return new RequestEntryChain(legalNumber(c) || c == '-' ? nextWhile(RequestParser::legalValChar) : null); // decimal negative? & instant format
return new RequestEntryChain(legalNumber(c) || c == '-' ? nextWhile(RequestParser::legalValChar) : null); // decimal negative? | instant format
}

private String nextWhile(CharPredicate cp) {
Expand Down

0 comments on commit aa5b5ad

Please sign in to comment.