Skip to content

Improved consistency in writing Util classes and removed raw types to make types more stable #3408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
* @author Greg Turnquist
* @since 2.7.0
*/
public final class JSqlParserUtils {
public abstract class JSqlParserUtils {

private JSqlParserUtils() {}
private JSqlParserUtils() {
throw new IllegalStateException("Cannot instantiate a utility class!");
}

/**
* Generates a count function call, based on the {@code countFields}.
Expand All @@ -49,7 +51,7 @@ public static Function getJSqlCount(final List<String> countFields, final boolea
.map(Column::new) //
.collect(Collectors.toList());

ExpressionList countExpression = new ExpressionList(countColumns);
ExpressionList<Expression> countExpression = new ExpressionList<>(countColumns);

return new Function() //
.withName("count") //
Expand All @@ -66,7 +68,7 @@ public static Function getJSqlCount(final List<String> countFields, final boolea
public static Function getJSqlLower(String column) {

List<Expression> expressions = Collections.singletonList(new Column(column));
ExpressionList lowerParamExpression = new ExpressionList(expressions);
ExpressionList<Expression> lowerParamExpression = new ExpressionList<>(expressions);

return new Function() //
.withName("lower") //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private enum MetaKey {
}
}

private Map<String, Object> values = Collections.emptyMap();
private Map<String, Object> values = new LinkedHashMap<>(2);

public Meta() {}

Expand Down Expand Up @@ -100,10 +100,6 @@ void setValue(String key, @Nullable Object value) {

Assert.hasText(key, "Meta key must not be 'null' or blank");

if (values == Collections.EMPTY_MAP) {
values = new LinkedHashMap<>(2);
}

if (value == null || (value instanceof String stringValue && !StringUtils.hasText(stringValue))) {
this.values.remove(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ static boolean hasNamedQuery(EntityManager em, String queryName) {
* See DATAJPA-617, we have to use a dedicated em for the lookups to avoid a
* potential rollback of the running tx.
*/
EntityManager lookupEm = em.getEntityManagerFactory().createEntityManager();

try {
try (EntityManager lookupEm = em.getEntityManagerFactory().createEntityManager()) {
lookupEm.createNamedQuery(queryName);
return true;
} catch (IllegalArgumentException e) {
Expand All @@ -118,8 +117,6 @@ static boolean hasNamedQuery(EntityManager em, String queryName) {
LOG.debug(String.format("Did not find named query %s", queryName));
}
return false;
} finally {
lookupEm.close();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @author Greg Turnquist
* @since 3.0
*/
public final class PageableUtils {
public abstract class PageableUtils {

private PageableUtils() {
throw new IllegalStateException("Cannot instantiate a utility class!");
Expand Down
Loading