Skip to content

Commit

Permalink
Fixed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddie Carpenter committed Jun 12, 2024
1 parent 11cd747 commit ba8569b
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ public static <T> EntityMetaData<T> getMetaData(Class<?> entityName)

public static void register(@Nonnull EntityMetaData<?> metaData)
{
if (metaData == null) {
throw new IllegalArgumentException("EntityMetaData cannot be null");
}//if

if (REGISTRY_ENTITY_NAMES.containsKey(metaData.getName())) {
throw new IllegalArgumentException("EntityMetaData already registered for " + metaData.getName());
}//if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
@SuppressWarnings("java:S3011")//Changing accessibility mode is needed
public class EntityLifecycleImpl implements EntityLifecycle
{
private List<Methods> listeners;
private final List<Methods> listeners;

private class Methods
private static class Methods
{
private Class<?> listenerClass;
private final Class<?> listenerClass;
private Method postLoad;
private Method prePersist;
private Method postPersist;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public PersistenceContext getPersistenceContext(@Nonnull JPALitePersistenceUnit
}//if

Map<String, PersistenceContext> connectionList = connections.get();
PersistenceContext manager = null;
PersistenceContext manager;
if (connectionList == null || connectionList.get(persistenceUnit.getPersistenceUnitName()) == null) {
LOG.trace("Creating a new Persistence Context for thread {}", Thread.currentThread().getName());
manager = new PersistenceContextImpl(this, persistenceUnit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,6 @@ protected void logError(String pmethod, String queryStr, Throwable exception)
protected void logExecution(String method, String queryStr, long executeTime, boolean update)
{
if (connection.isEnableLogging() || connection.getAuditWriter() != null) {
StringBuilder paramsStr = new StringBuilder();
if (params.isEmpty()) {
paramsStr.append(",");
}//if
else {
for (Iterator<Integer> iterator = params.keySet().iterator(); iterator.hasNext(); ) {
Integer key = iterator.next();
Object value = params.get(key);
if (value == null) {
value = NULL_STR;
}//if

paramsStr.append(",:").append(key).append("=").append(value);
}
}//else

super.logExecution(method, queryStr + " - (" + buildParamList() + ")", executeTime, update);
}//if
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class JPALiteQueryImpl<T> implements Query
/**
* The lock mode of the returned item
*/
private LockModeType lockMode = LockModeType.NONE;
private LockModeType lockMode;
/**
* The expected return type
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public class NamedQueryImpl<T> extends TypedQueryImpl<T>
{
public static final @Nonnull Map<String, Object> buildHints(Map<String, Object> hints, QueryHint[] namedHints)
{
Map<String, Object> newHints = new HashMap<>();
newHints.putAll(hints);
Map<String, Object> newHints = new HashMap<>(hints);
for (QueryHint hint : namedHints) {
newHints.put(hint.name(), hint.value());
}//for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ private Object readField(ReadContext context, TagReader reader, EntityMetaData<?
}//if
else {
EntityMetaData<?> subMetaData = EntityMetaDataManager.getMetaData(field.getType());
if (subMetaData == null) {
throw new IOException(field.getType() + " is not an entity");
}//if

Object primaryKey;
//If we have multiple keys then that primary key will be stored in an embedded object
if (metaData.hasMultipleIdFields()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
return vClassList;
}

@SuppressWarnings("java:S2112") //We need URLs here
@SuppressWarnings({"java:S2112", "UrlHashCode"}) //We need URLs here
public void execute() throws MojoExecutionException
{
if (skip) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.List;
import java.util.Map;

@SuppressWarnings("SqlSourceToSinkFlow")
public class TransactionScopedEntityManagerImpl implements JPALiteEntityManager
{
private static final Logger LOG = LoggerFactory.getLogger(TransactionScopedEntityManagerImpl.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public class Filter
public static final String AND = " AND ";
public static final String OR = " OR ";

private List<Filter> filters;
private final List<Filter> filters;
private FilterExpression filterExpressions;
private String condOper;

public class FilterExpression
public static class FilterExpression
{
private String field;
private Operators operator;
private Object[] parameter;
private final String field;
private final Operators operator;
private final Object[] parameter;

public FilterExpression(String field, Operators operator, Object... parameters)
{
Expand Down Expand Up @@ -68,7 +68,7 @@ public String getExpression(Map<String, Object> params)
if (paramNr > 1) {
expr.append(",");
}//if
expr.append(":" + paramName + paramNr);
expr.append(":").append(paramName).append(paramNr);
paramNr++;
}//for
expr.append(")");
Expand All @@ -82,7 +82,7 @@ public String getExpression(Map<String, Object> params)
int paramNr = 1;
for (Object param : parameter) {
params.put(paramName + paramNr, operator.getPrefix() + param + operator.getPostfix());
expr.append(" :" + paramName + paramNr);
expr.append(" :").append(paramName).append(paramNr);
paramNr++;
}//for
yield expr.toString();
Expand All @@ -98,7 +98,7 @@ public String getExpression(Map<String, Object> params)
if (paramNr > 1) {
expr.append(",");
}//if
expr.append(" :" + paramName + paramNr);
expr.append(" :").append(paramName).append(paramNr);
paramNr++;
}//for
yield expr.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,12 @@ private void createMethod(PrintWriter out, ExecutableElement method)
method.getParameters()
.stream()
.filter(p -> p.asType().toString().equals(Pageable.class.getName()))
.forEach(p -> pageAndSort.append("query.setFirstResult(" + p.getSimpleName() + ".getPageIndex())\n")
.append(".setMaxResults(" + p.getSimpleName() + ".getPageSize());\n"));
.forEach(p -> pageAndSort.append("query.setFirstResult(")
.append(p.getSimpleName())
.append(".getPageIndex())\n")
.append(".setMaxResults(")
.append(p.getSimpleName())
.append(".getPageSize());\n"));
}//if
else {
out.println("String queryStr = \"" + query.value() + "\";");
Expand All @@ -277,8 +281,12 @@ private void createMethod(PrintWriter out, ExecutableElement method)
.filter(p -> p.asType().toString().equals(Pageable.class.getName()))
.forEach(p ->
{
pageAndSort.append("query.setFirstResult(" + p.getSimpleName() + ".getPageIndex())\n")
.append(".setMaxResults(" + p.getSimpleName() + ".getPageSize());\n");
pageAndSort.append("query.setFirstResult(")
.append(p.getSimpleName())
.append(".getPageIndex())\n")
.append(".setMaxResults(")
.append(p.getSimpleName())
.append(".getPageSize());\n");
out.println("queryStr += " + p.getSimpleName() + ".getSort().getOrderBy();");
});
method.getParameters()
Expand Down
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@

<distributionManagement>
<repository>
<id>TradeSwitch</id>
<name>Internal TradeSwitch Release Repository</name>
<url>https://nexus.frei.dev/repository/tradeswitch.dev/</url>
<id>devrepo</id>
<name>Dev Repo</name>
<url>http://localhost:8046/artifactory/devrepo/</url>
<layout>default</layout>
</repository>
</distributionManagement>
</profile>
Expand Down

0 comments on commit ba8569b

Please sign in to comment.