-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug where a Staged interface for a required property generates …
…a setter with the wrong type parameter.
- Loading branch information
Showing
4 changed files
with
60 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.jilt.test; | ||
|
||
import org.jilt.test.data.optionals.OptionalsValue; | ||
import org.jilt.test.data.optionals.OptionalsValueBuilder; | ||
import org.junit.Test; | ||
|
||
import java.util.Optional; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class OptionalsValueTest { | ||
@Test | ||
public void optional_property_is_always_optional() { | ||
OptionalsValue<String, Integer> value = OptionalsValueBuilder.<String, Integer>optionalsValue() | ||
.optional(Optional.of("abc")) | ||
.t2(33) | ||
.build(); | ||
|
||
assertThat(value.optional).contains("abc"); | ||
assertThat(value.t2).isEqualTo(33); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/test/java/org/jilt/test/data/optionals/OptionalsValue.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.jilt.test.data.optionals; | ||
|
||
import org.jilt.Builder; | ||
import org.jilt.BuilderStyle; | ||
|
||
import java.util.Optional; | ||
|
||
@Builder(style = BuilderStyle.STAGED) | ||
public final class OptionalsValue<T1, T2> { | ||
public final Optional<T1> optional; | ||
public final T2 t2; | ||
|
||
public OptionalsValue(Optional<T1> optional, T2 t2) { | ||
this.optional = optional; | ||
this.t2 = t2; | ||
} | ||
} |