Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experimental Builder.Parameter and Builder.Switch for values #237
- Loading branch information
Showing
8 changed files
with
192 additions
and
91 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
21 changes: 21 additions & 0 deletions
21
builder/test/org/immutables/builder/fixture/BuilderParameterAndSwitch.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,21 @@ | ||
package org.immutables.builder.fixture; | ||
|
||
import java.lang.annotation.RetentionPolicy; | ||
import javax.annotation.Nullable; | ||
import org.immutables.builder.Builder; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
public interface BuilderParameterAndSwitch { | ||
@Builder.Parameter | ||
int theory(); | ||
|
||
@Nullable | ||
String reality(); | ||
|
||
@Builder.Parameter | ||
String value(); | ||
|
||
@Builder.Switch | ||
RetentionPolicy policy(); | ||
} |
28 changes: 28 additions & 0 deletions
28
builder/test/org/immutables/builder/fixture/BuilderParameterAndSwitch2.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,28 @@ | ||
package org.immutables.builder.fixture; | ||
|
||
import java.lang.annotation.RetentionPolicy; | ||
import org.immutables.builder.Builder; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Style(typeInnerBuilder = "Building") | ||
@Value.Immutable | ||
public interface BuilderParameterAndSwitch2 { | ||
@Builder.Parameter | ||
int theory(); | ||
|
||
@Builder.Parameter | ||
String value(); | ||
|
||
@Builder.Switch | ||
RetentionPolicy policy(); | ||
|
||
class Building extends ImmutableBuilderParameterAndSwitch2.Builder { | ||
public Building() { | ||
super(0, ""); | ||
} | ||
|
||
public Building(int theory, String label) { | ||
super(theory, label); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
builder/test/org/immutables/builder/fixture/BuilderParameterAndSwitchUse.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,15 @@ | ||
package org.immutables.builder.fixture; | ||
|
||
public class BuilderParameterAndSwitchUse { | ||
void use() { | ||
ImmutableBuilderParameterAndSwitch.builder(2, "") | ||
.runtimePolicy() | ||
.sourcePolicy() | ||
.classPolicy() | ||
.build(); | ||
|
||
new BuilderParameterAndSwitch2.Building(2, "guess") | ||
.runtimePolicy() | ||
.build(); | ||
} | ||
} |
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
Oops, something went wrong.