Last active
March 8, 2016 18:15
-
-
Save justintuchek/0b8d29035cbc069f2be3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public enum Access { | |
| PUBLIC, | |
| PROTECTED, | |
| PACKAGE, | |
| PRIVATE | |
| } |
This file contains hidden or 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
| public class CoffeeDeliverySystem { | |
| @VisibleForTesting(Access.Private) | |
| public static final String COFFEE_PROTOCOL = "RFC2324"; | |
| public String getProtocol() { | |
| return COFFEE_PROTOCOL; | |
| } | |
| } |
This file contains hidden or 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
| public class CoffeeActivity extends Activity { | |
| private final CoffeeDeliverySystem cds = new CoffeeDeliverySystem(); | |
| /** | |
| * IntelliJ would treat this as access to a private field | |
| * during inspection and hinting. And maybe auto-complete | |
| * and a few dozen other things that IDEA does. | |
| */ | |
| private final String coffeeDeliveryProtocol = cds.COFFEE_PROTOCOL; | |
| } |
This file contains hidden or 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
| @Retention(RetentionPolicy.SOURCE) | |
| public @interface VisibleForTesting { | |
| Access value() default Access.PROTECTED; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment