Skip to content

Commit fdec294

Browse files
committed
style: code style hints from IntelliJ
- Cleanup code - Source version set to 21 - Updated library versions
1 parent 516a3e6 commit fdec294

File tree

80 files changed

+448
-997
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+448
-997
lines changed

use-core/pom.xml

+11-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<artifactId>use-core</artifactId>
1313

1414
<properties>
15-
<maven.compiler.source>14</maven.compiler.source>
16-
<maven.compiler.target>14</maven.compiler.target>
15+
<maven.compiler.source>21</maven.compiler.source>
16+
<maven.compiler.target>21</maven.compiler.target>
1717
</properties>
1818

1919
<dependencies>
@@ -45,7 +45,7 @@
4545
<dependency>
4646
<groupId>org.jruby</groupId>
4747
<artifactId>jruby-core</artifactId>
48-
<version>9.3.1.0</version>
48+
<version>9.4.5.0</version>
4949
</dependency>
5050
<dependency>
5151
<groupId>com.ximpleware</groupId>
@@ -55,7 +55,7 @@
5555
<dependency>
5656
<groupId>com.google.guava</groupId>
5757
<artifactId>guava-testlib</artifactId>
58-
<version>20.0</version>
58+
<version>33.2.1-jre</version>
5959
<scope>test</scope>
6060
</dependency>
6161
<dependency>
@@ -304,4 +304,11 @@
304304
</plugin>
305305
</plugins>
306306
</build>
307+
<repositories>
308+
<repository>
309+
<id>maven_central</id>
310+
<name>Maven Central</name>
311+
<url>https://repo.maven.apache.org/maven2/</url>
312+
</repository>
313+
</repositories>
307314
</project>

use-core/src/it/java/org/tzi/use/OCLExpressionIT.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
package org.tzi.use;
22

3-
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
import static org.junit.jupiter.api.Assertions.assertTrue;
5-
import static org.junit.jupiter.api.Assertions.fail;
6-
73
import org.junit.jupiter.api.Test;
84
import org.tzi.use.api.UseApiException;
95
import org.tzi.use.api.UseModelApi;
106
import org.tzi.use.api.UseSystemApi;
117
import org.tzi.use.api.impl.UseSystemApiNative;
12-
import org.tzi.use.uml.mm.MModel;
138
import org.tzi.use.uml.ocl.value.Value;
149

10+
import static org.junit.jupiter.api.Assertions.*;
11+
1512
public class OCLExpressionIT {
1613

1714
@Test

use-core/src/main/java/org/tzi/use/analysis/coverage/AbstractCoverageVisitor.java

+8-10
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,13 @@ protected abstract void addOperationCoverage(MClassifier sourceClassifier,
5454

5555
@Override
5656
public void visitAllInstances(ExpAllInstances exp) {
57-
if (exp.getSourceType() instanceof MDataType) {
58-
addDataTypeCoverage((MDataType) exp.getSourceType());
59-
} else if (exp.getSourceType() instanceof MClass) {
60-
addClassCoverage((MClass) exp.getSourceType());
61-
} else if (exp.getSourceType() instanceof MAssociation) {
62-
addAssociationCoverage((MAssociation) exp.getSourceType());
63-
} else {
64-
// handle case
65-
}
57+
switch (exp.getSourceType()) {
58+
case MDataType mDataType -> addDataTypeCoverage(mDataType);
59+
case MClass mClass -> addClassCoverage(mClass);
60+
case MAssociation mAssociation -> addAssociationCoverage(mAssociation);
61+
case null, default ->
62+
throw new RuntimeException("Unhandled subtype %s in visitor".formatted(exp.getClass().getName()));
63+
}
6664
}
6765

6866
@Override
@@ -188,7 +186,7 @@ public void visitObjAsSet(ExpObjAsSet exp) {
188186
exp.getObjectExpression().processWithVisitor(this);
189187
}
190188

191-
private Stack<MOperation> operationStack = new Stack<MOperation>();
189+
private final Stack<MOperation> operationStack = new Stack<MOperation>();
192190

193191
@Override
194192
public void visitObjOp(ExpObjOp exp) {

use-core/src/main/java/org/tzi/use/config/Options.java

-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ public class Options {
4848
public static final String COPYRIGHT = "Copyright (C) 1999-2024 University of Bremen & " +
4949
"University of Applied Sciences Hamburg";
5050

51-
// the trained support apes
52-
public static final String SUPPORT_MAIL = "grp-usedevel@informatik.uni-bremen.de";
53-
5451
/**
5552
* Name of the file for user properties.
5653
*/

use-core/src/main/java/org/tzi/use/gen/tool/GGenerator.java

+8-13
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@
2424

2525
package org.tzi.use.gen.tool;
2626

27-
import java.io.BufferedWriter;
28-
import java.io.FileInputStream;
29-
import java.io.FileNotFoundException;
30-
import java.io.FileWriter;
31-
import java.io.IOException;
32-
import java.io.PrintWriter;
33-
import java.util.Collection;
34-
import java.util.List;
35-
3627
import org.tzi.use.config.Options;
3728
import org.tzi.use.gen.assl.dynamics.GEvalProcedure;
3829
import org.tzi.use.gen.assl.dynamics.GEvaluationException;
@@ -48,6 +39,10 @@
4839
import org.tzi.use.uml.sys.soil.MStatement;
4940
import org.tzi.use.util.Log;
5041

42+
import java.io.*;
43+
import java.util.Collection;
44+
import java.util.List;
45+
5146

5247
/**
5348
* Provides operations called by the <code>GGeneratorShell</code>.
@@ -81,14 +76,14 @@ protected void internalError(GEvaluationException e, long randomNr) {
8176
e.printStackTrace(pw);
8277
pw.close();
8378
System.err.println("THE GENERATOR HAS AN INTERNAL ERROR." + nl +
84-
"PLEASE SEND THE FILE `generator_error.txt'"+nl+
85-
"TO " + Options.SUPPORT_MAIL + ".");
79+
"PLEASE SUBMIT THE FILE `generator_error.txt'"+nl+
80+
"AS AN ISSUE ON GITHUB.");
8681
System.err.println("The random number generator was "
8782
+ "initialized with " + randomNr + ".");
8883
} catch (IOException ioException) {
8984
System.err.println("THE GENERATOR HAS AN INTERNAL ERROR." + nl +
90-
"PLEASE SEND THE FOLLOWING INFORMATION "+nl+
91-
"TO " + Options.SUPPORT_MAIL + ".");
85+
"PLEASE SUBMIT THE FOLLOWING INFORMATION "+nl+
86+
"AS AN ISSUE ON GITHUB.");
9287
System.err.println("Program version: " + Options.RELEASE_VERSION);
9388
System.err.println("Stack trace: ");
9489
e.printStackTrace();

use-core/src/main/java/org/tzi/use/uml/mm/MAggregationKind.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ private MAggregationKind() {}
3737
/**
3838
* Returns a string representation of the enumeration values.
3939
*/
40-
public static final String name(int k) {
40+
public static String name(int k) {
4141
return fNames[k];
4242
}
4343

44-
public static final boolean isValid(int k) {
44+
public static boolean isValid(int k) {
4545
return k >= 0 && k <= 2;
4646
}
4747
}

use-core/src/main/java/org/tzi/use/uml/mm/MAssociationClassImpl.java

+6-12
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@
1919

2020
package org.tzi.use.uml.mm;
2121

22-
import java.util.ArrayList;
23-
import java.util.Collection;
24-
import java.util.Collections;
25-
import java.util.Iterator;
26-
import java.util.List;
27-
import java.util.Map;
28-
import java.util.Set;
29-
3022
import org.eclipse.jdt.annotation.NonNull;
3123
import org.tzi.use.uml.mm.statemachines.MProtocolStateMachine;
3224
import org.tzi.use.uml.ocl.expr.Expression;
@@ -35,6 +27,8 @@
3527
import org.tzi.use.uml.ocl.type.TypeFactory;
3628
import org.tzi.use.uml.sys.MOperationCall;
3729

30+
import java.util.*;
31+
3832

3933
/**
4034
* An associationclass is a class and a association at once.
@@ -48,8 +42,8 @@
4842

4943
public class MAssociationClassImpl extends MClassifierImpl implements MAssociationClass {
5044

51-
private MAssociationImpl fAssociationImpl;
52-
private MClassImpl fClassImpl;
45+
private final MAssociationImpl fAssociationImpl;
46+
private final MClassImpl fClassImpl;
5347

5448
/**
5549
* Creates a new associationclass.
@@ -520,7 +514,7 @@ public List<MNavigableElement> navigableEndsFrom( MClass cls ) {
520514
List<MNavigableElement> nav;
521515

522516
if (cls.equals(this)) {
523-
nav = new ArrayList<MNavigableElement>(navigableEnds().values());
517+
nav = new ArrayList<>(navigableEnds().values());
524518
} else {
525519
nav = fAssociationImpl.navigableEndsFrom( cls );
526520
nav.add( this );
@@ -530,7 +524,7 @@ public List<MNavigableElement> navigableEndsFrom( MClass cls ) {
530524
}
531525

532526
public Collection<MNavigableElement> navigableElements() {
533-
List<MNavigableElement> ne = new ArrayList<MNavigableElement>( navigableEnds().values() );
527+
List<MNavigableElement> ne = new ArrayList<>(navigableEnds().values());
534528
ne.add( this );
535529
return ne;
536530
}

use-core/src/main/java/org/tzi/use/uml/mm/MAssociationEnd.java

+9-16
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,15 @@
1919

2020
package org.tzi.use.uml.mm;
2121

22-
import java.util.Collections;
23-
import java.util.HashSet;
24-
import java.util.LinkedList;
25-
import java.util.List;
26-
import java.util.Set;
27-
2822
import org.tzi.use.uml.ocl.expr.Expression;
2923
import org.tzi.use.uml.ocl.expr.VarDecl;
3024
import org.tzi.use.uml.ocl.expr.VarDeclList;
3125
import org.tzi.use.uml.ocl.type.Type;
3226
import org.tzi.use.uml.ocl.type.TypeFactory;
3327
import org.tzi.use.util.collections.CollectionUtil;
3428

29+
import java.util.*;
30+
3531
/**
3632
* An AssociationEnd stores information about the role a class plays
3733
* in an association.
@@ -41,10 +37,10 @@
4137
public final class MAssociationEnd extends MModelElementImpl implements MNavigableElement {
4238

4339
private MAssociation fAssociation; // Owner of this association end
44-
private MClass fClass; // associated class
45-
private MMultiplicity fMultiplicity; // multiplicity spec
40+
private final MClass fClass; // associated class
41+
private final MMultiplicity fMultiplicity; // multiplicity spec
4642
private int fKind; // none, aggregation, or composition
47-
private boolean fIsOrdered; // use as Set or OrderedSet
43+
private final boolean fIsOrdered; // use as Set or OrderedSet
4844
private boolean fIsNavigable = true;
4945
private boolean fIsExplicitNavigable = false;
5046

@@ -113,11 +109,8 @@ public MAssociationEnd(MClass cls,
113109
fMultiplicity = mult;
114110
setAggregationKind(kind);
115111
fIsOrdered = isOrdered;
116-
117-
if (qualifiers == null)
118-
this.qualifier = Collections.emptyList();
119-
else
120-
this.qualifier = qualifiers;
112+
113+
this.qualifier = Objects.requireNonNullElse(qualifiers, Collections.emptyList());
121114
}
122115

123116
/**
@@ -248,7 +241,7 @@ public boolean equals(Object obj) {
248241
public Type getType( Type sourceObjectType, MNavigableElement src, boolean qualifiedAccess ) {
249242
Type t;
250243

251-
if (this.getRedefiningEnds().size() > 0) {
244+
if (!this.getRedefiningEnds().isEmpty()) {
252245
t = getRedefinedType((MClass)sourceObjectType);
253246
} else {
254247
t = cls();
@@ -480,7 +473,7 @@ public List<VarDecl> getQualifiers() {
480473

481474
@Override
482475
public boolean hasQualifiers() {
483-
return getQualifiers().size() > 0;
476+
return !getQualifiers().isEmpty();
484477
}
485478

486479
/* (non-Javadoc)

0 commit comments

Comments
 (0)