-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
io.quarkus.builder.Consume
a record
- Loading branch information
Vincent Potucek
authored and
Vincent Potucek
committed
Jan 23, 2025
1 parent
7d23bba
commit 5bdfb99
Showing
3 changed files
with
15 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 13 additions & 35 deletions
48
core/builder/src/main/java/io/quarkus/builder/Consume.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |