[Minor] Automated Code cleanups

This commit is contained in:
Robert von Burg 2023-04-04 10:06:47 +02:00
parent 776bab72d9
commit 16fb692b2e
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
98 changed files with 331 additions and 760 deletions

View File

@ -300,7 +300,7 @@ public class ComponentContainerImpl implements ComponentContainer {
LogMessageState.Information, ResourceBundle.getBundle("strolch-agent"), "agent.started") //
.value("applicationName", applicationName) //
.value("environment", environment) //
.value("components", "" + this.controllerMap.size()) //
.value("components", String.valueOf(this.controllerMap.size())) //
.value("took", tookS));
}
}
@ -325,7 +325,7 @@ public class ComponentContainerImpl implements ComponentContainer {
LogMessageState.Information, ResourceBundle.getBundle("strolch-agent"), "agent.stopping") //
.value("applicationName", applicationName) //
.value("environment", environment) //
.value("components", "" + this.controllerMap.size()));
.value("components", String.valueOf(this.controllerMap.size())));
}
}

View File

@ -139,13 +139,9 @@ public class ComponentController {
return false;
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ComponentController [component=");
builder.append(this.component.getName());
builder.append("]");
return builder.toString();
String builder = "ComponentController [component=" + this.component.getName() + "]";
return builder;
}
}

View File

@ -211,7 +211,6 @@ public class TransactionResult {
return this.created + this.read + this.updated + this.deleted;
}
@SuppressWarnings("nls")
public String getLogMessage() {
StringBuilder sb = new StringBuilder();

View File

@ -93,7 +93,7 @@ public class StrolchPolicyFileParser extends DefaultHandler {
}
}
public class PolicyType {
public static class PolicyType {
private final String type;
private final String api;
private final Map<String, String> policyByKeyMap;

View File

@ -188,7 +188,7 @@ public class SearchBuilder {
else
predicate = containsIgnoreCase(value);
if (bagId.isEmpty() || !bagId.equals("?")) {
if (!bagId.equals("?")) {
se = add(and, negate, se, param(bagId, paramId, predicate));
} else {
se = add(and, negate, se, element -> {

View File

@ -99,9 +99,7 @@ public abstract class Command implements Restrictable {
PolicyDefs policyDefs = policyContainer.getPolicyDefs();
PolicyDef policyDef = policyDefs.getPolicyDef(policyClass.getSimpleName());
PolicyHandler policyHandler = getComponent(PolicyHandler.class);
@SuppressWarnings("unchecked")
T policy = (T) policyHandler.getPolicy(policyDef, tx());
return policy;
return policyHandler.getPolicy(policyDef, tx());
}
/**

View File

@ -21,5 +21,5 @@ package li.strolch.service.api;
*/
public enum ServiceResultState {
SUCCESS, WARNING, FAILED, EXCEPTION, ACCESS_DENIED;
SUCCESS, WARNING, FAILED, EXCEPTION, ACCESS_DENIED
}

View File

@ -74,7 +74,7 @@ public class ParallelTests {
}
}
public class ParallelTask extends ForkJoinTask<Void> {
public static class ParallelTask extends ForkJoinTask<Void> {
@Override
public Void getRawResult() {

View File

@ -341,7 +341,7 @@ public class StrolchSearchTest {
}
}
public class NewBallSearch extends ResourceSearch {
public static class NewBallSearch extends ResourceSearch {
@Override
protected void define() {
@ -364,7 +364,7 @@ public class StrolchSearchTest {
}
}
public class BallSearch extends ResourceSearch {
public static class BallSearch extends ResourceSearch {
private final String id;
private final String status;

View File

@ -153,13 +153,9 @@ public abstract class AbstractStrolchElement implements StrolchElement {
}
AbstractStrolchElement other = (AbstractStrolchElement) obj;
if (this.id == null) {
if (other.id != null) {
return false;
}
} else if (!this.id.equals(other.id)) {
return false;
}
return true;
return other.id == null;
} else
return this.id.equals(other.id);
}
@Override

View File

@ -69,8 +69,8 @@ public abstract class AbstractStrolchRootElement extends GroupedParameterizedEle
// validate we have same objects
List<String> objectTypes = elements.stream().map(StrolchRootElement::getObjectType).distinct()
.collect(Collectors.toList());
List<String> types = elements.stream().map(StrolchRootElement::getType).distinct().collect(Collectors.toList());
.toList();
List<String> types = elements.stream().map(StrolchRootElement::getType).distinct().toList();
if (objectTypes.size() != 1)
throw new IllegalStateException(
"Only allow to have one type of object: " + elements.stream().map(StrolchElement::getId)

View File

@ -121,8 +121,7 @@ public class Locator {
* the additional element
*/
private Locator(List<String> path, String element) {
List<String> fullPath = new ArrayList<>();
fullPath.addAll(path);
List<String> fullPath = new ArrayList<>(path);
fullPath.add(element);
this.pathElements = Collections.unmodifiableList(fullPath);
}
@ -204,8 +203,8 @@ public class Locator {
}
/**
* Parses the given path to a {@link List} of path elements by splitting the string with the {@link
* #PATH_SEPARATOR}
* Parses the given path to a {@link List} of path elements by splitting the string with the
* {@link #PATH_SEPARATOR}
*
* @param path
* the path to parse
@ -253,6 +252,7 @@ public class Locator {
* Returns true if the given locator's path elements is the beginning of this locator's path elements
*
* @param locator
* the locator to check
*
* @return true if the given locator's path elements is the beginning of this locator's path elements
*/
@ -267,6 +267,7 @@ public class Locator {
* they are the same, i.e. must be an actual child
*
* @param locator
* the locator to check
*
* @return true if the given locator's path elements is the beginning of this locator's path elements, but not if
* they are the same, i.e. must be an actual child
@ -281,7 +282,7 @@ public class Locator {
public int hashCode() {
if (this.hashcode == null) {
final int prime = 31;
this.hashcode = prime * 1 + ((this.pathElements == null) ? 0 : this.pathElements.hashCode());
this.hashcode = prime + ((this.pathElements == null) ? 0 : this.pathElements.hashCode());
}
return this.hashcode;
@ -300,13 +301,9 @@ public class Locator {
}
Locator other = (Locator) obj;
if (this.pathElements == null) {
if (other.pathElements != null) {
return false;
}
} else if (!this.pathElements.equals(other.pathElements)) {
return false;
}
return true;
return other.pathElements == null;
} else
return this.pathElements.equals(other.pathElements);
}
/**
@ -358,8 +355,8 @@ public class Locator {
}
/**
* {@link LocatorBuilder} is used to build {@link Locator}s where a deep hierarchy is to be created. The {@link
* #append(String)} method returns itself for chain building
* {@link LocatorBuilder} is used to build {@link Locator}s where a deep hierarchy is to be created. The
* {@link #append(String)} method returns itself for chain building
*
* @author Robert von Burg <eitch@eitchnet.ch>
*/
@ -383,9 +380,7 @@ public class Locator {
* @return this instance for chaining
*/
public LocatorBuilder append(String... path) {
for (String element : path) {
this.pathElements.add(element);
}
this.pathElements.addAll(Arrays.asList(path));
return this;
}

View File

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

View File

@ -1234,20 +1234,11 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
return this.parent.getRootElement();
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
String builder = "ParameterizedElement [id=" + this.id + ", name=" + this.name + ", type=" + this.type + "]";
builder.append("ParameterizedElement [id=");
builder.append(this.id);
builder.append(", name=");
builder.append(this.name);
builder.append(", type=");
builder.append(this.type);
builder.append("]");
return builder.toString();
return builder;
}
}

View File

@ -380,22 +380,13 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
return visitor.visitResource(this);
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
String builder =
"Resource [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", version=" + this.version;
builder.append("Resource [id=");
builder.append(this.id);
builder.append(", name=");
builder.append(this.name);
builder.append(", type=");
builder.append(this.type);
builder.append(", version=");
builder.append(this.version);
return builder.toString();
return builder;
}
@Override

View File

@ -242,23 +242,12 @@ public class Version {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Version [version=");
builder.append(this.version);
builder.append(", locator=");
builder.append(this.locator);
builder.append(", createdBy=");
builder.append(this.createdBy);
builder.append(", updatedBy=");
builder.append(this.updatedBy);
builder.append(", created=");
builder.append(ISO8601FormatFactory.getInstance().formatDate(this.created));
builder.append(", updated=");
builder.append(ISO8601FormatFactory.getInstance().formatDate(this.updated));
builder.append(", deleted=");
builder.append(this.deleted);
builder.append("]");
return builder.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;
}
/**
@ -369,8 +358,6 @@ public class Version {
return false;
} else if (!this.locator.equals(other.locator))
return false;
if (this.version != other.version)
return false;
return true;
return this.version == other.version;
}
}

View File

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

View File

@ -26,5 +26,5 @@ public enum AccessType {
READ,
CREATE,
UPDATE,
DELETE;
DELETE
}

View File

@ -151,13 +151,9 @@ public class Audit implements Comparable<Audit> {
}
Audit other = (Audit) obj;
if (this.id == null) {
if (other.id != null) {
return false;
}
} else if (!this.id.equals(other.id)) {
return false;
}
return true;
return other.id == null;
} else
return this.id.equals(other.id);
}
@Override

View File

@ -480,7 +480,7 @@ public class StrolchElementToJsonVisitor implements StrolchElementVisitor<JsonEl
if (!this.withoutObjectType)
rootJ.addProperty(OBJECT_TYPE, ACTIVITY);
toJson((AbstractStrolchElement) element, rootJ);
toJson(element, rootJ);
rootJ.addProperty(TIME_ORDERING, element.getTimeOrdering().getName());
rootJ.addProperty(STATE, element.getState().getName());
rootJ.addProperty(START, formatDate(element.getStart()));

View File

@ -5,5 +5,5 @@ public enum LogSeverity {
Notification,
Warning,
Error,
Exception;
Exception
}

View File

@ -5,6 +5,7 @@ import static java.util.stream.Collectors.joining;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Stream;
@ -209,6 +210,6 @@ public abstract class AbstractListParameter<E> extends AbstractParameter<List<E>
@Override
public boolean containsAll(List<E> values) {
return this.value.containsAll(values);
return new HashSet<>(this.value).containsAll(values);
}
}

View File

@ -209,22 +209,10 @@ public abstract class AbstractParameter<T> extends AbstractStrolchElement implem
clone.index = this.index;
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(getClass().getSimpleName());
builder.append(" [id=");
builder.append(this.id);
builder.append(", name=");
builder.append(this.name);
builder.append(", value=");
builder.append(getValueAsString());
builder.append("]");
return builder.toString();
return getClass().getSimpleName() + " [id=" + this.id + ", name=" + this.name + ", value=" + getValueAsString()
+ "]";
}
/**

View File

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

View File

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

View File

@ -217,21 +217,12 @@ public abstract class AbstractStrolchTimedState<T extends IValue> extends Abstra
this.state.getTimeEvolution().clear();
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
String builder = getClass().getSimpleName() + " [id=" + this.id + ", name=" + this.name + ", valueNow="
+ this.state.getStateAt(System.currentTimeMillis()) + "]";
builder.append(getClass().getSimpleName());
builder.append(" [id=");
builder.append(this.id);
builder.append(", name=");
builder.append(this.name);
builder.append(", valueNow=");
builder.append(this.state.getStateAt(System.currentTimeMillis()));
builder.append("]");
return builder.toString();
return builder;
}
}

View File

@ -80,24 +80,14 @@ public class AString implements Serializable {
return false;
}
if (this.string == null) {
if (other.string != null) {
return false;
}
} else if (!this.string.equals(other.string)) {
return false;
}
return true;
return other.string == null;
} else
return this.string.equals(other.string);
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("AString [string=");
sb.append(this.string);
sb.append(", inverse=");
sb.append(this.inverse);
sb.append("]");
return sb.toString();
String sb = "AString [string=" + this.string + ", inverse=" + this.inverse + "]";
return sb;
}
}

View File

@ -72,14 +72,10 @@ public class BooleanValue implements IValue<Boolean>, Serializable {
return this.value.toString();
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("BooleanValue [value=");
sb.append(this.value);
sb.append("]");
return sb.toString();
String sb = "BooleanValue [value=" + this.value + "]";
return sb;
}
@Override

View File

@ -98,14 +98,10 @@ public class FloatListValue implements IValue<List<Double>>, Serializable {
return sb.toString();
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("FloatListValue [value=");
sb.append(this.value);
sb.append("]");
return sb.toString();
String sb = "FloatListValue [value=" + this.value + "]";
return sb;
}
@Override

View File

@ -71,14 +71,10 @@ public class FloatValue implements IValue<Double>, Serializable {
return MathHelper.toPrecisionString(this.value, 8);
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("DoubleValue [value=");
sb.append(this.value);
sb.append("]");
return sb.toString();
String sb = "DoubleValue [value=" + this.value + "]";
return sb;
}
@Override

View File

@ -98,14 +98,10 @@ public class IntegerListValue implements IValue<List<Integer>>, Serializable {
return sb.toString();
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("IntegerListValue [value=");
sb.append(this.value);
sb.append("]");
return sb.toString();
String sb = "IntegerListValue [value=" + this.value + "]";
return sb;
}
@Override

View File

@ -72,14 +72,10 @@ public class IntegerValue implements IValue<Integer>, Serializable {
return this.value.toString();
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("IntegerValue [value=");
sb.append(this.value);
sb.append("]");
return sb.toString();
String sb = "IntegerValue [value=" + this.value + "]";
return sb;
}
@Override

View File

@ -72,14 +72,10 @@ public class LongValue implements IValue<Long>, Serializable {
return this.value.toString();
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("LongValue [value=");
sb.append(this.value);
sb.append("]");
return sb.toString();
String sb = "LongValue [value=" + this.value + "]";
return sb;
}
@Override

View File

@ -129,14 +129,10 @@ public class StringSetValue implements IValue<Set<AString>>, Serializable {
return sb.toString();
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("StringSetValue [aStrings=");
sb.append(getValueAsString());
sb.append("]");
return sb.toString();
String sb = "StringSetValue [aStrings=" + getValueAsString() + "]";
return sb;
}
@Override

View File

@ -76,16 +76,10 @@ public class TimeValue<T extends IValue> implements ITimeValue<T>, Serializable
return new TimeValue<>(this.time, (T) this.value.getCopy());
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("TimeValue [time=");
sb.append(this.time);
sb.append(", value=");
sb.append(this.value);
sb.append("]");
return sb.toString();
String sb = "TimeValue [time=" + this.time + ", value=" + this.value + "]";
return sb;
}
@Override

View File

@ -101,18 +101,10 @@ public class ValueChange<T extends IValue> implements IValueChange<T>, Serializa
return Objects.hash(time, value);
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("ValueChange [time=");
sb.append(this.time);
sb.append(", value=");
sb.append(this.value);
sb.append(", stateId=");
sb.append(this.stateId);
sb.append("]");
return sb.toString();
String sb = "ValueChange [time=" + this.time + ", value=" + this.value + ", stateId=" + this.stateId + "]";
return sb;
}
@Override

View File

@ -74,7 +74,7 @@ public class StrolchElementDeepEqualsVisitor implements StrolchElementVisitor<Li
* destination order
*/
public void deepEquals(Order srcOrder, Order dstOrder) {
deepEquals((StrolchRootElement) srcOrder, (StrolchRootElement) dstOrder);
deepEquals(srcOrder, (StrolchRootElement) dstOrder);
if (!srcOrder.getState().equals(dstOrder.getState()))
addLocator(dstOrder.getLocator().append(Tags.STATE));
@ -91,7 +91,7 @@ public class StrolchElementDeepEqualsVisitor implements StrolchElementVisitor<Li
* destination resource
*/
public void deepEquals(Resource srcRes, Resource dstRes) {
deepEquals((StrolchRootElement) srcRes, (StrolchRootElement) dstRes);
deepEquals(srcRes, (StrolchRootElement) dstRes);
Set<String> srcTimedStateKeySet = srcRes.getTimedStateKeySet();
for (String timedStateKey : srcTimedStateKeySet) {
@ -124,7 +124,7 @@ public class StrolchElementDeepEqualsVisitor implements StrolchElementVisitor<Li
* destination activity
*/
public void deepEquals(Activity srcActivity, Activity dstActivity) {
deepEquals((StrolchRootElement) srcActivity, (StrolchRootElement) dstActivity);
deepEquals(srcActivity, (StrolchRootElement) dstActivity);
if (!srcActivity.getTimeOrdering().equals(dstActivity.getTimeOrdering()))
addLocator(dstActivity.getLocator().append(Tags.TIME_ORDERING));
@ -162,7 +162,7 @@ public class StrolchElementDeepEqualsVisitor implements StrolchElementVisitor<Li
}
private void deepEquals(StrolchRootElement srcElement, StrolchRootElement dstElement) {
deepEquals((StrolchElement) srcElement, (StrolchElement) dstElement);
deepEquals(srcElement, (StrolchElement) dstElement);
deepEquals((GroupedParameterizedElement) srcElement, (GroupedParameterizedElement) dstElement);
if (srcElement.hasVersion() && dstElement.hasVersion())
@ -226,8 +226,8 @@ public class StrolchElementDeepEqualsVisitor implements StrolchElementVisitor<Li
}
private void deepEquals(Action srcAction, Action dstAction) {
deepEquals((StrolchElement) srcAction, (StrolchElement) dstAction);
deepEquals((GroupedParameterizedElement) srcAction, (GroupedParameterizedElement) dstAction);
deepEquals(srcAction, (StrolchElement) dstAction);
deepEquals(srcAction, (GroupedParameterizedElement) dstAction);
if (!srcAction.getResourceId().equals(dstAction.getResourceId()))
addLocator(dstAction.getLocator().append(Tags.RESOURCE_ID));
@ -279,7 +279,7 @@ public class StrolchElementDeepEqualsVisitor implements StrolchElementVisitor<Li
}
private void deepEquals(ParameterBag srcBag, ParameterBag dstBag) {
deepEquals((StrolchElement) srcBag, (StrolchElement) dstBag);
deepEquals(srcBag, (StrolchElement) dstBag);
Set<String> srcParamKeySet = srcBag.getParameterKeySet();
for (String paramKey : srcParamKeySet) {
@ -303,7 +303,7 @@ public class StrolchElementDeepEqualsVisitor implements StrolchElementVisitor<Li
}
private void deepEquals(Parameter<?> srcParam, Parameter<?> dstParam) {
deepEquals((StrolchElement) srcParam, (StrolchElement) dstParam);
deepEquals(srcParam, (StrolchElement) dstParam);
if (!srcParam.getUom().equals(dstParam.getUom()))
addLocator(dstParam.getLocator().append(Tags.UOM));
if (!srcParam.getInterpretation().equals(dstParam.getInterpretation()))
@ -318,7 +318,7 @@ public class StrolchElementDeepEqualsVisitor implements StrolchElementVisitor<Li
}
private void deepEquals(StrolchTimedState<?> srcState, StrolchTimedState<?> dstState) {
deepEquals((StrolchElement) srcState, (StrolchElement) dstState);
deepEquals(srcState, (StrolchElement) dstState);
final ITimeVariable<?> srcTimeEvolution = srcState.getTimeEvolution();
final ITimeVariable<?> dstTimeEvolution = dstState.getTimeEvolution();

View File

@ -66,10 +66,10 @@ public class PostgreSqlHelper {
StringBuilder sb = new StringBuilder();
if (mm.isCaseSensitve() && mm.isEquals()) {
if (query.length == 1) {
sb.append(column + " = ?\n");
sb.append(column).append(" = ?\n");
values.add(query[0]);
} else {
sb.append(column + " in ( ");
sb.append(column).append(" in ( ");
for (int i = 0; i < query.length; i++) {
sb.append("?");
values.add(query[i]);
@ -80,10 +80,10 @@ public class PostgreSqlHelper {
}
} else if (!mm.isCaseSensitve() && mm.isEquals()) {
if (query.length == 1) {
sb.append("lower(" + column + ") = ?\n");
sb.append("lower(").append(column).append(") = ?\n");
values.add(query[0].toLowerCase());
} else {
sb.append("lower(" + column + ") in ( ");
sb.append("lower(").append(column).append(") in ( ");
for (int i = 0; i < query.length; i++) {
sb.append("?");
values.add(query[i].toLowerCase());
@ -94,14 +94,14 @@ public class PostgreSqlHelper {
}
} else if (!mm.isEquals() && mm.isCaseSensitve()) {
if (query.length == 1) {
sb.append(column + " like ?\n");
sb.append(column).append(" like ?\n");
values.add("%" + query[0] + "%");
} else {
sb.append("(\n");
for (int i = 0; i < query.length; i++) {
sb.append(indent);
sb.append(" ");
sb.append(column + " like ?");
sb.append(column).append(" like ?");
values.add("%" + query[i] + "%");
if (i < query.length - 1)
sb.append(" or");
@ -111,14 +111,14 @@ public class PostgreSqlHelper {
}
} else {
if (query.length == 1) {
sb.append("lower(" + column + ") like ?\n");
sb.append("lower(").append(column).append(") like ?\n");
values.add("%" + query[0].toLowerCase() + "%");
} else {
sb.append("(\n");
for (int i = 0; i < query.length; i++) {
sb.append(indent);
sb.append(" ");
sb.append("lower(" + column + ") like ?");
sb.append("lower(").append(column).append(") like ?");
values.add("%" + query[i].toLowerCase() + "%");
if (i < query.length - 1)
sb.append(" or");

View File

@ -80,7 +80,7 @@ public class ObserverUpdateTest {
runtimeMock.destroyRuntime();
}
public final class ElementAddedObserver implements Observer {
public static final class ElementAddedObserver implements Observer {
Map<String, ModificationResult> results = new HashMap<>();

View File

@ -198,7 +198,7 @@ public class XmlPersistenceHandler extends StrolchComponent implements Persisten
super.start();
}
class PersistenceStore {
static class PersistenceStore {
PersistenceManager persistenceManager;
File dbStorePathF;
}

View File

@ -16,13 +16,9 @@ public class MailUserChallengeHandler extends UserChallengeHandler {
String subject = "Mail TAN";
StringBuilder sb = new StringBuilder();
sb.append("Hello ").append(user.getFirstname()).append(" ").append(user.getLastname()).append("\n\n");
sb.append("You have requested an action which requires you to respond to a challenge.\n\n");
sb.append("Please use the following code to response to the challenge:\n\n");
sb.append(challenge);
String text = sb.toString();
String text = "Hello " + user.getFirstname() + " " + user.getLastname() + "\n\n"
+ "You have requested an action which requires you to respond to a challenge.\n\n"
+ "Please use the following code to response to the challenge:\n\n" + challenge;
String recipient = user.getEmail();
if (StringHelper.isEmpty(recipient)) {
String msg = "User {0} has no property {1}, so can not initiate challenge!";

View File

@ -43,7 +43,6 @@ public class PasswordCreator {
* @throws Exception
* thrown if anything goes wrong
*/
@SuppressWarnings("nls")
public static void main(String[] args) throws Exception {
while (true) {
@ -110,8 +109,8 @@ public class PasswordCreator {
Map<String, String> parameterMap = new HashMap<>();
parameterMap.put(XmlConstants.XML_PARAM_HASH_ALGORITHM, hashAlgorithm);
parameterMap.put(XmlConstants.XML_PARAM_HASH_ITERATIONS, "" + iterations);
parameterMap.put(XmlConstants.XML_PARAM_HASH_KEY_LENGTH, "" + keyLength);
parameterMap.put(XmlConstants.XML_PARAM_HASH_ITERATIONS, String.valueOf(iterations));
parameterMap.put(XmlConstants.XML_PARAM_HASH_KEY_LENGTH, String.valueOf(keyLength));
DefaultEncryptionHandler encryptionHandler = new DefaultEncryptionHandler();
encryptionHandler.initialize(parameterMap);

View File

@ -321,10 +321,8 @@ public final class Certificate implements Serializable {
} else if (!this.sessionId.equals(other.sessionId))
return false;
if (this.username == null) {
if (other.username != null)
return false;
} else if (!this.username.equals(other.username))
return false;
return true;
return other.username == null;
} else
return this.username.equals(other.username);
}
}

View File

@ -167,22 +167,15 @@ public class PrivilegeRep implements Serializable {
*
* @see java.lang.Object#toString()
*/
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("PrivilegeRep [name=");
builder.append(this.name);
builder.append(", policy=");
builder.append(this.policy);
builder.append(", allAllowed=");
builder.append(this.allAllowed);
builder.append(", denyList=");
builder.append((this.denyList == null ? "null" : this.denyList.size()));
builder.append(", allowList=");
builder.append((this.allowList == null ? "null" : this.allowList.size()));
builder.append("]");
return builder.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;
}
@Override
@ -203,11 +196,9 @@ public class PrivilegeRep implements Serializable {
return false;
PrivilegeRep other = (PrivilegeRep) obj;
if (this.name == null) {
if (other.name != null)
return false;
} else if (!this.name.equals(other.name))
return false;
return true;
return other.name == null;
} else
return this.name.equals(other.name);
}
public <T> T accept(PrivilegeElementVisitor<T> visitor) {

View File

@ -110,16 +110,12 @@ public class RoleRep implements Serializable {
*
* @see java.lang.Object#toString()
*/
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("RoleRep [name=");
builder.append(this.name);
builder.append(", privilegeMap=");
builder.append((this.privileges == null ? "null" : this.privileges));
builder.append("]");
return builder.toString();
String builder =
"RoleRep [name=" + this.name + ", privilegeMap=" + (this.privileges == null ? "null" : this.privileges)
+ "]";
return builder;
}
@Override
@ -140,11 +136,9 @@ public class RoleRep implements Serializable {
return false;
RoleRep other = (RoleRep) obj;
if (this.name == null) {
if (other.name != null)
return false;
} else if (!this.name.equals(other.name))
return false;
return true;
return other.name == null;
} else
return this.name.equals(other.name);
}
public <T> T accept(PrivilegeElementVisitor<T> visitor) {

View File

@ -351,26 +351,13 @@ public class UserRep implements Serializable {
*
* @see java.lang.Object#toString()
*/
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("UserRep [userId=");
builder.append(this.userId);
builder.append(", username=");
builder.append(this.username);
builder.append(", firstname=");
builder.append(this.firstname);
builder.append(", lastname=");
builder.append(this.lastname);
builder.append(", userState=");
builder.append(this.userState);
builder.append(", locale=");
builder.append(this.locale);
builder.append(", roles=");
builder.append(this.roles);
builder.append("]");
return builder.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;
}
@Override
@ -391,11 +378,9 @@ public class UserRep implements Serializable {
return false;
UserRep other = (UserRep) obj;
if (this.username == null) {
if (other.username != null)
return false;
} else if (!this.username.equals(other.username))
return false;
return true;
return other.username == null;
} else
return this.username.equals(other.username);
}
@Override

View File

@ -203,33 +203,18 @@ public class PrivilegeContainerModel {
return this.policies;
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("PrivilegeContainerModel [encryptionHandlerClassName=");
builder.append(this.encryptionHandlerClassName);
builder.append(", encryptionHandlerParameterMap=");
builder.append(this.encryptionHandlerParameterMap.size());
builder.append(", passwordStrengthHandlerClassName=");
builder.append(this.passwordStrengthHandlerClassName);
builder.append(", passwordStrengthHandlerParameterMap=");
builder.append(this.passwordStrengthHandlerParameterMap);
builder.append(", persistenceHandlerClassName=");
builder.append(this.persistenceHandlerClassName);
builder.append(", persistenceHandlerParameterMap=");
builder.append(this.persistenceHandlerParameterMap.size());
builder.append(", challengeHandlerParameterMap=");
builder.append(this.challengeHandlerParameterMap.size());
builder.append(", ssoHandlerParameterMap=");
builder.append(this.ssoHandlerParameterMap.size());
builder.append(", privilegeHandlerParameterMap=");
builder.append(this.privilegeHandlerParameterMap.size());
builder.append(", parameterMap=");
builder.append(this.parameterMap.size());
builder.append(", policies=");
builder.append(this.policies.size());
builder.append("]");
return builder.toString();
String builder = "PrivilegeContainerModel [encryptionHandlerClassName=" + this.encryptionHandlerClassName
+ ", encryptionHandlerParameterMap=" + this.encryptionHandlerParameterMap.size()
+ ", passwordStrengthHandlerClassName=" + this.passwordStrengthHandlerClassName
+ ", passwordStrengthHandlerParameterMap=" + this.passwordStrengthHandlerParameterMap
+ ", persistenceHandlerClassName=" + this.persistenceHandlerClassName
+ ", persistenceHandlerParameterMap=" + this.persistenceHandlerParameterMap.size()
+ ", challengeHandlerParameterMap=" + this.challengeHandlerParameterMap.size()
+ ", ssoHandlerParameterMap=" + this.ssoHandlerParameterMap.size() + ", privilegeHandlerParameterMap="
+ this.privilegeHandlerParameterMap.size() + ", parameterMap=" + this.parameterMap.size()
+ ", policies=" + this.policies.size() + "]";
return builder;
}
}

View File

@ -193,16 +193,10 @@ public final class PrivilegeImpl implements IPrivilege {
*
* @see java.lang.Object#toString()
*/
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Privilege [name=");
builder.append(this.name);
builder.append(", policy=");
builder.append(this.policy);
builder.append("]");
return builder.toString();
String builder = "Privilege [name=" + this.name + ", policy=" + this.policy + "]";
return builder;
}
@Override
@ -223,10 +217,8 @@ public final class PrivilegeImpl implements IPrivilege {
return false;
PrivilegeImpl other = (PrivilegeImpl) obj;
if (this.name == null) {
if (other.name != null)
return false;
} else if (!this.name.equals(other.name))
return false;
return true;
return other.name == null;
} else
return this.name.equals(other.name);
}
}

View File

@ -143,16 +143,10 @@ public final class Role {
*
* @see java.lang.Object#toString()
*/
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Role [name=");
builder.append(this.name);
builder.append(", privileges=");
builder.append(this.privilegeMap.keySet());
builder.append("]");
return builder.toString();
String builder = "Role [name=" + this.name + ", privileges=" + this.privilegeMap.keySet() + "]";
return builder;
}
@Override
@ -173,10 +167,8 @@ public final class Role {
return false;
Role other = (Role) obj;
if (this.name == null) {
if (other.name != null)
return false;
} else if (!this.name.equals(other.name))
return false;
return true;
return other.name == null;
} else
return this.name.equals(other.name);
}
}

View File

@ -355,26 +355,12 @@ public final class User {
*
* @see java.lang.Object#toString()
*/
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("User [userId=");
builder.append(this.userId);
builder.append(", username=");
builder.append(this.username);
builder.append(", firstname=");
builder.append(this.firstname);
builder.append(", lastname=");
builder.append(this.lastname);
builder.append(", locale=");
builder.append(this.locale);
builder.append(", userState=");
builder.append(this.userState);
builder.append(", roles=");
builder.append(this.roles);
builder.append("]");
return builder.toString();
String builder = "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
@ -395,10 +381,8 @@ public final class User {
return false;
User other = (User) obj;
if (this.userId == null) {
if (other.userId != null)
return false;
} else if (!this.userId.equals(other.userId))
return false;
return true;
return other.userId == null;
} else
return this.userId.equals(other.userId);
}
}

View File

@ -101,7 +101,7 @@ public class PrivilegeConfigDomWriter {
// Policies
Element policiesElem = doc.createElement(XML_POLICIES);
rootElement.appendChild(policiesElem);
this.containerModel.getPolicies().entrySet().stream().sorted(Comparator.comparing(Map.Entry::getKey))
this.containerModel.getPolicies().entrySet().stream().sorted(Entry.comparingByKey())
.forEach(entry -> {
Element policyElem = doc.createElement(XML_POLICY);
policyElem.setAttribute(XML_ATTR_NAME, entry.getKey());

View File

@ -239,7 +239,7 @@ public class Migrations {
DBC.PRE.assertTrue("migrations/data must be a directory!", dataDir.isDirectory());
// only list directories where name is a realmName
File[] realmMigrations = dataDir.listFiles((FileFilter) path -> realmNames.contains(path.getName()));
File[] realmMigrations = dataDir.listFiles(path -> realmNames.contains(path.getName()));
for (File realmMigration : realmMigrations) {
String realm = realmMigration.getName();
@ -248,7 +248,7 @@ public class Migrations {
migrationsByRealm.put(realm, migrations);
File[] migrationFiles = realmMigration
.listFiles((FileFilter) pathname -> pathname.getName().endsWith(".xml"));
.listFiles(pathname -> pathname.getName().endsWith(".xml"));
for (File file : migrationFiles) {
String name = file.getName();
Version version = Version.valueOf(name.substring(0, name.length() - 4));
@ -269,7 +269,7 @@ public class Migrations {
if (codeDir.exists()) {
DBC.PRE.assertTrue("migrations/code must be a directory!", codeDir.isDirectory());
File[] realmMigrations = codeDir.listFiles((FileFilter) path -> realmNames.contains(path.getName()));
File[] realmMigrations = codeDir.listFiles(path -> realmNames.contains(path.getName()));
for (File realmMigration : realmMigrations) {
String realm = realmMigration.getName();
@ -278,7 +278,7 @@ public class Migrations {
migrationsByRealm.put(realm, migrations);
File[] migrationFiles = realmMigration
.listFiles((FileFilter) pathname -> pathname.getName().endsWith(".xml"));
.listFiles(pathname -> pathname.getName().endsWith(".xml"));
for (File file : migrationFiles) {
String name = file.getName();
Version version = Version.valueOf(name.substring(0, name.length() - 4));

View File

@ -807,8 +807,7 @@ public class GenericReport extends ReportPolicy {
if (this.filtersById != null && !this.filtersById.isEmpty() && this.filtersById.containsSet(
element.getType())) {
if (!this.filtersById.getSet(element.getType()).contains(element.getId()))
return false;
return this.filtersById.getSet(element.getType()).contains(element.getId());
}
// otherwise we want to keep this row
@ -1132,7 +1131,7 @@ public class GenericReport extends ReportPolicy {
List<Parameter<?>> relationParams = relationsBag.getParametersByInterpretationAndUom(interpretation, joinType)
.stream()
.filter(p -> p.getValueType() == StrolchValueType.STRING)
.collect(toList());
.toList();
if (relationParams.isEmpty())
throw new IllegalStateException("Found no relation parameters with UOM " + joinType + " of type "

View File

@ -93,7 +93,7 @@ public class ServiceExecutionHandler extends StrolchComponent {
}
}
public class ServiceContext<T extends ServiceArgument, U extends ServiceResult> {
public static class ServiceContext<T extends ServiceArgument, U extends ServiceResult> {
private final Certificate certificate;
private final Service<T, U> service;

View File

@ -123,7 +123,7 @@ public abstract class AbstractRealmCommandTest {
doCommand(REALM_CACHED);
}
private class FailCommandFacade extends Command {
private static class FailCommandFacade extends Command {
private final Command command;

View File

@ -48,7 +48,7 @@ public class RemoveActivityCollectionCommandTest extends AbstractRealmCommandTes
List<Activity> activities = new ArrayList<>(this.locators.size());
for (Locator locator : this.locators) {
activities.add((Activity) tx.findElement(locator));
activities.add(tx.findElement(locator));
}
RemoveActivityCollectionCommand command = new RemoveActivityCollectionCommand(tx);

View File

@ -48,7 +48,7 @@ public class RemoveOrderCollectionCommandTest extends AbstractRealmCommandTest {
List<Order> orders = new ArrayList<>(this.locators.size());
for (Locator locator : this.locators) {
orders.add((Order) tx.findElement(locator));
orders.add(tx.findElement(locator));
}
RemoveOrderCollectionCommand command = new RemoveOrderCollectionCommand(tx);

View File

@ -48,7 +48,7 @@ public class RemoveResourceCollectionCommandTest extends AbstractRealmCommandTes
List<Resource> resources = new ArrayList<>(this.locators.size());
for (Locator locator : this.locators) {
resources.add((Resource) tx.findElement(locator));
resources.add(tx.findElement(locator));
}
RemoveResourceCollectionCommand command = new RemoveResourceCollectionCommand(tx);

View File

@ -158,7 +158,7 @@ public class GenericReportTest {
List<JsonObject> result = report.filter("Product", "product01") //
.dateRange(dateRange) //
.doReportAsJson() //
.collect(toList());
.toList();
assertTrue(result.isEmpty());
}
@ -172,7 +172,7 @@ public class GenericReportTest {
List<JsonObject> result = report.filter("Product", "product01") //
.dateRange(dateRange) //
.doReportAsJson() //
.collect(toList());
.toList();
assertEquals(2, result.size());
}
}
@ -191,7 +191,7 @@ public class GenericReportTest {
DateRange dateRange = new DateRange().from(from, true).to(to, false);
List<JsonObject> result = report.filter("Product", "product01").dateRange(dateRange).doReportAsJson()
.collect(toList());
.toList();
assertTrue(result.isEmpty());
}
@ -202,7 +202,7 @@ public class GenericReportTest {
DateRange dateRange = new DateRange().from(from, true).to(to, false);
List<JsonObject> result = report.filter("Product", "product01").dateRange(dateRange).doReportAsJson()
.collect(toList());
.toList();
assertEquals(2, result.size());
}
@ -213,7 +213,7 @@ public class GenericReportTest {
DateRange dateRange = new DateRange().from(from, true).to(to, false);
List<JsonObject> result = report.filter("Product", "product01", "product02").dateRange(dateRange)
.doReportAsJson().collect(toList());
.doReportAsJson().toList();
assertEquals(4, result.size());
}
}

View File

@ -162,7 +162,7 @@ public class SimpleModelTest {
// get products
List<Resource> products = articles.stream().map(a -> tx.getResourceByRelation(a, "product", true))
.distinct().collect(Collectors.toList());
.distinct().toList();
assertEquals(1, products.size());
// search for all orders in state PLANNED and with customer

View File

@ -151,8 +151,6 @@ public class SOQLListener extends SOQLBaseListener {
((SelectExpression) pointer).addExpression(chainedMethodExpression);
} else if (pointer instanceof ComparisonExpression) {
((ComparisonExpression) pointer).addOperand(chainedMethodExpression);
} else if (pointer instanceof SelectExpression) {
((SelectExpression) pointer).addExpression(chainedMethodExpression);
}
pointer = chainedMethodExpression;
}

View File

@ -308,7 +308,7 @@ public class AuditModelTestRunner {
}
}
private final class AuditByIdComparator implements Comparator<Audit> {
private static final class AuditByIdComparator implements Comparator<Audit> {
@Override
public int compare(Audit o1, Audit o2) {
return o1.getId().compareTo(o2.getId());

View File

@ -92,7 +92,7 @@ public class LogMessagesTestRunner {
LogMessage m = new LogMessage(this.realmName, SYSTEM_USER_AGENT,
Locator.valueOf(AGENT, "li.strolch.testbase", StrolchAgent.getUniqueId()),
LogSeverity.Exception, LogMessageState.Information, bundle, "test-message").value("reason",
"" + i);
String.valueOf(i));
this.operationsLog.addMessage(m);
ids.add(m.getId());
}

View File

@ -55,7 +55,7 @@ public class DbConnectionCheck {
logger.info("Checking connection " + ds);
try (Connection con = ds.getConnection(); Statement st = con.createStatement();) {
try (Connection con = ds.getConnection(); Statement st = con.createStatement()) {
try (ResultSet rs = st.executeQuery("select version()")) { //$NON-NLS-1$
if (rs.next()) {

View File

@ -22,5 +22,5 @@ public enum DbMigrationState {
NOTHING,
CREATED,
MIGRATED,
DROPPED_CREATED;
DROPPED_CREATED
}

View File

@ -228,7 +228,7 @@ public class DbSchemaVersionCheck {
String dbVersionPropFile = MessageFormat.format(RESOURCE_DB_VERSION, app);
try (InputStream stream = ctxClass.getResourceAsStream(dbVersionPropFile);) {
try (InputStream stream = ctxClass.getResourceAsStream(dbVersionPropFile)) {
DBC.PRE.assertNotNull(
MessageFormat.format("Resource file with name {0} does not exist!", dbVersionPropFile), stream);
dbVersionProps.load(stream);

View File

@ -226,11 +226,9 @@ public class I18nMessage {
} else if (!this.key.equals(other.key))
return false;
if (this.values == null) {
if (other.values != null)
return false;
} else if (!this.values.equals(other.values))
return false;
return true;
return other.values == null;
} else
return this.values.equals(other.values);
}
@Override

View File

@ -155,16 +155,14 @@ public class ObjectHelper {
return false;
}
return true;
} else {
for (String s : rightArr) {
if (!leftString.contains(s))
return false;
}
return true;
}
return true;
}
if (right.getClass().isEnum())

View File

@ -75,7 +75,7 @@ public enum StringMatchMode {
return value1.toLowerCase().contains(value2.toLowerCase());
if (!isCaseSensitve())
return value1.toLowerCase().equals(value2.toLowerCase());
return value1.equalsIgnoreCase(value2);
if (!isEquals())
return value1.contains(value2);

View File

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

View File

@ -218,12 +218,11 @@ public class DateRange {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.fromDate == null ? "-" : ISO8601.toString(this.fromDate));
sb.append((this.fromInclusive ? " (inc)" : " (exc)"));
sb.append(" - ");
sb.append(this.toDate == null ? "-" : ISO8601.toString(this.toDate));
sb.append((this.toInclusive ? " (inc)" : " (exc)"));
return sb.toString();
String sb = (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

@ -177,7 +177,7 @@ public enum DBC {
}
}
public class DbcException extends RuntimeException {
public static class DbcException extends RuntimeException {
public DbcException(String message) {
super(message);

View File

@ -212,7 +212,6 @@ public class AsciiHelper {
*
* @return String
*/
@SuppressWarnings("nls")
public static String getAsciiText(char c) {
// else if(c == ) { return "";}
if (c == NUL) {

View File

@ -334,18 +334,11 @@ public class ByteHelper {
*/
public static String asBinary(byte b) {
StringBuilder sb = new StringBuilder();
String sb =
String.valueOf((b >>> 7) & 1) + ((b >>> 6) & 1) + ((b >>> 5) & 1) + ((b >>> 4) & 1) + ((b >>> 3) & 1)
+ ((b >>> 2) & 1) + ((b >>> 1) & 1) + ((b) & 1);
sb.append(((b >>> 7) & 1));
sb.append(((b >>> 6) & 1));
sb.append(((b >>> 5) & 1));
sb.append(((b >>> 4) & 1));
sb.append(((b >>> 3) & 1));
sb.append(((b >>> 2) & 1));
sb.append(((b >>> 1) & 1));
sb.append(((b) & 1));
return sb.toString();
return sb;
}
/**
@ -358,29 +351,13 @@ public class ByteHelper {
*/
public static String asBinary(short i) {
StringBuilder sb = new StringBuilder();
String sb =
String.valueOf((i >>> 15) & 1) + ((i >>> 14) & 1) + ((i >>> 13) & 1) + ((i >>> 12) & 1) + ((i >>> 11)
& 1) + ((i >>> 10) & 1) + ((i >>> 9) & 1) + ((i >>> 8) & 1) + StringHelper.SPACE + ((i >>> 7)
& 1) + ((i >>> 6) & 1) + ((i >>> 5) & 1) + ((i >>> 4) & 1) + ((i >>> 3) & 1) + ((i >>> 2) & 1)
+ ((i >>> 1) & 1) + ((i) & 1);
sb.append(((i >>> 15) & 1));
sb.append(((i >>> 14) & 1));
sb.append(((i >>> 13) & 1));
sb.append(((i >>> 12) & 1));
sb.append(((i >>> 11) & 1));
sb.append(((i >>> 10) & 1));
sb.append(((i >>> 9) & 1));
sb.append(((i >>> 8) & 1));
sb.append(StringHelper.SPACE);
sb.append(((i >>> 7) & 1));
sb.append(((i >>> 6) & 1));
sb.append(((i >>> 5) & 1));
sb.append(((i >>> 4) & 1));
sb.append(((i >>> 3) & 1));
sb.append(((i >>> 2) & 1));
sb.append(((i >>> 1) & 1));
sb.append(((i) & 1));
return sb.toString();
return sb;
}
/**
@ -393,51 +370,16 @@ public class ByteHelper {
*/
public static String asBinary(int i) {
StringBuilder sb = new StringBuilder();
String sb =
String.valueOf((i >>> 31) & 1) + ((i >>> 30) & 1) + ((i >>> 29) & 1) + ((i >>> 28) & 1) + ((i >>> 27)
& 1) + ((i >>> 26) & 1) + ((i >>> 25) & 1) + ((i >>> 24) & 1) + StringHelper.SPACE + ((i >>> 23)
& 1) + ((i >>> 22) & 1) + ((i >>> 21) & 1) + ((i >>> 20) & 1) + ((i >>> 19) & 1) + ((i >>> 18)
& 1) + ((i >>> 17) & 1) + ((i >>> 16) & 1) + StringHelper.SPACE + ((i >>> 15) & 1) + ((i >>> 14)
& 1) + ((i >>> 13) & 1) + ((i >>> 12) & 1) + ((i >>> 11) & 1) + ((i >>> 10) & 1) + ((i >>> 9)
& 1) + ((i >>> 8) & 1) + StringHelper.SPACE + ((i >>> 7) & 1) + ((i >>> 6) & 1) + ((i >>> 5)
& 1) + ((i >>> 4) & 1) + ((i >>> 3) & 1) + ((i >>> 2) & 1) + ((i >>> 1) & 1) + ((i) & 1);
sb.append(((i >>> 31) & 1));
sb.append(((i >>> 30) & 1));
sb.append(((i >>> 29) & 1));
sb.append(((i >>> 28) & 1));
sb.append(((i >>> 27) & 1));
sb.append(((i >>> 26) & 1));
sb.append(((i >>> 25) & 1));
sb.append(((i >>> 24) & 1));
sb.append(StringHelper.SPACE);
sb.append(((i >>> 23) & 1));
sb.append(((i >>> 22) & 1));
sb.append(((i >>> 21) & 1));
sb.append(((i >>> 20) & 1));
sb.append(((i >>> 19) & 1));
sb.append(((i >>> 18) & 1));
sb.append(((i >>> 17) & 1));
sb.append(((i >>> 16) & 1));
sb.append(StringHelper.SPACE);
sb.append(((i >>> 15) & 1));
sb.append(((i >>> 14) & 1));
sb.append(((i >>> 13) & 1));
sb.append(((i >>> 12) & 1));
sb.append(((i >>> 11) & 1));
sb.append(((i >>> 10) & 1));
sb.append(((i >>> 9) & 1));
sb.append(((i >>> 8) & 1));
sb.append(StringHelper.SPACE);
sb.append(((i >>> 7) & 1));
sb.append(((i >>> 6) & 1));
sb.append(((i >>> 5) & 1));
sb.append(((i >>> 4) & 1));
sb.append(((i >>> 3) & 1));
sb.append(((i >>> 2) & 1));
sb.append(((i >>> 1) & 1));
sb.append(((i) & 1));
return sb.toString();
return sb;
}
/**
@ -450,94 +392,23 @@ public class ByteHelper {
*/
public static String asBinary(long i) {
StringBuilder sb = new StringBuilder();
String sb =
String.valueOf((i >>> 63) & 1) + ((i >>> 62) & 1) + ((i >>> 61) & 1) + ((i >>> 60) & 1) + ((i >>> 59)
& 1) + ((i >>> 58) & 1) + ((i >>> 57) & 1) + ((i >>> 56) & 1) + StringHelper.SPACE + ((i >>> 55)
& 1) + ((i >>> 54) & 1) + ((i >>> 53) & 1) + ((i >>> 52) & 1) + ((i >>> 51) & 1) + ((i >>> 50)
& 1) + ((i >>> 49) & 1) + ((i >>> 48) & 1) + StringHelper.SPACE + ((i >>> 47) & 1) + ((i >>> 46)
& 1) + ((i >>> 45) & 1) + ((i >>> 44) & 1) + ((i >>> 43) & 1) + ((i >>> 42) & 1) + ((i >>> 41)
& 1) + ((i >>> 40) & 1) + StringHelper.SPACE + ((i >>> 39) & 1) + ((i >>> 38) & 1) + ((i >>> 37)
& 1) + ((i >>> 36) & 1) + ((i >>> 35) & 1) + ((i >>> 34) & 1) + ((i >>> 33) & 1) + ((i >>> 32)
& 1) + StringHelper.SPACE + ((i >>> 31) & 1) + ((i >>> 30) & 1) + ((i >>> 29) & 1) + ((i >>> 28)
& 1) + ((i >>> 27) & 1) + ((i >>> 26) & 1) + ((i >>> 25) & 1) + ((i >>> 24) & 1)
+ StringHelper.SPACE + ((i >>> 23) & 1) + ((i >>> 22) & 1) + ((i >>> 21) & 1) + ((i >>> 20) & 1)
+ ((i >>> 19) & 1) + ((i >>> 18) & 1) + ((i >>> 17) & 1) + ((i >>> 16) & 1) + StringHelper.SPACE
+ ((i >>> 15) & 1) + ((i >>> 14) & 1) + ((i >>> 13) & 1) + ((i >>> 12) & 1) + ((i >>> 11) & 1)
+ ((i >>> 10) & 1) + ((i >>> 9) & 1) + ((i >>> 8) & 1) + StringHelper.SPACE + ((i >>> 7) & 1)
+ ((i >>> 6) & 1) + ((i >>> 5) & 1) + ((i >>> 4) & 1) + ((i >>> 3) & 1) + ((i >>> 2) & 1) + (
(i >>> 1) & 1) + ((i) & 1);
sb.append(((i >>> 63) & 1));
sb.append(((i >>> 62) & 1));
sb.append(((i >>> 61) & 1));
sb.append(((i >>> 60) & 1));
sb.append(((i >>> 59) & 1));
sb.append(((i >>> 58) & 1));
sb.append(((i >>> 57) & 1));
sb.append(((i >>> 56) & 1));
sb.append(StringHelper.SPACE);
sb.append(((i >>> 55) & 1));
sb.append(((i >>> 54) & 1));
sb.append(((i >>> 53) & 1));
sb.append(((i >>> 52) & 1));
sb.append(((i >>> 51) & 1));
sb.append(((i >>> 50) & 1));
sb.append(((i >>> 49) & 1));
sb.append(((i >>> 48) & 1));
sb.append(StringHelper.SPACE);
sb.append(((i >>> 47) & 1));
sb.append(((i >>> 46) & 1));
sb.append(((i >>> 45) & 1));
sb.append(((i >>> 44) & 1));
sb.append(((i >>> 43) & 1));
sb.append(((i >>> 42) & 1));
sb.append(((i >>> 41) & 1));
sb.append(((i >>> 40) & 1));
sb.append(StringHelper.SPACE);
sb.append(((i >>> 39) & 1));
sb.append(((i >>> 38) & 1));
sb.append(((i >>> 37) & 1));
sb.append(((i >>> 36) & 1));
sb.append(((i >>> 35) & 1));
sb.append(((i >>> 34) & 1));
sb.append(((i >>> 33) & 1));
sb.append(((i >>> 32) & 1));
sb.append(StringHelper.SPACE);
sb.append(((i >>> 31) & 1));
sb.append(((i >>> 30) & 1));
sb.append(((i >>> 29) & 1));
sb.append(((i >>> 28) & 1));
sb.append(((i >>> 27) & 1));
sb.append(((i >>> 26) & 1));
sb.append(((i >>> 25) & 1));
sb.append(((i >>> 24) & 1));
sb.append(StringHelper.SPACE);
sb.append(((i >>> 23) & 1));
sb.append(((i >>> 22) & 1));
sb.append(((i >>> 21) & 1));
sb.append(((i >>> 20) & 1));
sb.append(((i >>> 19) & 1));
sb.append(((i >>> 18) & 1));
sb.append(((i >>> 17) & 1));
sb.append(((i >>> 16) & 1));
sb.append(StringHelper.SPACE);
sb.append(((i >>> 15) & 1));
sb.append(((i >>> 14) & 1));
sb.append(((i >>> 13) & 1));
sb.append(((i >>> 12) & 1));
sb.append(((i >>> 11) & 1));
sb.append(((i >>> 10) & 1));
sb.append(((i >>> 9) & 1));
sb.append(((i >>> 8) & 1));
sb.append(StringHelper.SPACE);
sb.append(((i >>> 7) & 1));
sb.append(((i >>> 6) & 1));
sb.append(((i >>> 5) & 1));
sb.append(((i >>> 4) & 1));
sb.append(((i >>> 3) & 1));
sb.append(((i >>> 2) & 1));
sb.append(((i >>> 1) & 1));
sb.append(((i) & 1));
return sb.toString();
return sb;
}
}

View File

@ -171,14 +171,14 @@ public class FileHelper {
*/
public static String readFileToString(File file) {
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file));) {
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
StringBuilder sb = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
sb.append(line + "\n"); //$NON-NLS-1$
sb.append(line).append("\n"); //$NON-NLS-1$
}
return sb.toString();
@ -201,14 +201,14 @@ public class FileHelper {
*/
public static String readStreamToString(InputStream stream) {
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream));) {
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream))) {
StringBuilder sb = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
sb.append(line + "\n"); //$NON-NLS-1$
sb.append(line).append("\n"); //$NON-NLS-1$
}
return sb.toString();
@ -247,7 +247,7 @@ public class FileHelper {
*/
public static void writeStringToFile(String string, File dstFile) {
try (BufferedWriter bufferedwriter = new BufferedWriter(new FileWriter(dstFile));) {
try (BufferedWriter bufferedwriter = new BufferedWriter(new FileWriter(dstFile))) {
bufferedwriter.write(string);
} catch (FileNotFoundException e) {
throw new RuntimeException("Filed does not exist " + dstFile.getAbsolutePath()); //$NON-NLS-1$

View File

@ -67,12 +67,12 @@ public class ProcessHelper {
long start = System.nanoTime();
logger.info(MessageFormat.format("Starting command (Timeout {0} {1}) {2}", timeout, unit.name(),
Arrays.stream(commandAndArgs).collect(Collectors.joining(" "))));
String.join(" ", commandAndArgs)));
final Process process = pb.start();
int[] returnValue = new int[1];
try (BufferedReader errorStream = new BufferedReader(new InputStreamReader(process.getErrorStream()));
BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream()));) {
BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
Thread errorIn = new Thread(() -> readStream(sb, "[ERROR] ", errorStream), "errorIn");
errorIn.start();
@ -93,8 +93,8 @@ public class ProcessHelper {
returnValue[0] = -1;
}
errorIn.join(100l);
infoIn.join(100l);
errorIn.join(100L);
infoIn.join(100L);
sb.append("=====================================\n"); //$NON-NLS-1$
}
@ -126,7 +126,7 @@ public class ProcessHelper {
String line;
try {
while ((line = bufferedReader.readLine()) != null) {
sb.append(prefix + line + StringHelper.NEW_LINE);
sb.append(prefix).append(line).append(StringHelper.NEW_LINE);
}
} catch (IOException e) {
String msg = "Faild to read from {0} stream: {1}"; //$NON-NLS-1$

View File

@ -466,16 +466,16 @@ public class StringHelper {
if (value.length() < length) {
String tmp = value;
StringBuilder tmp = new StringBuilder(value);
while (tmp.length() != length) {
if (beginning) {
tmp = c + tmp;
tmp.insert(0, c);
} else {
tmp = tmp + c;
tmp.append(c);
}
}
return tmp;
return tmp.toString();
} else if (shorten) {
@ -657,18 +657,15 @@ public class StringHelper {
int start = Math.max(0, (i - maxContext));
int end = Math.min(i + maxContext, (Math.min(bytes1.length, bytes2.length)));
StringBuilder sb = new StringBuilder();
sb.append("Strings are not equal! Start of inequality is at ").append(i); //$NON-NLS-1$
sb.append(". Showing ").append(maxContext); //$NON-NLS-1$
sb.append(" extra characters and start and end:\n"); //$NON-NLS-1$
sb.append("context s1: "); //$NON-NLS-1$
sb.append(s1, start, end);
sb.append("\n"); //$NON-NLS-1$
sb.append("context s2: "); //$NON-NLS-1$
sb.append(s2, start, end);
sb.append("\n"); //$NON-NLS-1$
String sb = "Strings are not equal! Start of inequality is at " + i //$NON-NLS-1$
+ ". Showing " + maxContext //$NON-NLS-1$
+ " extra characters and start and end:\n" //$NON-NLS-1$
+ "context s1: " //$NON-NLS-1$
+ s1.substring(start, end) + "\n" //$NON-NLS-1$
+ "context s2: " //$NON-NLS-1$
+ s2.substring(start, end) + "\n"; //$NON-NLS-1$
return sb.toString();
return sb;
}
/**

View File

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

View File

@ -70,7 +70,6 @@ public class ObjectCache {
*/
private Object object;
@SuppressWarnings("nls")
public ObjectCache(long id, String key, Object objectKey, Object object, Operation operation) {
this.id = id;
@ -80,16 +79,9 @@ public class ObjectCache {
this.operation = operation;
if (logger.isDebugEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Instanciated Cache: ID");
sb.append(this.id);
sb.append(" / ");
sb.append(key);
sb.append(" OP: ");
sb.append(this.operation);
sb.append(" / ");
sb.append(objectKey.toString());
logger.debug(sb.toString());
String sb = "Instanciated Cache: ID" + this.id + " / " + key + " OP: " + this.operation + " / "
+ objectKey.toString();
logger.debug(sb);
}
}

View File

@ -35,5 +35,5 @@ public enum Operation {
/**
* REMOVE The operation associated when an object was removed
*/
REMOVE;
REMOVE
}

View File

@ -405,7 +405,7 @@ public final class Interval
*/
public Interval intersection(Interval other) {
Objects.requireNonNull(other, "other");
if (isConnected(other) == false) {
if (!isConnected(other)) {
throw new DateTimeException("Intervals do not connect: " + this + " and " + other);
}
int cmpStart = start.compareTo(other.start);
@ -433,7 +433,7 @@ public final class Interval
*/
public Interval union(Interval other) {
Objects.requireNonNull(other, "other");
if (isConnected(other) == false) {
if (!isConnected(other)) {
throw new DateTimeException("Intervals do not connect: " + this + " and " + other);
}
int cmpStart = start.compareTo(other.start);

View File

@ -175,7 +175,7 @@ public final class PeriodDuration implements TemporalAmount, Serializable, Compa
return PeriodDuration.of((Duration) amount);
}
if (amount instanceof ChronoPeriod) {
if (IsoChronology.INSTANCE.equals(((ChronoPeriod) amount).getChronology()) == false) {
if (!IsoChronology.INSTANCE.equals(((ChronoPeriod) amount).getChronology())) {
throw new DateTimeException("Period requires ISO chronology: " + amount);
}
}

View File

@ -50,7 +50,6 @@ public class StringMatchModeTest {
/**
* Test method for {@link li.strolch.utils.StringMatchMode#matches(java.lang.String, java.lang.String)}.
*/
@SuppressWarnings("nls")
@Test
public void testMatches() {
assertTrue(StringMatchMode.CONTAINS_CASE_INSENSITIVE.matches("hello", "el"));

View File

@ -1,6 +1,5 @@
package li.strolch.utils.collections;
import static java.util.Arrays.asList;
import static java.util.Collections.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -129,11 +128,11 @@ public class MapOfTest {
Set<String> set;
set = mapOfSets.getSet("a");
assertNotNull(set);
assertEquals(new HashSet<>(asList("1", "2")), set);
assertEquals(new HashSet<>(List.of("1", "2")), set);
set = mapOfSets.getSet("b");
assertNotNull(set);
assertEquals(new HashSet<>(asList("3", "4")), set);
assertEquals(new HashSet<>(List.of("3", "4")), set);
mapOfSets.computeIfAbsent("c", s -> {
Set<String> items = new HashSet<>();
@ -143,11 +142,11 @@ public class MapOfTest {
set = mapOfSets.getSet("c");
assertNotNull(set);
assertEquals(new HashSet<>(asList("5")), set);
assertEquals(new HashSet<>(List.of("5")), set);
set = mapOfSets.getSetOrDefault("a", emptySet());
assertNotNull(set);
assertEquals(new HashSet<>(asList("1", "2")), set);
assertEquals(new HashSet<>(List.of("1", "2")), set);
set = mapOfSets.getSetOrDefault("d", emptySet());
assertNotNull(set);
@ -156,7 +155,7 @@ public class MapOfTest {
mapOfSets.forEach((key, items) -> {
if (key.equals("a")) {
assertNotNull(items);
assertEquals(new HashSet<>(asList("1", "2")), items);
assertEquals(new HashSet<>(List.of("1", "2")), items);
}
});
}

View File

@ -28,8 +28,7 @@ import org.junit.Test;
public class PagingTest {
private List<String> getInputList() {
List<String> list = Arrays.asList("a", "b", "c", "d", "e", "f", "g");
return list;
return Arrays.asList("a", "b", "c", "d", "e", "f", "g");
}
@Test
@ -45,7 +44,7 @@ public class PagingTest {
public void shouldReturnFirstPage1() {
List<String> list = getInputList();
List<String> page = Paging.asPage(list, 0, 1).getPage();
assertEquals(Arrays.asList("a"), page);
assertEquals(List.of("a"), page);
}
@Test
@ -59,7 +58,7 @@ public class PagingTest {
public void shouldReturnSecondPage1() {
List<String> list = getInputList();
List<String> page = Paging.asPage(list, 1, 1).getPage();
assertEquals(Arrays.asList("b"), page);
assertEquals(List.of("b"), page);
}
@Test
@ -73,7 +72,7 @@ public class PagingTest {
public void shouldReturnLastPage1() {
List<String> list = getInputList();
List<String> page = Paging.asPage(list, 5, 1).getPage();
assertEquals(Arrays.asList("f"), page);
assertEquals(List.of("f"), page);
}
@Test
@ -95,7 +94,7 @@ public class PagingTest {
paging = Paging.asPage(list, paging.getLastOffset(), 2);
page = paging.getPage();
assertEquals(Arrays.asList("g"), page);
assertEquals(List.of("g"), page);
assertEquals(6, paging.getNextOffset());
assertEquals(6, paging.getLastOffset());
}
@ -106,11 +105,11 @@ public class PagingTest {
Paging<String> paging = Paging.asPage(list, 0, 1);
List<String> page = paging.getPage();
assertEquals(Arrays.asList("a"), page);
assertEquals(List.of("a"), page);
paging = Paging.asPage(list, paging.getLastOffset(), 1);
page = paging.getPage();
assertEquals(Arrays.asList("g"), page);
assertEquals(List.of("g"), page);
assertEquals(6, paging.getNextOffset());
assertEquals(6, paging.getLastOffset());
}
@ -137,7 +136,7 @@ public class PagingTest {
paging = Paging.asPage(list, paging.getLastOffset(), paging.getLimit());
page = paging.getPage();
assertEquals(Arrays.asList("g"), page);
assertEquals(List.of("g"), page);
assertEquals(6, paging.getOffset());
assertEquals(3, paging.getPreviousOffset());
assertEquals(6, paging.getNextOffset());
@ -150,23 +149,23 @@ public class PagingTest {
Paging<String> paging = Paging.asPage(list, 1, 1);
List<String> page = paging.getPage();
assertEquals(Arrays.asList("b"), page);
assertEquals(List.of("b"), page);
paging = Paging.asPage(list, paging.getPreviousOffset(), paging.getLimit());
page = paging.getPage();
assertEquals(Arrays.asList("a"), page);
assertEquals(List.of("a"), page);
paging = Paging.asPage(list, paging.getNextOffset(), paging.getLimit());
page = paging.getPage();
assertEquals(Arrays.asList("b"), page);
assertEquals(List.of("b"), page);
paging = Paging.asPage(list, paging.getNextOffset(), paging.getLimit());
page = paging.getPage();
assertEquals(Arrays.asList("c"), page);
assertEquals(List.of("c"), page);
paging = Paging.asPage(list, paging.getLastOffset(), paging.getLimit());
page = paging.getPage();
assertEquals(Arrays.asList("g"), page);
assertEquals(List.of("g"), page);
}
@Test

View File

@ -20,5 +20,5 @@ public enum IoOperation {
CREATE,
READ,
UPDATE,
DELETE;
DELETE
}

View File

@ -209,7 +209,7 @@ public class ObjectDao {
assertIsIdRef(objectRef);
this.tx.lock(objectRef);
PersistenceContext<T> ctx = objectRef.<T>createPersistenceContext(this.tx);
PersistenceContext<T> ctx = objectRef.createPersistenceContext(this.tx);
return this.fileDao.exists(ctx);
}
@ -218,7 +218,7 @@ public class ObjectDao {
assertIsIdRef(objectRef);
this.tx.lock(objectRef);
PersistenceContext<T> ctx = objectRef.<T>createPersistenceContext(this.tx);
PersistenceContext<T> ctx = objectRef.createPersistenceContext(this.tx);
this.fileDao.performRead(ctx);
return ctx.getObject();
}
@ -281,7 +281,7 @@ public class ObjectDao {
public <T> PersistenceContext<T> createCtx(ObjectRef objectRef, long lastModified) {
String type = objectRef.getType();
PersistenceContextFactory<T> ctxFactory = this.ctxFactoryDelegator.<T>getCtxFactory(type);
PersistenceContextFactory<T> ctxFactory = this.ctxFactoryDelegator.getCtxFactory(type);
PersistenceContext<T> ctx = ctxFactory.createCtx(objectRef);
ctx.setLastModified(lastModified);
return ctx;

View File

@ -75,24 +75,16 @@ public class PersistenceContext<T> {
return false;
PersistenceContext<?> other = (PersistenceContext<?>) obj;
if (this.objectRef == null) {
if (other.objectRef != null)
return false;
} else if (!this.objectRef.equals(other.objectRef))
return false;
return true;
return other.objectRef == null;
} else
return this.objectRef.equals(other.objectRef);
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("PersistenceContext [objectRef=");
builder.append(this.objectRef);
builder.append(", object=");
builder.append(this.object);
builder.append(", parserFactory=");
builder.append(this.parserFactory);
builder.append("]");
return builder.toString();
String builder =
"PersistenceContext [objectRef=" + this.objectRef + ", object=" + this.object + ", parserFactory="
+ this.parserFactory + "]";
return builder;
}
}

View File

@ -19,5 +19,5 @@ public enum TransactionState {
OPEN, //
COMMITTED, //
ROLLED_BACK, //
FAILED;
FAILED
}

View File

@ -92,10 +92,8 @@ public class TypeRef extends ObjectRef {
} else if (!this.name.equals(other.name))
return false;
if (this.type == null) {
if (other.type != null)
return false;
} else if (!this.type.equals(other.type))
return false;
return true;
return other.type == null;
} else
return this.type.equals(other.type);
}
}

View File

@ -39,7 +39,6 @@ public abstract class AbstractPersistenceTest {
protected PersistenceManager persistenceManager;
@SuppressWarnings("nls")
protected static void cleanPath(String path) {
File file = new File(path).getAbsoluteFile();

View File

@ -141,7 +141,7 @@ public class ObjectDaoBookTest extends AbstractPersistenceTest {
String press = "Penguin Books"; //$NON-NLS-1$
double price = 21.30;
Book book = createBook((long) i, title, author, press, price);
Book book = createBook(i, title, author, press, price);
books.add(book);
}

View File

@ -40,7 +40,6 @@ public class BookDomParser implements DomParser<Book> {
this.book = object;
}
@SuppressWarnings("nls")
@Override
public Document toDom() {
@ -59,7 +58,6 @@ public class BookDomParser implements DomParser<Book> {
}
@SuppressWarnings("nls")
@Override
public void fromDom(Document document) {

View File

@ -47,7 +47,6 @@ public class BookSaxParser extends DefaultHandler implements SaxParser<Book> {
return this;
}
@SuppressWarnings("nls")
@Override
public void write(XMLStreamWriter writer) throws XMLStreamException {
@ -59,7 +58,6 @@ public class BookSaxParser extends DefaultHandler implements SaxParser<Book> {
writer.writeAttribute("price", Double.toString(this.book.getPrice()));
}
@SuppressWarnings("nls")
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) {

View File

@ -40,7 +40,6 @@ public class MyModelDomParser implements DomParser<MyModel> {
this.resource = resource;
}
@SuppressWarnings("nls")
@Override
public Document toDom() {
@ -68,7 +67,6 @@ public class MyModelDomParser implements DomParser<MyModel> {
return document;
}
@SuppressWarnings("nls")
@Override
public void fromDom(Document document) {

View File

@ -44,7 +44,6 @@ class MyModelSaxParser extends DefaultHandler implements SaxParser<MyModel> {
return this;
}
@SuppressWarnings("nls")
@Override
public void write(XMLStreamWriter writer) throws XMLStreamException {
@ -63,28 +62,26 @@ class MyModelSaxParser extends DefaultHandler implements SaxParser<MyModel> {
writer.writeEndElement();
}
@SuppressWarnings("nls")
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) {
switch (qName) {
case "Resource":
case "Resource" -> {
String id = attributes.getValue("id");
String name = attributes.getValue("name");
String type = attributes.getValue("type");
this.resource = new MyModel(id, name, type);
}
case "Parameter" -> {
String id = attributes.getValue("id");
String name = attributes.getValue("name");
String type = attributes.getValue("type");
MyModel resource = new MyModel(id, name, type);
this.resource = resource;
break;
case "Parameter":
id = attributes.getValue("id");
name = attributes.getValue("name");
type = attributes.getValue("type");
String value = attributes.getValue("value");
MyParameter param = new MyParameter(id, name, type, value);
this.resource.addParameter(param);
break;
default:
this.resource.addParameter(new MyParameter(id, name, type, value));
}
default -> {
throw new IllegalArgumentException("The element '" + qName + "' is unhandled!");
}
}
}
}

View File

@ -46,7 +46,6 @@ public class MyModel {
this.type = type;
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -59,7 +58,7 @@ public class MyModel {
builder.append(", parameters=");
for (Entry<String, MyParameter> param : this.parameters.entrySet()) {
builder.append("\n");
builder.append(" " + param.getKey() + " = " + param.getValue());
builder.append(" ").append(param.getKey()).append(" = ").append(param.getValue());
}
builder.append("]");
return builder.toString();

View File

@ -43,20 +43,12 @@ public class MyParameter {
this.value = value;
}
@SuppressWarnings("nls")
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Parameter [id=");
builder.append(this.id);
builder.append(", name=");
builder.append(this.name);
builder.append(", type=");
builder.append(this.type);
builder.append(", value=");
builder.append(this.value);
builder.append("]");
return builder.toString();
String builder =
"Parameter [id=" + this.id + ", name=" + this.name + ", type=" + this.type + ", value=" + this.value
+ "]";
return builder;
}
/**