Skip to content
Snippets Groups Projects
Commit 19dbb45d authored by dgelessus's avatar dgelessus
Browse files

Replace Apache Commons Lang with standard library solutions

parent a4b0b11a
No related branches found
No related tags found
No related merge requests found
Showing
with 34 additions and 53 deletions
......@@ -33,7 +33,7 @@ To build the Prolog binaries you require a SICStus 4 (http://sicstus.sics.se/ind
- We use gradle to manage the dependencies to the libraries, thus you will need gradle installed on your computer.
(see http://www.gradle.org/)
- In the workspace directory run the completeInstall task (```gradle completeInstall```), alternatively you can also run the downloadCli and collectDependencies tasks (```gradle downloadCli collectDependencies```). This will download the latest nightly build of the Prolog binary and the required Java libraries (such as apache commons, etc.)
- In the workspace directory run the completeInstall task (```gradle completeInstall```), alternatively you can also run the downloadCli and collectDependencies tasks (```gradle downloadCli collectDependencies```). This will download the latest nightly build of the Prolog binary and the required Java libraries (such as the parser libraries).
- Install Eclipse for RCP Development
......
......@@ -38,7 +38,6 @@ project(':de.prob.core') {
implementation group: "de.hhu.stups", name: "prologlib", version: parser_version
implementation group: "de.hhu.stups", name: "unicode", version: parser_version
implementation group: "de.hhu.stups", name: "theorymapping", version: parser_version
implementation 'commons-lang:commons-lang:2.6'
implementation 'com.thoughtworks.xstream:xstream:1.4.19'
// Current versions of XStream depend on MXParser, but not any specific version of it.
// To avoid the version number changing unexpectedly and breaking the MANIFEST.MF classpath entries,
......
......@@ -10,7 +10,6 @@
-->
<classpathentry exported="true" kind="lib" path="lib/dependencies/answerparser-2.12.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/dependencies/bparser-2.12.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/dependencies/commons-lang-2.6.jar"/>
<classpathentry exported="true" kind="lib" path="lib/dependencies/jna-3.4.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/dependencies/jsr305-1.3.9.jar"/>
<classpathentry exported="true" kind="lib" path="lib/dependencies/ltlparser-2.12.4.jar"/>
......
......@@ -97,15 +97,6 @@ Export-Package: com.thoughtworks.xstream,
javax.annotation,
javax.annotation.concurrent,
javax.annotation.meta,
org.apache.commons.lang,
org.apache.commons.lang.builder,
org.apache.commons.lang.enums,
org.apache.commons.lang.exception,
org.apache.commons.lang.math,
org.apache.commons.lang.mutable,
org.apache.commons.lang.reflect,
org.apache.commons.lang.text,
org.apache.commons.lang.time,
org.ptolemy.fmi,
org.ptolemy.fmi.driver,
org.ptolemy.fmi.type
......@@ -123,7 +114,6 @@ Bundle-ClassPath: .,
lib/dependencies/answerparser-2.12.4.jar,
lib/dependencies/ptolemy-jfmi-1.1.0.jar,
lib/dependencies/xstream-1.4.19.jar,
lib/dependencies/commons-lang-2.6.jar,
lib/dependencies/jsr305-1.3.9.jar,
lib/dependencies/mxparser-1.2.2.jar,
lib/dependencies/xmlpull-1.1.3.1.jar,
......
......@@ -8,8 +8,6 @@ package de.prob.core;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import de.prob.cli.CliException;
import de.prob.core.command.CommandException;
import de.prob.core.internal.ResultParserException;
......@@ -69,7 +67,7 @@ public class ProblemHandler {
public static void raisePrologException(final List<String> errors,
final boolean onlyWarnings) throws PrologException {
final String message = "ProB reported errors:\n"
+ StringUtils.join(errors, '\n');
+ String.join("\n", errors);
Logger.notifyUser(message);
throw new PrologException(message, onlyWarnings);
}
......
......@@ -5,8 +5,6 @@ package de.prob.core.command;
import java.util.List;
import org.apache.commons.lang.ArrayUtils;
import de.prob.parser.ISimplifiedROMap;
import de.prob.prolog.output.IPrologTermOutput;
import de.prob.prolog.output.PrologTermDelegate;
......@@ -77,14 +75,14 @@ public class ComposedCommand implements IComposableCommand {
public void reprocessResult(final IComposableCommand command,
final ISimplifiedROMap<String, PrologTerm> bindings)
throws CommandException {
final int index = ArrayUtils.indexOf(cmds, command);
if (index >= 0) {
final PrefixMap<PrologTerm> prefixMap = new PrefixMap<PrologTerm>(
bindings);
processPrefixedCommand(prefixMap, index);
} else
throw new IllegalArgumentException(
"cannot reprocess command, command unknown");
for (int i = 0; i < cmds.length; i++) {
if (command.equals(cmds[i])) {
final PrefixMap<PrologTerm> prefixMap = new PrefixMap<PrologTerm>(bindings);
processPrefixedCommand(prefixMap, i);
return;
}
}
throw new IllegalArgumentException("cannot reprocess command, command unknown");
}
/**
......
......@@ -12,8 +12,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import de.prob.prolog.term.CompoundPrologTerm;
import de.prob.prolog.term.IntegerPrologTerm;
import de.prob.prolog.term.ListPrologTerm;
......@@ -289,7 +287,7 @@ public final class Operation {
if (argsPretty.isEmpty()) {
return name;
} else {
return name + "(" + StringUtils.join(argsPretty, ',') + ")";
return name + "(" + String.join(",", argsPretty) + ")";
}
}
......
......@@ -6,7 +6,7 @@
package de.prob.core.domainobjects;
import org.apache.commons.lang.ObjectUtils;
import java.util.Objects;
import de.prob.core.command.CommandException;
import de.prob.parser.BindingGenerator;
......@@ -94,7 +94,7 @@ public final class Variable {
} else if (obj != null && obj instanceof Variable) {
Variable other = (Variable) obj;
equal = this.identifier.equals(other.identifier)
&& ObjectUtils.equals(this.value, other.value);
&& Objects.equals(this.value, other.value);
} else {
equal = false;
}
......
......@@ -6,9 +6,9 @@ package de.prob.core.langdep;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import org.apache.commons.lang.ObjectUtils;
import org.eclipse.core.runtime.CoreException;
import org.eventb.core.IContextRoot;
import org.eventb.core.IEventBRoot;
......@@ -187,7 +187,7 @@ public class EventBAnimatorPart implements LanguageDependendAnimationPart {
final ISCMachineRoot machine = ((IMachineRoot) root).getSCMachineRoot();
try {
for (final ISCEvent event : machine.getSCEvents()) {
if (ObjectUtils.equals(event.getLabel(), eventName))
if (Objects.equals(event.getLabel(), eventName))
return event;
}
throw new ProBParseException("unknown event " + eventName);
......
......@@ -13,7 +13,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eventb.core.IContextRoot;
......@@ -218,7 +217,7 @@ public final class ContextTranslator extends AbstractComponentTranslator {
if (!bugs.isEmpty()) {
String message = "Translation incomplete due to a Bug in Rodin. This does not affect correctness of the Animation/Model Checking but can decrease its performance. Skipped discharged information about: "
+ StringUtils.join(bugs, ",");
+ String.join(",", bugs);
Logger.notifyUser(message);
}
......
......@@ -12,7 +12,6 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.runtime.CoreException;
import org.eventb.core.IConvergenceElement.Convergence;
import org.eventb.core.ILabeledElement;
......@@ -237,7 +236,7 @@ public class ModelTranslator extends AbstractComponentTranslator {
if (!bugs.isEmpty()) {
String message = "Translation incomplete due to a Bug in Rodin. This does not affect correctness of the Animation/Model Checking but can decrease its performance. Skipped discharged information about: "
+ StringUtils.join(bugs, ",");
+ String.join(",", bugs);
Logger.notifyUser(message);
}
......
......@@ -4,10 +4,12 @@
package de.prob.ui.historyview;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.ObjectUtils;
import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.DoubleClickEvent;
......@@ -168,15 +170,17 @@ public class HistoryView extends StateBasedViewPart {
final Animator animator = Animator.getAnimator();
MachineDescription machineDescription = animator
.getMachineDescription();
String[] models = new String[0];
List<String> models;
if (machineDescription != null) {
models = machineDescription.getModelNames().toArray(new String[0]);
ArrayUtils.reverse(models);
models = new ArrayList<>(machineDescription.getModelNames());
Collections.reverse(models);
} else {
models = Collections.emptyList();
}
final TableColumnLayout layout = new TableColumnLayout();
composite.setLayout(layout);
labelProviders = new ArrayList<HistoryLabelProvider>();
if (models.length > 0) {
if (!models.isEmpty()) {
int pos = 0;
for (final String model : models) {
final boolean isFirst = pos == 0;
......@@ -227,7 +231,7 @@ public class HistoryView extends StateBasedViewPart {
vItems[i] = new HistViewItem(i, activeItem, state, op, cs);
}
current = vItems[activeItem];
ArrayUtils.reverse(vItems);
Collections.reverse(Arrays.asList(vItems));
} else {
current = null;
}
......@@ -256,10 +260,8 @@ public class HistoryView extends StateBasedViewPart {
// The item representing the root state has no operation leading to
// it, so we have to check if it is null
this.previousStateIsSameAsCurrent = operation != null
&& ObjectUtils.equals(currentState.getId(),
operation.getSource());
this.followingStateIsSameAsCurrent = ObjectUtils.equals(
currentState, dstState);
&& Objects.equals(currentState.getId(), operation.getSource());
this.followingStateIsSameAsCurrent = Objects.equals(currentState, dstState);
}
public State getDestination() {
......
......@@ -6,8 +6,7 @@ package de.prob.ui.stateview.statetree;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.ObjectUtils;
import java.util.Objects;
import de.prob.core.command.EvaluationGetValuesCommand;
import de.prob.core.command.EvaluationGetValuesCommand.EvaluationResult;
......@@ -78,7 +77,7 @@ public class StateTreeExpression extends AbstractStateTreeElement {
e.notifyUserOnce();
return false;
}
return !ObjectUtils.equals(curval, lastval);
return !Objects.equals(curval, lastval);
}
private String getResultString(final State state) throws ProBException {
......
......@@ -3,7 +3,7 @@
*/
package de.prob.ui.stateview.statetree;
import org.apache.commons.lang.ObjectUtils;
import java.util.Objects;
import de.prob.core.domainobjects.State;
import de.prob.core.domainobjects.Variable;
......@@ -45,7 +45,7 @@ public class StateTreeVariable extends AbstractStateTreeElement {
public boolean hasChanged(final State current, final State last) {
final String curVal = getValueOfVar(current);
final String lastVal = getValueOfVar(last);
return !ObjectUtils.equals(curVal, lastVal);
return !Objects.equals(curVal, lastVal);
}
private String getValueOfVar(final State state) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment