-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check field type when looking for stored delayed execution methods
- Loading branch information
Showing
7 changed files
with
107 additions
and
21 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
18 changes: 18 additions & 0 deletions
18
...try/src/test/java/com/example/staticinitializers/delayedexecution/EnumFieldMethodRef.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,18 @@ | ||
package com.example.staticinitializers.delayedexecution; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public enum EnumFieldMethodRef { | ||
A(EnumFieldMethodRef::canMutate), B(EnumFieldMethodRef::canMutate); | ||
|
||
private final Supplier<String> supplier; | ||
|
||
|
||
EnumFieldMethodRef(Supplier<String> supplier) { | ||
this.supplier = supplier; | ||
} | ||
|
||
private static String canMutate() { | ||
return "Do not mutate"; | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...staticinitializers/EnumFieldSupplier.java → ...s/delayedexecution/EnumFieldSupplier.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
23 changes: 23 additions & 0 deletions
23
...-entry/src/test/java/com/example/staticinitializers/delayedexecution/EnumMixedFields.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,23 @@ | ||
package com.example.staticinitializers.delayedexecution; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public enum EnumMixedFields { | ||
A(EnumMixedFields::canMutate, doNotMutate()), B(EnumMixedFields::canMutate, doNotMutate()); | ||
|
||
private final Supplier<String> supplier; | ||
private final String s; | ||
|
||
EnumMixedFields(Supplier<String> supplier, String s) { | ||
this.supplier = supplier; | ||
this.s = s; | ||
} | ||
|
||
private static String canMutate() { | ||
return "mutate me"; // mutate | ||
} | ||
|
||
private static String doNotMutate() { | ||
return "Do not mutate"; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...aticinitializers/StaticFunctionField.java → ...delayedexecution/StaticFunctionField.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
2 changes: 1 addition & 1 deletion
2
...aticinitializers/StaticSupplierField.java → ...delayedexecution/StaticSupplierField.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
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