[Minor] Automated Code cleanup: Redundant local variable

This commit is contained in:
Robert von Burg 2023-04-04 11:38:33 +02:00
parent 238e8e2610
commit 373b582a44
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
47 changed files with 70 additions and 145 deletions

View File

@ -30,13 +30,12 @@ public class ObserverEvent {
}
private static String collectSizeByType(Map.Entry<String, List<StrolchRootElement>> entry) {
String sizeByType = entry.getValue()
return entry.getValue()
.stream()
.collect(groupingBy(StrolchElement::getType))
.entrySet()
.stream()
.map(e -> e.getKey() + "=" + e.getValue().size())
.collect(joining(","));
return sizeByType;
}
}

View File

@ -141,7 +141,6 @@ public class ComponentController {
@Override
public String toString() {
String builder = "ComponentController [component=" + this.component.getName() + "]";
return builder;
return "ComponentController [component=" + this.component.getName() + "]";
}
}

View File

@ -79,8 +79,7 @@ public class ConfigurationParser {
globalEnvBuilder.merge(envBuilder);
// build configuration
StrolchConfiguration strolchConfiguration = globalEnvBuilder.build(configPathF, dataPathF, tempPathF);
return strolchConfiguration;
return globalEnvBuilder.build(configPathF, dataPathF, tempPathF);
}
}

View File

@ -28,8 +28,6 @@ public class ResourceGeneratorHandlerTestImpl extends StrolchComponent implement
@Override
public Resource getTestResource(String id, String name, String type) {
Resource resource = new Resource(id, name, type);
return resource;
return new Resource(id, name, type);
}
}

View File

@ -295,11 +295,8 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
@Override
public String toString() {
String builder =
"Order [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", state=" + this.state
+ ", date=" + ISO8601.toString(this.date) + ", version=" + this.version + "]";
return builder;
return "Order [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", state=" + this.state
+ ", date=" + ISO8601.toString(this.date) + ", version=" + this.version + "]";
}
@Override

View File

@ -1237,8 +1237,6 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
@Override
public String toString() {
String builder = "ParameterizedElement [id=" + this.id + ", name=" + this.name + ", type=" + this.type + "]";
return builder;
return "ParameterizedElement [id=" + this.id + ", name=" + this.name + ", type=" + this.type + "]";
}
}

View File

@ -383,10 +383,7 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
@Override
public String toString() {
String builder =
"Resource [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", version=" + this.version;
return builder;
return "Resource [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", version=" + this.version;
}
@Override

View File

@ -242,12 +242,10 @@ public class Version {
@Override
public String toString() {
String builder =
"Version [version=" + this.version + ", locator=" + this.locator + ", createdBy=" + this.createdBy
+ ", updatedBy=" + this.updatedBy + ", created=" + ISO8601FormatFactory.getInstance()
.formatDate(this.created) + ", updated=" + ISO8601FormatFactory.getInstance()
.formatDate(this.updated) + ", deleted=" + this.deleted + "]";
return builder;
return "Version [version=" + this.version + ", locator=" + this.locator + ", createdBy=" + this.createdBy
+ ", updatedBy=" + this.updatedBy + ", created=" + ISO8601FormatFactory.getInstance()
.formatDate(this.created) + ", updated=" + ISO8601FormatFactory.getInstance()
.formatDate(this.updated) + ", deleted=" + this.deleted + "]";
}
/**

View File

@ -368,9 +368,8 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
@Override
public String toString() {
String builder = "Action [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", resourceId="
return "Action [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", resourceId="
+ this.resourceId + ", state=" + this.state + "]";
return builder;
}
@Override

View File

@ -102,8 +102,7 @@ public abstract class PolicyDef {
@Override
public String toString() {
String sb = "PolicyDef [type=" + this.type + ", value=" + this.value + "]";
return sb;
return "PolicyDef [type=" + this.type + ", value=" + this.value + "]";
}
/**

View File

@ -107,10 +107,8 @@ public class PolicyDefs {
@Override
public String toString() {
String sb =
"PolicyDefs [parent=" + (this.parent == null ? "null" : this.parent.getLocator()) + ", policyDefMap="
+ this.policyDefMap + "]";
return sb;
return "PolicyDefs [parent=" + (this.parent == null ? "null" : this.parent.getLocator()) + ", policyDefMap="
+ this.policyDefMap + "]";
}
public boolean isReadOnly() {

View File

@ -220,9 +220,7 @@ public abstract class AbstractStrolchTimedState<T extends IValue> extends Abstra
@Override
public String toString() {
String builder = getClass().getSimpleName() + " [id=" + this.id + ", name=" + this.name + ", valueNow="
return getClass().getSimpleName() + " [id=" + this.id + ", name=" + this.name + ", valueNow="
+ this.state.getStateAt(System.currentTimeMillis()) + "]";
return builder;
}
}

View File

@ -87,7 +87,6 @@ public class AString implements Serializable {
@Override
public String toString() {
String sb = "AString [string=" + this.string + ", inverse=" + this.inverse + "]";
return sb;
return "AString [string=" + this.string + ", inverse=" + this.inverse + "]";
}
}

View File

@ -74,8 +74,7 @@ public class BooleanValue implements IValue<Boolean>, Serializable {
@Override
public String toString() {
String sb = "BooleanValue [value=" + this.value + "]";
return sb;
return "BooleanValue [value=" + this.value + "]";
}
@Override

View File

@ -100,8 +100,7 @@ public class FloatListValue implements IValue<List<Double>>, Serializable {
@Override
public String toString() {
String sb = "FloatListValue [value=" + this.value + "]";
return sb;
return "FloatListValue [value=" + this.value + "]";
}
@Override

View File

@ -73,8 +73,7 @@ public class FloatValue implements IValue<Double>, Serializable {
@Override
public String toString() {
String sb = "DoubleValue [value=" + this.value + "]";
return sb;
return "DoubleValue [value=" + this.value + "]";
}
@Override

View File

@ -100,8 +100,7 @@ public class IntegerListValue implements IValue<List<Integer>>, Serializable {
@Override
public String toString() {
String sb = "IntegerListValue [value=" + this.value + "]";
return sb;
return "IntegerListValue [value=" + this.value + "]";
}
@Override

View File

@ -74,8 +74,7 @@ public class IntegerValue implements IValue<Integer>, Serializable {
@Override
public String toString() {
String sb = "IntegerValue [value=" + this.value + "]";
return sb;
return "IntegerValue [value=" + this.value + "]";
}
@Override

View File

@ -74,8 +74,7 @@ public class LongValue implements IValue<Long>, Serializable {
@Override
public String toString() {
String sb = "LongValue [value=" + this.value + "]";
return sb;
return "LongValue [value=" + this.value + "]";
}
@Override

View File

@ -131,8 +131,7 @@ public class StringSetValue implements IValue<Set<AString>>, Serializable {
@Override
public String toString() {
String sb = "StringSetValue [aStrings=" + getValueAsString() + "]";
return sb;
return "StringSetValue [aStrings=" + getValueAsString() + "]";
}
@Override

View File

@ -78,8 +78,7 @@ public class TimeValue<T extends IValue> implements ITimeValue<T>, Serializable
@Override
public String toString() {
String sb = "TimeValue [time=" + this.time + ", value=" + this.value + "]";
return sb;
return "TimeValue [time=" + this.time + ", value=" + this.value + "]";
}
@Override

View File

@ -103,8 +103,7 @@ public class ValueChange<T extends IValue> implements IValueChange<T>, Serializa
@Override
public String toString() {
String sb = "ValueChange [time=" + this.time + ", value=" + this.value + ", stateId=" + this.stateId + "]";
return sb;
return "ValueChange [time=" + this.time + ", value=" + this.value + ", stateId=" + this.stateId + "]";
}
@Override

View File

@ -169,13 +169,11 @@ public class PrivilegeRep implements Serializable {
*/
@Override
public String toString() {
String builder =
"PrivilegeRep [name=" + this.name + ", policy=" + this.policy + ", allAllowed=" + this.allAllowed
+ ", denyList=" + (this.denyList == null ? "null" : this.denyList.size()) + ", allowList=" + (
this.allowList == null ?
"null" :
this.allowList.size()) + "]";
return builder;
return "PrivilegeRep [name=" + this.name + ", policy=" + this.policy + ", allAllowed=" + this.allAllowed
+ ", denyList=" + (this.denyList == null ? "null" : this.denyList.size()) + ", allowList=" + (
this.allowList == null ?
"null" :
this.allowList.size()) + "]";
}
@Override

View File

@ -112,10 +112,8 @@ public class RoleRep implements Serializable {
*/
@Override
public String toString() {
String builder =
"RoleRep [name=" + this.name + ", privilegeMap=" + (this.privileges == null ? "null" : this.privileges)
+ "]";
return builder;
return "RoleRep [name=" + this.name + ", privilegeMap=" + (this.privileges == null ? "null" : this.privileges)
+ "]";
}
@Override

View File

@ -353,11 +353,9 @@ public class UserRep implements Serializable {
*/
@Override
public String toString() {
String builder =
"UserRep [userId=" + this.userId + ", username=" + this.username + ", firstname=" + this.firstname
+ ", lastname=" + this.lastname + ", userState=" + this.userState + ", locale=" + this.locale
+ ", roles=" + this.roles + "]";
return builder;
return "UserRep [userId=" + this.userId + ", username=" + this.username + ", firstname=" + this.firstname
+ ", lastname=" + this.lastname + ", userState=" + this.userState + ", locale=" + this.locale
+ ", roles=" + this.roles + "]";
}
@Override

View File

@ -205,7 +205,7 @@ public class PrivilegeContainerModel {
@Override
public String toString() {
String builder = "PrivilegeContainerModel [encryptionHandlerClassName=" + this.encryptionHandlerClassName
return "PrivilegeContainerModel [encryptionHandlerClassName=" + this.encryptionHandlerClassName
+ ", encryptionHandlerParameterMap=" + this.encryptionHandlerParameterMap.size()
+ ", passwordStrengthHandlerClassName=" + this.passwordStrengthHandlerClassName
+ ", passwordStrengthHandlerParameterMap=" + this.passwordStrengthHandlerParameterMap
@ -215,6 +215,5 @@ public class PrivilegeContainerModel {
+ ", ssoHandlerParameterMap=" + this.ssoHandlerParameterMap.size() + ", privilegeHandlerParameterMap="
+ this.privilegeHandlerParameterMap.size() + ", parameterMap=" + this.parameterMap.size()
+ ", policies=" + this.policies.size() + "]";
return builder;
}
}

View File

@ -195,8 +195,7 @@ public final class PrivilegeImpl implements IPrivilege {
*/
@Override
public String toString() {
String builder = "Privilege [name=" + this.name + ", policy=" + this.policy + "]";
return builder;
return "Privilege [name=" + this.name + ", policy=" + this.policy + "]";
}
@Override

View File

@ -145,8 +145,7 @@ public final class Role {
*/
@Override
public String toString() {
String builder = "Role [name=" + this.name + ", privileges=" + this.privilegeMap.keySet() + "]";
return builder;
return "Role [name=" + this.name + ", privileges=" + this.privilegeMap.keySet() + "]";
}
@Override

View File

@ -357,10 +357,9 @@ public final class User {
*/
@Override
public String toString() {
String builder = "User [userId=" + this.userId + ", username=" + this.username + ", firstname=" + this.firstname
return "User [userId=" + this.userId + ", username=" + this.username + ", firstname=" + this.firstname
+ ", lastname=" + this.lastname + ", locale=" + this.locale + ", userState=" + this.userState
+ ", roles=" + this.roles + "]";
return builder;
}
@Override

View File

@ -41,8 +41,7 @@ public class SOQLListener extends SOQLBaseListener {
@Override
public void enterSelect_clause(Select_clauseContext ctx) {
SelectClause selectClause = new SelectClause();
pointer = selectClause;
pointer = new SelectClause();
}
@Override
@ -65,8 +64,7 @@ public class SOQLListener extends SOQLBaseListener {
@Override
public void enterWhere_clause(Where_clauseContext ctx) {
WhereExpression whereExpression = new WhereExpression();
pointer = whereExpression;
pointer = new WhereExpression();
}
@Override

View File

@ -27,9 +27,7 @@ public class ChainedMethodExpression extends AbstractObjectExpression {
@Override
public Object evaluate(final Map<String, Object> inputObjects, final Map<String, Object> queryParameter) {
final Object inputObject = inputObjects.get(objectKey);
Object object = inputObject;
Object object = inputObjects.get(objectKey);
for (MethodExpression methodExpression : methodExpressions) {
methodExpression.setObject(object);
object = methodExpression.evaluate(inputObjects, queryParameter);

View File

@ -23,7 +23,7 @@ public class ComparisonExpression extends AbstractBooleanExpression {
@Override
public boolean evaluate(Map<String, Object> inputObjects, Map<String, Object> queryParameter) {
boolean result = switch (operator) {
return switch (operator) {
case "=" -> evaluateEquals(inputObjects, queryParameter);
case "<>" -> !evaluateEquals(inputObjects, queryParameter);
case ">" -> evaluateMore(inputObjects, queryParameter);
@ -33,8 +33,6 @@ public class ComparisonExpression extends AbstractBooleanExpression {
default -> throw new SOQLEvaluationException(
"Comparison with operator " + operator + " is not supported yet.");
};
return result;
}
/**

View File

@ -180,8 +180,7 @@ public class RuntimeMock {
public <T extends ServiceArgument, U extends ServiceResult> U doService(Certificate certificate,
Service<T, U> service, T argument) {
U result = getServiceHandler().doService(certificate, service, argument);
return result;
return getServiceHandler().doService(certificate, service, argument);
}
public <T extends ServiceArgument, U extends ServiceResult> U doServiceAssertResult(Certificate certificate,

View File

@ -506,7 +506,6 @@ public class Version implements Comparable<Version> {
* @return This only the major and minor version in a string
*/
public String toMajorAndMinorString() {
String result = this.major + SEPARATOR + this.minor;
return result;
return this.major + SEPARATOR + this.minor;
}
}

View File

@ -218,11 +218,10 @@ public class DateRange {
@Override
public String toString() {
String sb = (this.fromDate == null ? "-" : ISO8601.toString(this.fromDate)) + (this.fromInclusive ?
return (this.fromDate == null ? "-" : ISO8601.toString(this.fromDate)) + (this.fromInclusive ?
" (inc)" :
" (exc)") + " - " + (this.toDate == null ? "-" : ISO8601.toString(this.toDate)) + (this.toInclusive ?
" (inc)" :
" (exc)");
return sb;
}
}

View File

@ -53,8 +53,7 @@ public class AesCryptoHelper {
outputStream.write(initVector);
outputStream.flush();
CipherOutputStream cipherOutputStream = new CipherOutputStream(outputStream, cipher);
return cipherOutputStream;
return new CipherOutputStream(outputStream, cipher);
} catch (Exception e) {
throw new RuntimeException(e);
@ -87,8 +86,7 @@ public class AesCryptoHelper {
Cipher cipher = Cipher.getInstance(CIPHER);
cipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(initVector));
CipherInputStream cipherInputStream = new CipherInputStream(inputStream, cipher);
return cipherInputStream;
return new CipherInputStream(inputStream, cipher);
} catch (Exception e) {
throw new RuntimeException(e);
@ -322,8 +320,7 @@ public class AesCryptoHelper {
Cipher cipher = Cipher.getInstance(CIPHER);
cipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(initVector));
byte[] decryptedBytes = cipher.doFinal(encryptedBytes, 16, encryptedBytes.length - 16);
return decryptedBytes;
return cipher.doFinal(encryptedBytes, 16, encryptedBytes.length - 16);
} catch (Exception e) {
throw new RuntimeException(e);
@ -335,9 +332,8 @@ public class AesCryptoHelper {
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
KeySpec keySpec = new PBEKeySpec(password, salt, 65536, 256);
SecretKey secretKey = factory.generateSecret(keySpec);
SecretKey secret = new SecretKeySpec(secretKey.getEncoded(), "AES");
return secret;
return new SecretKeySpec(secretKey.getEncoded(), "AES");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -137,9 +137,7 @@ public class ClassHelper {
public static <T> Class<T> loadClass(String className) throws IllegalArgumentException {
try {
Class<T> clazz = (Class<T>) Class.forName(className);
return clazz;
return (Class<T>) Class.forName(className);
} catch (Exception e) {
String msg = MessageFormat.format("The class {0} could not be instantiated: ", className);

View File

@ -28,8 +28,7 @@ public class DomUtil {
public static DocumentBuilder createDocumentBuilder() {
try {
DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
return docBuilder;
return dbfac.newDocumentBuilder();
} catch (ParserConfigurationException e) {
String msg = "No Xml Parser could be loaded: {0}";
msg = MessageFormat.format(msg, e.getMessage());

View File

@ -160,8 +160,7 @@ public class StringHelper {
public static byte fromHexStringByte(String encoded) {
if (encoded.length() != 2)
throw new IllegalArgumentException("Input string must be exactly two characters long.");
byte result = (byte) Integer.parseInt(encoded, 16);
return result;
return (byte) Integer.parseInt(encoded, 16);
}
/**
@ -657,15 +656,13 @@ public class StringHelper {
int start = Math.max(0, (i - maxContext));
int end = Math.min(i + maxContext, (Math.min(bytes1.length, bytes2.length)));
String sb = "Strings are not equal! Start of inequality is at " + i
return "Strings are not equal! Start of inequality is at " + i
+ ". Showing " + maxContext
+ " extra characters and start and end:\n"
+ "context s1: "
+ s1.substring(start, end) + "\n"
+ "context s2: "
+ s2.substring(start, end) + "\n";
return sb;
}
/**

View File

@ -58,10 +58,8 @@ public class SystemHelper {
* @see java.lang.Object#toString()
*/
public static String asString() {
String sb =
"OS: " + osName + " " + osVersion + " Arch: " + osArch + " on Java " + javaVendor + " " + javaVersion
+ " CPU Cores: " + nrOfCores;
return sb;
return "OS: " + osName + " " + osVersion + " Arch: " + osArch + " on Java " + javaVendor + " " + javaVersion
+ " CPU Cores: " + nrOfCores;
}
public static String getUserDir() {
@ -105,12 +103,11 @@ public class SystemHelper {
}
public static String getMemorySummary() {
String sb = "System Memory available "
return "System Memory available "
+ SystemHelper.getMaxMemory() + ", Total: "
+ SystemHelper.getTotalMemory() + ", Used: "
+ SystemHelper.getUsedMemory() + ", Free: "
+ SystemHelper.getFreeMemory();
return sb;
}
public static void main(String[] args) {

View File

@ -53,9 +53,7 @@ public class TexHelper {
data = StringHelper.replacePropertiesIn(properties, data);
data = StringHelper.replacePropertiesIn(getI18nData(bundle), "%", data);
File renderedPdf = renderPdf(fileName, templatePath, data);
return renderedPdf;
return renderPdf(fileName, templatePath, data);
}
private File renderPdf(String fileName, File templatePath, String data) {

View File

@ -121,7 +121,6 @@ public class XmlSignHelperTest {
SimpleDateFormat simpleDf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
simpleDf.setTimeZone(TimeZone.getTimeZone("UTC"));
String issueInstantS = simpleDf.format(issueInstant.getTime());
String notBeforeS = issueInstantS;
issueInstant.add(Calendar.SECOND, 10);
String notOnOrAfterS = simpleDf.format(issueInstant.getTime());
@ -148,7 +147,7 @@ public class XmlSignHelperTest {
authnReqE.appendChild(issuerE);
Element conditionsE = doc.createElement("Conditions");
conditionsE.setAttribute("NotBefore", notBeforeS);
conditionsE.setAttribute("NotBefore", issueInstantS);
conditionsE.setAttribute("NotOnOrAfter", notOnOrAfterS);
authnReqE.appendChild(conditionsE);
@ -166,7 +165,6 @@ public class XmlSignHelperTest {
SimpleDateFormat simpleDf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
simpleDf.setTimeZone(TimeZone.getTimeZone("UTC"));
String issueInstantS = simpleDf.format(issueInstant.getTime());
String notBeforeS = issueInstantS;
issueInstant.add(Calendar.SECOND, 10);
String notOnOrAfterS = simpleDf.format(issueInstant.getTime());
@ -196,7 +194,7 @@ public class XmlSignHelperTest {
Element conditionsE = doc.createElementNS("urn:oasis:names:tc:SAML:2.0:assertion", "Conditions");
conditionsE.setPrefix("saml");
conditionsE.setAttribute("NotBefore", notBeforeS);
conditionsE.setAttribute("NotBefore", issueInstantS);
conditionsE.setAttribute("NotOnOrAfter", notOnOrAfterS);
authnReqE.appendChild(conditionsE);

View File

@ -82,9 +82,7 @@ public class PersistenceContext<T> {
@Override
public String toString() {
String builder =
"PersistenceContext [objectRef=" + this.objectRef + ", object=" + this.object + ", parserFactory="
+ this.parserFactory + "]";
return builder;
return "PersistenceContext [objectRef=" + this.objectRef + ", object=" + this.object + ", parserFactory="
+ this.parserFactory + "]";
}
}

View File

@ -30,8 +30,7 @@ public class DomUtil {
public static DocumentBuilder createDocumentBuilder() {
try {
DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
return docBuilder;
return dbfac.newDocumentBuilder();
} catch (ParserConfigurationException e) {
String msg = "No Xml Parser could be loaded: {0}";
msg = MessageFormat.format(msg, e.getMessage());

View File

@ -71,7 +71,6 @@ public class BookDomParser implements DomParser<Book> {
String priceS = rootElement.getAttribute("price");
double price = Double.parseDouble(priceS);
Book book = new Book(id, title, author, press, price);
this.book = book;
this.book = new Book(id, title, author, press, price);
}
}

View File

@ -63,13 +63,11 @@ public class ModelBuilder {
}
public static Book createBook() {
Book book = new Book(BOOK_ID, BOOK_TITLE, BOOK_AUTHOR, BOOK_PRESS_1, BOOK_PRICE);
return book;
return new Book(BOOK_ID, BOOK_TITLE, BOOK_AUTHOR, BOOK_PRESS_1, BOOK_PRICE);
}
public static Book createBook(long id, String title, String author, String press, double price) {
Book book = new Book(id, title, author, press, price);
return book;
return new Book(id, title, author, press, price);
}
public static void updateBook(Book book) {

View File

@ -45,10 +45,8 @@ public class MyParameter {
@Override
public String toString() {
String builder =
"Parameter [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", value=" + this.value
+ "]";
return builder;
return "Parameter [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", value=" + this.value
+ "]";
}
/**