Skip to content

Commit

Permalink
Remove unnecessary string conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
solth committed Jan 29, 2025
1 parent 8f9d1fc commit c6c57fd
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private void loadBeans() {
try (JarFile jarFile = new JarFile(f.toString())) {
if (hasFrontendFiles(jarFile)) {
Enumeration<JarEntry> entries = jarFile.entries();
URL[] urls = {new URL("jar:file:" + f.toString() + "!/") };
URL[] urls = {new URL("jar:file:" + f + "!/") };
try (URLClassLoader cl = URLClassLoader.newInstance(urls)) {
while (entries.hasMoreElements()) {
JarEntry je = entries.nextElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ DivType toDiv(Map<PhysicalDivision, String> physicalDivisionIDs, LinkedList<Pair
Optional<MdSecType> optionalDmdSec = createMdSec(super.getMetadata(), MdSec.DMD_SEC);
if (optionalDmdSec.isPresent()) {
MdSecType dmdSec = optionalDmdSec.get();
String name = metsReferrerId + ':' + MdSec.DMD_SEC.toString();
String name = metsReferrerId + ':' + MdSec.DMD_SEC;
dmdSec.setID(KitodoUUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8)));
mets.getDmdSec().add(dmdSec);
div.getDMDID().add(dmdSec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ default boolean getBooleanValue(Map<String, Object> jsonObject) throws DataExcep
try {
return (Boolean) jsonObject.get(this.toString());
} catch (ClassCastException | NullPointerException e) {
throw new DataException("Not possible to retrieve boolean value for key " + this.toString()
+ ". Exception: " + e.getMessage());
throw new DataException("Not possible to retrieve boolean value for key " + this + ". Exception: "
+ e.getMessage());
}
}

Expand All @@ -55,8 +55,8 @@ default int getIntValue(Map<String, Object> jsonObject) throws DataException {
try {
return (Integer) jsonObject.get(this.toString());
} catch (ClassCastException | NullPointerException e) {
throw new DataException("Not possible to retrieve int value for key " + this.toString()
+ ". Exception: " + e.getMessage());
throw new DataException("Not possible to retrieve int value for key " + this + ". Exception: "
+ e.getMessage());
}
}

Expand All @@ -71,8 +71,8 @@ default double getDoubleValue(Map<String, Object> jsonObject) throws DataExcepti
try {
return (double) jsonObject.get(this.toString());
} catch (ClassCastException | NullPointerException e) {
throw new DataException("Not possible to retrieve double value for key " + this.toString()
+ ". Exception: " + e.getMessage());
throw new DataException("Not possible to retrieve double value for key " + this + ". Exception: "
+ e.getMessage());
}
}

Expand All @@ -87,8 +87,8 @@ default String getStringValue(Map<String, Object> jsonObject) throws DataExcepti
try {
return (String) jsonObject.get(this.toString());
} catch (ClassCastException | NullPointerException e) {
throw new DataException("Not possible to retrieve String value for key " + this.toString()
+ ". Exception: " + e.getMessage());
throw new DataException("Not possible to retrieve String value for key " + this + ". Exception: "
+ e.getMessage());
}
}

Expand All @@ -104,8 +104,8 @@ default List<Map<String, Object>> getJsonArray(Map<String, Object> jsonObject) t
try {
return (List<Map<String, Object>>) jsonObject.get(this.toString());
} catch (ClassCastException | NullPointerException e) {
throw new DataException("Not possible to retrieve JsonArray value for key " + this.toString()
+ ". Exception: " + e.getMessage());
throw new DataException("Not possible to retrieve JsonArray value for key " + this + ". Exception: "
+ e.getMessage());
}
}

Expand All @@ -121,8 +121,8 @@ default int getSizeOfProperty(Map<String, Object> object) throws DataException {
try {
return ((List) object.get(this.toString())).size();
} catch (ClassCastException | NullPointerException e) {
throw new DataException("Not possible to retrieve size of array for key " + this.toString()
+ ". Exception: " + e.getMessage());
throw new DataException("Not possible to retrieve size of array for key " + this + ". Exception: "
+ e.getMessage());
}
}
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public List<Map<String, Object>> getSupportedLocales() {
translation.put("displayLanguageTranslated",
supportedLocale.getDisplayLanguage(currentDisplayLanguage));
translation.put("selected", supportedLocale.equals(currentDisplayLanguage));
translation.put("flag", "javax.faces.resource/images/" + supportedLocale.toString() + ".svg.jsf");
translation.put("flag", "javax.faces.resource/images/" + supportedLocale + ".svg.jsf");
supportedLocales.add(translation);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public void init(@Observes @Initialized(ApplicationScoped.class) ServletContext
logger.error("Unable to update custom list columns in database!");
} catch (NoSuchElementException e) {
logger.info("Configuration key '"
+ ParameterCore.PROCESS_PROPERTIES.toString()
+ "' or '" + ParameterCore.TASK_CUSTOM_COLUMNS.toString()
+ ParameterCore.PROCESS_PROPERTIES
+ "' or '" + ParameterCore.TASK_CUSTOM_COLUMNS
+ "' not found in configuration => unable to load corresponding custom columns!");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@ private String determineReplacementForProjectid(Matcher variableFinder) {
logger.warn("Cannot replace \"(projectid)\": process has no project assigned");
return variableFinder.group(1);
}
return variableFinder.group(1) + String.valueOf(process.getProject().getId());
return variableFinder.group(1) + process.getProject().getId();
}

private String determineReplacementForStepid(Matcher variableFinder) {
if (Objects.isNull(task)) {
logger.warn("Cannot replace \"(stepid)\": no task given");
return variableFinder.group(1);
}
return variableFinder.group(1) + String.valueOf(task.getId());
return variableFinder.group(1) + task.getId();
}

private String determineReplacementForStepname(Matcher variableFinder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,11 +633,11 @@ private void prohibitOverlaps(LocalDate from, LocalDate until) {
public String toString() {
StringBuilder result = new StringBuilder();
if (Objects.nonNull(firstAppearance)) {
result.append(firstAppearance.toString());
result.append(firstAppearance);
}
result.append(" - ");
if (Objects.nonNull(lastAppearance)) {
result.append(lastAppearance.toString());
result.append(lastAppearance);
}
result.append(" [");
boolean first = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,15 +532,15 @@ public String toString() {
result.append(daysOfWeek.contains(DayOfWeek.SUNDAY.getValue()) ? 'S' : '-');
result.append(") +");
if (additions.size() <= 5) {
result.append(additions.toString());
result.append(additions);
} else {
result.append("[…(");
result.append(additions.size());
result.append(")…]");
}
result.append(" -");
if (exclusions.size() <= 5) {
result.append(exclusions.toString());
result.append(exclusions);
} else {
result.append("[…(");
result.append(exclusions.size());
Expand Down

0 comments on commit c6c57fd

Please sign in to comment.