diff --git a/core/builder/src/main/java/io/quarkus/builder/BuildChainBuilder.java b/core/builder/src/main/java/io/quarkus/builder/BuildChainBuilder.java index 8bc07c3da372d..aa242d9647553 100644 --- a/core/builder/src/main/java/io/quarkus/builder/BuildChainBuilder.java +++ b/core/builder/src/main/java/io/quarkus/builder/BuildChainBuilder.java @@ -178,7 +178,7 @@ private Map> wireDependencies(Set entry : stepBuilder.getConsumes().entrySet()) { final Consume consume = entry.getValue(); final ItemId id = entry.getKey(); - if (!consume.getFlags().contains(ConsumeFlag.OPTIONAL) && !id.isMulti()) { + if (!consume.flags().contains(ConsumeFlag.OPTIONAL) && !id.isMulti()) { if (!initialIds.contains(id) && !allProduces.containsKey(id)) { throw new ChainBuildException("No producers for required item " + id); } diff --git a/core/builder/src/main/java/io/quarkus/builder/BuildStepBuilder.java b/core/builder/src/main/java/io/quarkus/builder/BuildStepBuilder.java index 1d46c0aac0931..75431f9b6e694 100644 --- a/core/builder/src/main/java/io/quarkus/builder/BuildStepBuilder.java +++ b/core/builder/src/main/java/io/quarkus/builder/BuildStepBuilder.java @@ -235,7 +235,7 @@ Map getProduces() { Set getRealConsumes() { final HashMap map = new HashMap<>(consumes); - map.entrySet().removeIf(e -> e.getValue().getConstraint() == Constraint.ORDER_ONLY); + map.entrySet().removeIf(e -> e.getValue().constraint() == Constraint.ORDER_ONLY); return map.keySet(); } diff --git a/core/builder/src/main/java/io/quarkus/builder/Consume.java b/core/builder/src/main/java/io/quarkus/builder/Consume.java index d64980fa102de..806bf8bdcb18a 100644 --- a/core/builder/src/main/java/io/quarkus/builder/Consume.java +++ b/core/builder/src/main/java/io/quarkus/builder/Consume.java @@ -1,42 +1,20 @@ package io.quarkus.builder; -final class Consume { - private final BuildStepBuilder buildStepBuilder; - private final ItemId itemId; - private final Constraint constraint; - private final ConsumeFlags flags; +import static io.quarkus.builder.Constraint.ORDER_ONLY; +import static io.quarkus.builder.Constraint.REAL; +import static io.quarkus.builder.ConsumeFlag.OPTIONAL; - Consume(final BuildStepBuilder buildStepBuilder, final ItemId itemId, final Constraint constraint, - final ConsumeFlags flags) { - this.buildStepBuilder = buildStepBuilder; - this.itemId = itemId; - this.constraint = constraint; - this.flags = flags; - } - - BuildStepBuilder getBuildStepBuilder() { - return buildStepBuilder; - } - - ItemId getItemId() { - return itemId; - } - - ConsumeFlags getFlags() { - return flags; - } +record Consume(BuildStepBuilder buildStepBuilder, ItemId itemId, Constraint constraint, ConsumeFlags flags) { Consume combine(final Constraint constraint, final ConsumeFlags flags) { - final Constraint outputConstraint = constraint == Constraint.REAL || this.constraint == Constraint.REAL - ? Constraint.REAL - : Constraint.ORDER_ONLY; - final ConsumeFlags outputFlags = !flags.contains(ConsumeFlag.OPTIONAL) || !this.flags.contains(ConsumeFlag.OPTIONAL) - ? flags.with(this.flags).without(ConsumeFlag.OPTIONAL) - : flags.with(this.flags); - return new Consume(buildStepBuilder, itemId, outputConstraint, outputFlags); - } - - Constraint getConstraint() { - return constraint; + return new Consume( + buildStepBuilder, + itemId, + constraint == REAL || this.constraint == REAL + ? REAL + : ORDER_ONLY, + !flags.contains(OPTIONAL) || !this.flags.contains(OPTIONAL) + ? flags.with(this.flags).without(OPTIONAL) + : flags.with(this.flags)); } }