Skip to content

Instantly share code, notes, and snippets.

@justintuchek
Last active March 8, 2016 18:15
Show Gist options
  • Save justintuchek/0b8d29035cbc069f2be3 to your computer and use it in GitHub Desktop.
Save justintuchek/0b8d29035cbc069f2be3 to your computer and use it in GitHub Desktop.
public enum Access {
PUBLIC,
PROTECTED,
PACKAGE,
PRIVATE
}
public class CoffeeDeliverySystem {
@VisibleForTesting(Access.Private)
public static final String COFFEE_PROTOCOL = "RFC2324";
public String getProtocol() {
return COFFEE_PROTOCOL;
}
}
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;
}
@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