AccessSelector { public Optional<Modifier> accessModifierFor(String packageName) { switch (accessFor(packageName)) { case PACKAGE_PRIVATE: return Optional.empty(); case PRIVATE: return Optional.of(Modifier.PRIVATE); case PROTECTED: return Optional.of(Modifier.PROTECTED); case PUBLIC: return Optional.of(Modifier.PUBLIC); } throw new AssertionError("cannot get here"); } AccessSelector(Set<? extends Element> visibilityAnnotatedPackages); Optional<Modifier> accessModifierFor(String packageName);  }
@Test public void shouldReturnEmptyForExplicitPackagePrivate() { assertThat(selector.accessModifierFor("com.spotify.pkgpriv"), is(Optional.empty())); }
@Test public void shouldReturnConfiguredForDirectHit() { assertThat(selector.accessModifierFor("com.spotify.foo"), is(Optional.of(PRIVATE))); }
@Test public void shouldReturnConfiguredForRecursiveHit() { assertThat(selector.accessModifierFor("com.spotify.bar.spork"), is(Optional.of(PROTECTED))); }
@Test public void shouldOnlyMatchFullPackageNames() { assertThat(selector.accessModifierFor("com.spotify.bar.flurb"), is(Optional.of(PROTECTED))); }
@Test public void shouldReturnEmptyForNoHit() { assertThat(selector.accessModifierFor("org.apache"), is(Optional.empty())); }