Skip to content

Commit 73de7b3

Browse files
committed
Check for unnecessary code
1 parent 8caa5a0 commit 73de7b3

File tree

12 files changed

+32
-272
lines changed

12 files changed

+32
-272
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
11
package org.cobolt.algorithms.helpers;
22

3-
public class LogicHelper {
3+
class LogicHelper {
44

55
/**
66
* Returns the logic implication of the given premise and conclusion variables
7-
*
7+
*
88
* @param premise
99
* @param conclusion
1010
* @return premise => conclusion
1111
*/
12-
public static boolean implies(boolean premise, boolean conclusion) {
12+
static boolean implies(final boolean premise, final boolean conclusion) {
1313
return !premise || conclusion;
1414
}
15-
16-
/**
17-
* Implementation of the biimplication operator
18-
*
19-
* The result is (<code>a</code> AND <code>b</code>) OR (!<code>a</code> AND
20-
* !<code>b</code>)
21-
*
22-
* @param a
23-
* the premise value
24-
* @param b
25-
* the conclusion value
26-
* @return whether implication holds
27-
*/
28-
public static boolean biimplies(boolean a, boolean b) {
29-
return a == b;
30-
}
3115
}

org.cobolt.model/src/org/cobolt/model/listener/LoggingGraphContentAdapter.java

-38
This file was deleted.

org.cobolt.model/src/org/cobolt/model/utils/TopologyUtils.java

-69
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
package org.cobolt.model.utils;
22

3-
import java.util.ArrayList;
4-
import java.util.Comparator;
5-
import java.util.HashMap;
6-
import java.util.HashSet;
7-
import java.util.List;
8-
import java.util.Map;
9-
import java.util.Set;
10-
113
import org.cobolt.model.Edge;
124
import org.cobolt.model.EdgeState;
135
import org.cobolt.model.Node;
@@ -87,67 +79,6 @@ public static Edge addUndirectedEdge(final Topology topology, final String idFwd
8779
return addUndirectedEdge(topology, idFwd, idBwd, node1, node2, distance, Double.NaN);
8880
}
8981

90-
/**
91-
* Creates a summary of the edge states of the given {@link Topology}.
92-
*
93-
* For instance, this method can be used during debugging as follows:
94-
*
95-
* de.tudarmstadt.maki.tc.cbctc.model.utils.TopologyUtils.formatEdgeStateReport(unclassifiedEdge.getTopology())
96-
*
97-
* de.tudarmstadt.maki.tc.cbctc.model.utils.TopologyUtils.formatEdgeStateReport(topology)
98-
*
99-
* @param topology
100-
* @return
101-
*/
102-
public static String formatEdgeStateReport(final Topology topology) {
103-
final StringBuilder builder = new StringBuilder();
104-
final Set<Edge> processedEdges = new HashSet<>();
105-
final List<Edge> edges = new ArrayList<>(topology.getEdges());
106-
edges.sort(new Comparator<Edge>() {
107-
@Override
108-
public int compare(final Edge o1, final Edge o2) {
109-
return o1.getId().compareTo(o2.getId());
110-
}
111-
112-
});
113-
final Map<EdgeState, Integer> stateCounts = new HashMap<>();
114-
stateCounts.put(EdgeState.ACTIVE, 0);
115-
stateCounts.put(EdgeState.INACTIVE, 0);
116-
stateCounts.put(EdgeState.UNCLASSIFIED, 0);
117-
118-
for (final Edge link : edges) {
119-
if (!processedEdges.contains(link)) {
120-
final Edge revLink = link.getReverseEdge();
121-
final EdgeState linkState = link.getState();
122-
builder.append(String.format("%6s", link.getId()) + " : " + linkState.toString().substring(0, 1));
123-
processedEdges.add(link);
124-
stateCounts.put(linkState, stateCounts.get(linkState) + 1);
125-
126-
if (revLink != null) {
127-
final EdgeState revLinkState = revLink.getState();
128-
builder.append(" || " + String.format("%6s", revLink.getId()) + " : "
129-
+ revLinkState.toString().substring(0, 1));
130-
processedEdges.add(revLink);
131-
stateCounts.put(revLinkState, stateCounts.get(revLinkState) + 1);
132-
}
133-
134-
builder.append("\n");
135-
136-
}
137-
}
138-
139-
builder.insert(0, String.format("#A : %d || #I : %d || #U : %d || Sum : %d\n", //
140-
stateCounts.get(EdgeState.ACTIVE), //
141-
stateCounts.get(EdgeState.INACTIVE), //
142-
stateCounts.get(EdgeState.UNCLASSIFIED), //
143-
stateCounts.get(EdgeState.ACTIVE) + stateCounts.get(EdgeState.INACTIVE)
144-
+ stateCounts.get(EdgeState.UNCLASSIFIED)//
145-
));
146-
147-
return builder.toString().trim();
148-
149-
}
150-
15182
/**
15283
* Returns true if the topology contains at least one unclassified edge
15384
*

org.cobolt.simbridge/src/main/java/org/cobolt/algorithms/facade/EMoflonFacade.java

+1-17
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import de.tudarmstadt.maki.simonstrator.api.Monitor;
2929
import de.tudarmstadt.maki.simonstrator.api.Monitor.Level;
3030
import de.tudarmstadt.maki.simonstrator.api.common.graph.EdgeID;
31-
import de.tudarmstadt.maki.simonstrator.api.common.graph.GraphElementProperty;
3231
import de.tudarmstadt.maki.simonstrator.api.common.graph.IEdge;
3332
import de.tudarmstadt.maki.simonstrator.api.common.graph.IElement;
3433
import de.tudarmstadt.maki.simonstrator.api.common.graph.INode;
@@ -53,7 +52,7 @@ public class EMoflonFacade extends TopologyControlFacade_ImplBase {
5352

5453
public static final Double DEFAULT_VALUE_FOR_UNDEFINED_ATTRIBUTES = Double.NaN;
5554

56-
public static final int DEFAULT_VALUE_FOR_UNDEFINED_HOP_COUNT = -1;
55+
private static final int DEFAULT_VALUE_FOR_UNDEFINED_HOP_COUNT = -1;
5756

5857
private final Topology topology;
5958

@@ -142,11 +141,6 @@ private TopologyControlOperationMode mapOperationMode(
142141
}
143142
}
144143

145-
@Override
146-
public void run() {
147-
this.run(new TopologyControlAlgorithmParamters());
148-
}
149-
150144
@Override
151145
public void run(final TopologyControlAlgorithmParamters parameters) {
152146
if (this.algorithm instanceof AbstractKTC) {
@@ -443,16 +437,6 @@ public <T> void updateModelNodeAttribute(final Node modelNode, final SiSType<T>
443437
}
444438
}
445439

446-
/**
447-
* Calls {@link #updateModelLinkAttribute(Edge, GraphElementProperty, Object)}
448-
* for the given link and its reverse link, setting the same value for the given
449-
* property on both links.
450-
*/
451-
public <T> void updateModelLinkAttributeSymmetric(final Edge modelEdge, final SiSType<T> property, final T value) {
452-
updateModelLinkAttribute(modelEdge, property, value);
453-
updateModelLinkAttribute(modelEdge.getReverseEdge(), property, value);
454-
}
455-
456440
/**
457441
* Sets the property of the given link to the given value.
458442
*

org.cobolt.simbridge/src/main/java/org/cobolt/algorithms/facade/EMoflonFacadeAlgorithmHelper.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
/**
1010
* Helper class for algorithms in the {@link EMoflonFacade}
11-
*
11+
*
1212
* @author Roland Kluge - Initial implementation
1313
*/
14-
public class EMoflonFacadeAlgorithmHelper {
14+
class EMoflonFacadeAlgorithmHelper {
1515

1616
/**
1717
* Maps the given {@link TopologyControlAlgorithmID} to an (executable)

org.cobolt.simbridge/src/main/java/org/cobolt/algorithms/facade/EMoflonFacadeAttributeHelper.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
*
1111
* @author Roland Kluge - Initial implementation
1212
*/
13-
public class EMoflonFacadeAttributeHelper {
13+
class EMoflonFacadeAttributeHelper {
1414
private static final EdgeState DEFAULT_VALUE_FOR_UNDEFINED_EDGE_STATE = EdgeState.UNCLASSIFIED;
1515

1616
private EMoflonFacadeAttributeHelper() {
1717
throw new UnsupportedOperationException();
1818
}
1919

20-
static EdgeState getEdgeStateSafe(IEdge prototype) {
20+
static EdgeState getEdgeStateSafe(final IEdge prototype) {
2121
final de.tudarmstadt.maki.simonstrator.tc.underlay.EdgeState value = prototype
2222
.getProperty(UnderlayTopologyProperties.EDGE_STATE);
2323
if (value != null)
@@ -26,7 +26,7 @@ static EdgeState getEdgeStateSafe(IEdge prototype) {
2626
return DEFAULT_VALUE_FOR_UNDEFINED_EDGE_STATE;
2727
}
2828

29-
private static EdgeState mapToModelEdgeState(de.tudarmstadt.maki.simonstrator.tc.underlay.EdgeState value) {
29+
private static EdgeState mapToModelEdgeState(final de.tudarmstadt.maki.simonstrator.tc.underlay.EdgeState value) {
3030
switch (value) {
3131
case ACTIVE:
3232
return EdgeState.ACTIVE;

org.cobolt.simbridge/src/main/java/org/cobolt/algorithms/facade/EMoflonFacadeConstraintsHelper.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
/**
88
* Helper class for graph constraints in the {@link EMoflonFacade}
9-
*
9+
*
1010
* @author Roland Kluge - Initial implementation
1111
*/
12-
public class EMoflonFacadeConstraintsHelper {
12+
class EMoflonFacadeConstraintsHelper {
1313

14-
public static EdgeStateBasedConnectivityConstraint createPhysicalConnectivityConstraint() {
14+
static EdgeStateBasedConnectivityConstraint createPhysicalConnectivityConstraint() {
1515
final EdgeStateBasedConnectivityConstraint constraint = ConstraintsFactory.eINSTANCE
1616
.createEdgeStateBasedConnectivityConstraint();
1717
constraint.getStates().add(EdgeState.ACTIVE);
@@ -20,7 +20,7 @@ public static EdgeStateBasedConnectivityConstraint createPhysicalConnectivityCon
2020
return constraint;
2121
}
2222

23-
public static EdgeStateBasedConnectivityConstraint createWeakConnectivityConstraint() {
23+
static EdgeStateBasedConnectivityConstraint createWeakConnectivityConstraint() {
2424
final EdgeStateBasedConnectivityConstraint constraint = ConstraintsFactory.eINSTANCE
2525
.createEdgeStateBasedConnectivityConstraint();
2626
constraint.getStates().add(EdgeState.ACTIVE);

org.cobolt.simbridge/src/main/java/org/cobolt/algorithms/io/TopologyModelGraphTIO.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import de.tudarmstadt.maki.simonstrator.api.util.UtilityClassNotInstantiableException;
1414

15-
public final class TopologyModelGraphTIO {
15+
final class TopologyModelGraphTIO {
1616
public TopologyModelGraphTIO() {
1717
throw new UtilityClassNotInstantiableException();
1818
}
@@ -35,8 +35,8 @@ static Map<String, EStructuralFeature> initializeAttributeIdentifierMapping() {
3535
return modelAttributeMapping;
3636
}
3737

38-
static Object convertToObject(String attributeValue, String attributeIdentifier, Topology topology,
39-
TopologyElement topologyElement) {
38+
static Object convertToObject(final String attributeValue, final String attributeIdentifier,
39+
final Topology topology, final TopologyElement topologyElement) {
4040
switch (attributeIdentifier) {
4141
case "a":
4242
case "d":
@@ -68,7 +68,7 @@ static Object convertToObject(String attributeValue, String attributeIdentifier,
6868
}
6969
}
7070

71-
static EdgeState parseEdgeState(String stateIdentifier) {
71+
private static EdgeState parseEdgeState(final String stateIdentifier) {
7272
switch (stateIdentifier) {
7373
case "A":
7474
return EdgeState.ACTIVE;

org.cobolt.simbridge/src/main/java/org/cobolt/algorithms/io/TopologyModelGraphTReader.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,37 @@ public TopologyModelGraphTReader() {
3030

3131
/**
3232
* Reads a GraphT file from the given file into the given topology
33-
*
33+
*
3434
* @param topology
35-
* the {@link Topology} to fill
35+
* the {@link Topology} to fill
3636
* @param filename
37-
* the file name to read from
37+
* the file name to read from
3838
*/
3939
public void read(final Topology topology, final String filename) throws FileNotFoundException {
4040
this.read(topology, new File(filename));
4141
}
4242

4343
/**
4444
* Reads a GraphT file from the given file into the given topology
45-
*
45+
*
4646
* @param topology
47-
* the {@link Topology} to fill
47+
* the {@link Topology} to fill
4848
* @param inputFile
49-
* the file to read from
49+
* the file to read from
5050
*/
51-
public void read(final Topology topology, final File inputFile) throws FileNotFoundException {
51+
private void read(final Topology topology, final File inputFile) throws FileNotFoundException {
5252
this.read(topology, new FileInputStream(inputFile));
5353
}
5454

5555
/**
5656
* Reads a GraphT file from the given stream into the given topology
57-
*
57+
*
5858
* @param topology
59-
* the {@link Topology} to fill
59+
* the {@link Topology} to fill
6060
* @param stream
61-
* the stream to read from
61+
* the stream to read from
6262
*/
63-
public void read(final Topology topology, final InputStream stream) {
63+
private void read(final Topology topology, final InputStream stream) {
6464
Scanner scanner = null;
6565

6666
try {
@@ -140,7 +140,7 @@ public void read(final Topology topology, final InputStream stream) {
140140
}
141141

142142
private void parseAttributeSpecification(final TopologyElement topologyElement, final String attributeSpec,
143-
Topology topology) {
143+
final Topology topology) {
144144
final String[] attributeEntry = attributeSpec.split(Pattern.quote("="));
145145
if (attributeEntry.length != 2)
146146
throw new IllegalArgumentException(String.format("Invalid attribute specification: '%s'", attributeSpec));

0 commit comments

Comments
 (0)