diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index f3ce8e8..32db7f7 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -552,6 +552,7 @@
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 192b49e..9155874 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -25,7 +25,7 @@
-
+
\ No newline at end of file
diff --git a/Jenkinsfile b/Jenkinsfile
index e25e314..9d6c56f 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -4,7 +4,7 @@ import groovy.transform.stc.ClosureParams
import groovy.transform.stc.SimpleType
@Field
-String jdk = 'openjdk-11'
+String jdk = 'openjdk-17'
@Field
String idea = '2023.2'
@Field
diff --git a/conf/idea/Dockerfile b/conf/idea/Dockerfile
index b103fb4..4430932 100644
--- a/conf/idea/Dockerfile
+++ b/conf/idea/Dockerfile
@@ -11,7 +11,7 @@ curl \
EOF
-FROM debian:buster-20220418
+FROM debian:bullseye-20220418
ARG JDK
RUN <
-
+
diff --git a/exedio-cope-builder-log.txt b/exedio-cope-builder-log.txt
index 30c6223..b142083 100644
--- a/exedio-cope-builder-log.txt
+++ b/exedio-cope-builder-log.txt
@@ -7,6 +7,7 @@ omit bug fixes.
The items are sorted inversely, i.e. latest items are on top
--------------------------------------------------------------------------
+* JDK 17 required
* add @SuppressWarnings({"ClassEscapesDefinedScope", "RedundantSuppression"}) to generated builder
* ant 1.9.7 required
* JDK 11 required
diff --git a/src/com/exedio/cope/builder/ItemBuilder.java b/src/com/exedio/cope/builder/ItemBuilder.java
index 6250d1d..08c085d 100644
--- a/src/com/exedio/cope/builder/ItemBuilder.java
+++ b/src/com/exedio/cope/builder/ItemBuilder.java
@@ -202,7 +202,7 @@ public I build()
}
@SuppressWarnings("unchecked")
- private Condition equalCondition(final FunctionField> key, final SetValue> value)
+ private static Condition equalCondition(final FunctionField> key, final SetValue> value)
{
//noinspection RedundantCast
return ((FunctionField) key).equal(((SetValue) value).value);
diff --git a/src/com/exedio/cope/builder/generator/Main.java b/src/com/exedio/cope/builder/generator/Main.java
index d12857f..ca56735 100644
--- a/src/com/exedio/cope/builder/generator/Main.java
+++ b/src/com/exedio/cope/builder/generator/Main.java
@@ -51,11 +51,9 @@ static void run(final Params params) throws HumanReadableException, IOException
{
for(final Feature feature : type.getDeclaredFeatures())
{
- if(!(feature instanceof CompositeField>))
+ if(!(feature instanceof final CompositeField> field))
continue;
- final CompositeField> field = (CompositeField>) feature;
-
final Class extends Composite> clazz = field.getValueClass();
if(!params.matchesPackagePrefixes(clazz))
{
@@ -82,6 +80,7 @@ static void run(final Params params) throws HumanReadableException, IOException
private static void printSummary(final Params params, final Model model, final ArrayList> skippedPackagePrefix,
final HashMap>> skippedTargetDirectoryDoesNotExist, final int generatedBuilders)
{
+ //noinspection EnhancedSwitchMigration
switch(skippedPackagePrefix.size())
{
case 0: // nothing
diff --git a/src/com/exedio/cope/builder/generator/ModificationCheck.java b/src/com/exedio/cope/builder/generator/ModificationCheck.java
index c1ea912..5dabafe 100644
--- a/src/com/exedio/cope/builder/generator/ModificationCheck.java
+++ b/src/com/exedio/cope/builder/generator/ModificationCheck.java
@@ -39,6 +39,7 @@ static File getFileContaining(final URI uri)
if(scheme == null)
throw new IllegalArgumentException("scheme null in " + uri);
+ //noinspection EnhancedSwitchMigration
switch(scheme)
{
case "file":
diff --git a/src/com/exedio/cope/builder/generator/Params.java b/src/com/exedio/cope/builder/generator/Params.java
index f2d6846..0b39767 100644
--- a/src/com/exedio/cope/builder/generator/Params.java
+++ b/src/com/exedio/cope/builder/generator/Params.java
@@ -53,7 +53,7 @@ private void addPackagePrefix(final String packagePrefix)
"packagePrefix \"" + packagePrefix + "\" must not end with dot.");
packagePrefixesMatch.add(packagePrefix + '.');
- if(packagePrefixesDisplay.length() > 0)
+ if(!packagePrefixesDisplay.isEmpty())
packagePrefixesDisplay.append(',');
packagePrefixesDisplay.append(packagePrefix);
}
diff --git a/src/com/exedio/cope/builder/generator/Writer.java b/src/com/exedio/cope/builder/generator/Writer.java
index 787196b..889efe4 100644
--- a/src/com/exedio/cope/builder/generator/Writer.java
+++ b/src/com/exedio/cope/builder/generator/Writer.java
@@ -153,18 +153,16 @@ else if(feature instanceof PriceField)
"final int store",
"com.exedio.cope.pattern.Price.storeOf(store)");
}
- else if(feature instanceof MoneyField)
+ else if(feature instanceof final MoneyField> field)
{
- final MoneyField> field = (MoneyField>) feature;
final String currencyClass = TypeUtil.getCanonicalName(field.getCurrencyClass());
writeRedirectSetter(writer, featureIdentifier, "final double value," + "final " + currencyClass + " currency",
"com.exedio.cope.pattern.Money.valueOf(value,currency)");
writeRedirectSetter(writer, featureIdentifier, "final int store," + "final " + currencyClass + " currency",
"com.exedio.cope.pattern.Money.storeOf(store,currency)");
}
- else if(feature instanceof ItemField)
+ else if(feature instanceof final ItemField> field)
{
- final ItemField> field = (ItemField>) feature;
final Class extends Item> elementClass = field.getValueClass();
Type> elementType = null;
try
@@ -200,9 +198,8 @@ else if(feature instanceof ItemField)
}
}
}
- else if(feature instanceof CompositeField)
+ else if(feature instanceof final CompositeField> field)
{
- final CompositeField> field = (CompositeField>) feature;
final CompositeType myType = new CompositeType(field);
if(generated.contains(myType))
{
@@ -223,9 +220,8 @@ else if(feature instanceof CompositeField)
System.out.println("Skip external composite lambda builder setter:" + field + " " + myType.getJavaClass());
}
}
- else if(feature instanceof EnumMapField)
+ else if(feature instanceof final EnumMapField, ?> enumMapField)
{
- final EnumMapField, ?> enumMapField = (EnumMapField, ?>) feature;
final Class extends Enum>> keyClass = enumMapField.getKeyClass();
final String enumKeyType = TypeUtil.getCanonicalName(enumMapField.getKeyClass());
final String enumValueType = TypeUtil.getCanonicalName(enumMapField.getValueClass());
diff --git a/src/com/exedio/cope/builder/generator/type/TypeUtil.java b/src/com/exedio/cope/builder/generator/type/TypeUtil.java
index ada7a72..b295e80 100644
--- a/src/com/exedio/cope/builder/generator/type/TypeUtil.java
+++ b/src/com/exedio/cope/builder/generator/type/TypeUtil.java
@@ -64,28 +64,24 @@ private static String getCanonicalName(@Nonnull final ParameterizedType type)
@Nullable
public static String valueType(@Nonnull final Feature feature)
{
- if(feature instanceof Settable>)
+ if(feature instanceof final Settable> field)
{
- final Settable> field = (Settable>) feature;
final Type valueClass = field.getInitialType();
final Type primitiveClass = (valueClass instanceof Class && field.isMandatory())
? PrimitiveUtil.toPrimitive((Class>) valueClass)
: valueClass;
return getCanonicalName((primitiveClass != null) ? primitiveClass : Objects.requireNonNull(valueClass));
}
- else if(feature instanceof SetField>)
+ else if(feature instanceof final SetField> field)
{
- final SetField> field = (SetField>) feature;
return Set.class.getName() + '<' + getCanonicalName(field.getElement().getValueClass()) + '>';
}
- else if(feature instanceof ListField>)
+ else if(feature instanceof final ListField> field)
{
- final ListField> field = (ListField>) feature;
return List.class.getName() + '<' + getCanonicalName(field.getElement().getValueClass()) + '>';
}
- else if(feature instanceof MapField, ?>)
+ else if(feature instanceof final MapField, ?> field)
{
- final MapField, ?> field = (MapField, ?>) feature;
return Map.class.getName() + '<' + getCanonicalName(field.getKey().getValueClass()) + ',' + getCanonicalName(field.getValue().getValueClass())
+ '>';
}
@@ -97,9 +93,8 @@ public static String fieldType(@Nonnull final Feature feature)
{
if(feature instanceof Settable)
{
- if(feature instanceof EnumMapField)
+ if(feature instanceof final EnumMapField, ?> field)
{
- final EnumMapField, ?> field = (EnumMapField, ?>) feature;
return EnumMapField.class.getCanonicalName() + '<' + getCanonicalName(field.getKeyClass()) + ',' +
getCanonicalName(field.getValueClass()) + '>';
}
@@ -113,9 +108,8 @@ else if(feature instanceof ListField)
{
return ListField.class.getName() + '<' + getCanonicalName(((ListField>) feature).getElement().getValueClass()) + '>';
}
- else if(feature instanceof MapField)
+ else if(feature instanceof final MapField, ?> field)
{
- final MapField, ?> field = (MapField, ?>) feature;
return MapField.class.getName() + '<' + getCanonicalName(field.getKey().getValueClass()) + ',' +
getCanonicalName(field.getValue().getValueClass()) + '>';
}
diff --git a/testsrc/com/exedio/cope/builder/test/CompositeFieldTest.java b/testsrc/com/exedio/cope/builder/test/CompositeFieldTest.java
index ef4c7f1..3520a86 100644
--- a/testsrc/com/exedio/cope/builder/test/CompositeFieldTest.java
+++ b/testsrc/com/exedio/cope/builder/test/CompositeFieldTest.java
@@ -26,7 +26,6 @@ public void fallback()
}
@Test
- @SuppressWarnings("MisorderedAssertEqualsArguments") // OK: bug in idea
public void getOrBuild()
{
assertEquals(asList(), CompositeItem.TYPE.search());