diff --git a/build-release-17 b/build-release-17 new file mode 100644 index 0000000..e69de29 diff --git a/container/build-release-17 b/container/build-release-17 new file mode 100644 index 0000000..e69de29 diff --git a/container/pom.xml b/container/pom.xml index 41775f7..38c8c2b 100644 --- a/container/pom.xml +++ b/container/pom.xml @@ -5,7 +5,7 @@ io.smallrye.beanbag smallrye-beanbag-parent - 1.4.2-SNAPSHOT + 1.5.0-SNAPSHOT smallrye-beanbag diff --git a/container/src/main/java/io/smallrye/beanbag/Util.java b/container/src/main/java/io/smallrye/beanbag/Util.java index edabcbc..77126ee 100644 --- a/container/src/main/java/io/smallrye/beanbag/Util.java +++ b/container/src/main/java/io/smallrye/beanbag/Util.java @@ -27,22 +27,18 @@ public static List mapList(List input, Function mapper, IntFu Assert.checkNotNullParam("input", input); Assert.checkNotNullParam("mapper", mapper); final int size = input.size(); - switch (size) { - case 0: - return List.of(); - case 1: - return List.of(mapper.apply(input.get(0))); - case 2: - return List.of(mapper.apply(input.get(0)), mapper.apply(input.get(1))); - case 3: - return List.of(mapper.apply(input.get(0)), mapper.apply(input.get(1)), mapper.apply(input.get(2))); - default: { + return switch (size) { + case 0 -> List.of(); + case 1 -> List.of(mapper.apply(input.get(0))); + case 2 -> List.of(mapper.apply(input.get(0)), mapper.apply(input.get(1))); + case 3 -> List.of(mapper.apply(input.get(0)), mapper.apply(input.get(1)), mapper.apply(input.get(2))); + default -> { final R[] array = generator.apply(size); for (int i = 0; i < size; i++) { array[i] = mapper.apply(input.get(i)); } - return List.of(array); + yield List.of(array); } - } + }; } } diff --git a/maven/build-release-17 b/maven/build-release-17 new file mode 100644 index 0000000..e69de29 diff --git a/maven/pom.xml b/maven/pom.xml index 5e21a79..5c3aa46 100644 --- a/maven/pom.xml +++ b/maven/pom.xml @@ -5,7 +5,7 @@ io.smallrye.beanbag smallrye-beanbag-parent - 1.4.2-SNAPSHOT + 1.5.0-SNAPSHOT smallrye-beanbag-maven diff --git a/pom.xml b/pom.xml index 0c8c5a1..c7111dd 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.smallrye.beanbag smallrye-beanbag-parent - 1.4.2-SNAPSHOT + 1.5.0-SNAPSHOT io.smallrye @@ -17,8 +17,6 @@ A trivial programmatic bean container implementation - 11 - 11 UTF-8 diff --git a/sisu/build-release-17 b/sisu/build-release-17 new file mode 100644 index 0000000..e69de29 diff --git a/sisu/pom.xml b/sisu/pom.xml index a4be085..750d6d1 100644 --- a/sisu/pom.xml +++ b/sisu/pom.xml @@ -5,7 +5,7 @@ io.smallrye.beanbag smallrye-beanbag-parent - 1.4.2-SNAPSHOT + 1.5.0-SNAPSHOT smallrye-beanbag-sisu diff --git a/sisu/src/main/java/io/smallrye/beanbag/sisu/Sisu.java b/sisu/src/main/java/io/smallrye/beanbag/sisu/Sisu.java index 015acfa..0941a3c 100644 --- a/sisu/src/main/java/io/smallrye/beanbag/sisu/Sisu.java +++ b/sisu/src/main/java/io/smallrye/beanbag/sisu/Sisu.java @@ -136,13 +136,10 @@ interface XMLCloser extends AutoCloseable { private void consume(final XMLStreamReader xr) throws XMLStreamException { while (xr.hasNext()) { switch (xr.next()) { - case XMLStreamReader.END_ELEMENT: { + case XMLStreamReader.END_ELEMENT -> { return; } - case XMLStreamReader.START_ELEMENT: { - consume(xr); - break; - } + case XMLStreamReader.START_ELEMENT -> consume(xr); } } } @@ -152,16 +149,15 @@ private void parseComponentSet(final XMLStreamReader xr, final Map, Com throws XMLStreamException { while (xr.hasNext()) { switch (xr.next()) { - case XMLStreamReader.END_ELEMENT: { + case XMLStreamReader.END_ELEMENT -> { return; } - case XMLStreamReader.START_ELEMENT: { + case XMLStreamReader.START_ELEMENT -> { if (xr.getLocalName().equals("components")) { parseComponents(xr, map, classLoader, filter); } else { consume(xr); } - break; } } } @@ -172,16 +168,15 @@ private void parseComponents(final XMLStreamReader xr, final Map, Compo throws XMLStreamException { while (xr.hasNext()) { switch (xr.next()) { - case XMLStreamReader.END_ELEMENT: { + case XMLStreamReader.END_ELEMENT -> { return; } - case XMLStreamReader.START_ELEMENT: { + case XMLStreamReader.START_ELEMENT -> { if (xr.getLocalName().equals("component")) { parseComponent(xr, map, classLoader, filter); } else { consume(xr); } - break; } } } @@ -199,13 +194,13 @@ private void parseComponent(final XMLStreamReader xr, final Map, Compon loop: while (xr.hasNext()) { switch (xr.next()) { - case XMLStreamReader.END_ELEMENT: { + case XMLStreamReader.END_ELEMENT -> { // all done break loop; } - case XMLStreamReader.START_ELEMENT: { + case XMLStreamReader.START_ELEMENT -> { switch (xr.getLocalName()) { - case "implementation": { + case "implementation" -> { if (clazz == null) { // try to load it up final String className = xr.getElementText(); @@ -227,9 +222,8 @@ private void parseComponent(final XMLStreamReader xr, final Map, Compon } else { consume(xr); } - break; } - case "role": { + case "role" -> { if (type == null) { final String className = xr.getElementText(); if (builder.isTypeFilteredOut(className)) { @@ -244,9 +238,8 @@ private void parseComponent(final XMLStreamReader xr, final Map, Compon } else { consume(xr); } - break; } - case "role-hint": { + case "role-hint" -> { if (name == null) { name = xr.getElementText(); if (name.equals("default")) { @@ -255,33 +248,16 @@ private void parseComponent(final XMLStreamReader xr, final Map, Compon } else { consume(xr); } - break; } - case "instantiation-strategy": { + case "instantiation-strategy" -> { switch (xr.getElementText()) { - case "per-lookup": { - singleton = false; - break; - } - case "poolable": - case "keep-alive": - case "singleton": { - singleton = true; - break; - } + case "per-lookup" -> singleton = false; + case "poolable", "keep-alive", "singleton" -> singleton = true; } - break; - } - case "requirements": { - requirements = parseRequirements(xr, classLoader, filter); - break; - } - default: { - consume(xr); - break; } + case "requirements" -> requirements = parseRequirements(xr, classLoader, filter); + default -> consume(xr); } - break; } } } @@ -339,22 +315,18 @@ private List parseRequirements(final XMLStreamReader xr, final Clas List list = null; loop: while (xr.hasNext()) { switch (xr.next()) { - case XMLStreamReader.END_ELEMENT: { + case XMLStreamReader.END_ELEMENT -> { break loop; } - case XMLStreamReader.START_ELEMENT: { + case XMLStreamReader.START_ELEMENT -> { switch (xr.getLocalName()) { - case "requirement": { + case "requirement" -> { if (list == null) { list = new ArrayList<>(); } list.add(parseRequirement(xr, classLoader, filter)); - break; - } - default: { - consume(xr); - break; } + default -> consume(xr); } } } @@ -367,34 +339,23 @@ private Requirement parseRequirement(final XMLStreamReader xr, final ClassLoader final Requirement requirement = new Requirement(); while (xr.hasNext()) { switch (xr.next()) { - case XMLStreamReader.END_ELEMENT: { + case XMLStreamReader.END_ELEMENT -> { return requirement; } - case XMLStreamReader.START_ELEMENT: { + case XMLStreamReader.START_ELEMENT -> { switch (xr.getLocalName()) { - case "role": { - requirement.injectType = xr.getElementText(); - break; - } - case "role-hint": { + case "role" -> requirement.injectType = xr.getElementText(); + case "role-hint" -> { requirement.injectName = xr.getElementText(); if (requirement.injectName.equals("default")) { requirement.injectName = ""; } - break; - } - case "field": - case "field-name": { - requirement.fieldName = xr.getElementText(); - break; } + case "field", "field-name" -> requirement.fieldName = xr.getElementText(); + // todo: configuration - default: { - consume(xr); - break; - } + default -> consume(xr); } - break; } } } @@ -745,8 +706,7 @@ private static void doExprPart(final StringBuilder b, final StringItr itr, final } private static Type getTypeArgument(Type type, int position) { - if (type instanceof ParameterizedType) { - ParameterizedType pt = (ParameterizedType) type; + if (type instanceof final ParameterizedType pt) { return pt.getActualTypeArguments()[position]; } else { throw new IllegalArgumentException("No type argument given for " + type); @@ -756,19 +716,15 @@ private static Type getTypeArgument(Type type, int position) { private static Class getRawType(Type type) { if (type instanceof Class) { return (Class) type; - } else if (type instanceof ParameterizedType) { - ParameterizedType pt = (ParameterizedType) type; + } else if (type instanceof final ParameterizedType pt) { return getRawType(pt.getRawType()); - } else if (type instanceof GenericArrayType) { - GenericArrayType gat = (GenericArrayType) type; + } else if (type instanceof final GenericArrayType gat) { // Class.arrayType() is JDK 12+ return getArrayType(getRawType(gat.getGenericComponentType())); - } else if (type instanceof WildcardType) { - WildcardType wt = (WildcardType) type; + } else if (type instanceof final WildcardType wt) { final Type[] ub = wt.getUpperBounds(); return ub.length >= 1 ? getRawType(ub[0]) : Object.class; - } else if (type instanceof TypeVariable) { - TypeVariable tv = (TypeVariable) type; + } else if (type instanceof final TypeVariable tv) { final Type[] bounds = tv.getBounds(); return bounds.length >= 1 ? getRawType(bounds[0]) : Object.class; } else { @@ -959,28 +915,23 @@ private Annotations(AnnotatedElement element) { final Class annoType = annotation.annotationType(); final String annoName = annoType.getName(); switch (annoName) { - case "javax.inject.Inject": + case "javax.inject.Inject" -> { inject = true; - break; - case "javax.inject.Singleton": - case "org.eclipse.sisu.EagerSingleton": - case "org.sonatype.inject.EagerSingleton": + } + case "javax.inject.Singleton", "org.eclipse.sisu.EagerSingleton", "org.sonatype.inject.EagerSingleton" -> { singleton = true; - break; - case "javax.inject.Named": + } + case "javax.inject.Named" -> { named = GET_NAMED_VALUE_FN.get(annoType).apply(annotation); - break; - case "org.eclipse.sisu.Nullable": - case "org.sonatype.inject.Nullable": + } + case "org.eclipse.sisu.Nullable", "org.sonatype.inject.Nullable" -> { nullable = true; - break; - case "org.eclipse.sisu.Priority": { + } + case "org.eclipse.sisu.Priority" -> { priority = GET_PRIORITY_VALUE_FN.get(annoType).apply(annotation).intValue(); - break; } - case "org.eclipse.sisu.Typed": { + case "org.eclipse.sisu.Typed" -> { typed = List.of(GET_TYPED_VALUE_FN.get(annoType).apply(annotation)); - break; } } }