Codota Logo
ApiSurface
Code IndexAdd Codota to your IDE (free)

How to use
ApiSurface
in
org.apache.beam.sdk.util

Best Java code snippets using org.apache.beam.sdk.util.ApiSurface (Showing top 18 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ScheduledThreadPoolExecutor s =
  • Codota Iconnew ScheduledThreadPoolExecutor(corePoolSize)
  • Codota IconThreadFactory threadFactory;new ScheduledThreadPoolExecutor(corePoolSize, threadFactory)
  • Codota IconString str;new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(str).build())
  • Smart code suggestions by Codota
}
origin: org.apache.beam/beam-sdks-java-core

/**
 * All classes transitively reachable via only public method signatures of the SDK.
 *
 * <p>Note that our idea of "public" does not include various internal-only APIs.
 */
public static ApiSurface getSdkApiSurface(final ClassLoader classLoader) throws IOException {
 return ApiSurface.ofPackage("org.apache.beam", classLoader)
   .pruningPattern("org[.]apache[.]beam[.].*Test")
   // Exposes Guava, but not intended for users
   .pruningClassName("org.apache.beam.sdk.util.common.ReflectHelpers")
   // test only
   .pruningClassName("org.apache.beam.sdk.testing.InterceptingUrlClassLoader")
   // test only
   .pruningPrefix("org.apache.beam.model.")
   .pruningPrefix("org.apache.beam.vendor.")
   .pruningPrefix("java");
}
origin: org.apache.beam/beam-sdks-java-core

/** See {@link ApiSurface#containsOnlyPackages(Set)}. */
public static Matcher<ApiSurface> containsOnlyPackages(final String... packageNames) {
 return containsOnlyPackages(Sets.newHashSet(packageNames));
}
origin: org.apache.beam/beam-sdks-java-core

/** Returns an {@link ApiSurface} object representing just the surface of the given class. */
public static ApiSurface ofClass(Class<?> clazz) {
 return ApiSurface.empty().includingClass(clazz);
}
origin: org.apache.beam/beam-sdks-java-extensions-google-cloud-platform-core

 @Test
 public void testGcpCoreApiSurface() throws Exception {
  final Package thisPackage = getClass().getPackage();
  final ClassLoader thisClassLoader = getClass().getClassLoader();
  final ApiSurface apiSurface =
    ApiSurface.ofPackage(thisPackage, thisClassLoader)
      .pruningPattern("org[.]apache[.]beam[.].*Test.*")
      .pruningPattern("org[.]apache[.]beam[.].*IT")
      .pruningPattern("java[.]lang.*")
      .pruningPattern("java[.]util.*");

  @SuppressWarnings("unchecked")
  final Set<Matcher<Class<?>>> allowedClasses =
    ImmutableSet.of(
      classesInPackage("com.google.api.client.googleapis"),
      classesInPackage("com.google.api.client.http"),
      classesInPackage("com.google.api.client.json"),
      classesInPackage("com.google.api.client.util"),
      classesInPackage("com.google.api.services.storage"),
      classesInPackage("com.google.auth"),
      classesInPackage("com.fasterxml.jackson.annotation"),
      classesInPackage("java"),
      classesInPackage("javax"),
      classesInPackage("org.apache.beam.sdk"),
      classesInPackage("org.joda.time"));

  assertThat(apiSurface, containsOnlyClassesMatching(allowedClasses));
 }
}
origin: org.apache.beam/beam-runners-direct-java

final ClassLoader thisClassLoader = getClass().getClassLoader();
ApiSurface apiSurface =
  ApiSurface.ofPackage(thisPackage, thisClassLoader)
    .pruningClass(Pipeline.class)
    .pruningClass(PipelineRunner.class)
    .pruningClass(PipelineOptions.class)
    .pruningClass(PipelineOptionsRegistrar.class)
    .pruningClass(PipelineOptions.DirectRunner.class)
    .pruningClass(DisplayData.Builder.class)
    .pruningClass(MetricResults.class)
    .pruningClass(DirectGraphs.class)
    .pruningClass(
      WatermarkManager.class /* TODO: BEAM-4237 Consider moving to local-java */)
    .pruningClass(ExecutableGraphBuilder.class)
    .pruningPattern(
      "org[.]apache[.]beam[.]runners[.]direct[.]portable.*"
    .pruningPattern("org[.]apache[.]beam[.].*Test.*")
    .pruningPattern("org[.]apache[.]beam[.].*IT")
    .pruningPattern("java[.]io.*")
    .pruningPattern("java[.]lang.*")
    .pruningPattern("java[.]util.*");
assertThat(apiSurface, containsOnlyPackages(allowed));
origin: org.apache.beam/beam-sdks-java-core

@Test
public void testIgnoreAll() throws Exception {
 ApiSurface apiSurface =
   ApiSurface.ofClass(ExposedWildcardBound.class)
     .includingClass(Object.class)
     .includingClass(ApiSurface.class)
     .pruningPattern(".*");
 assertThat(apiSurface.getExposedClasses(), emptyIterable());
}
origin: org.apache.beam/beam-sdks-java-core

/** See {@link #pruningPattern(Pattern)}. */
public ApiSurface pruningPattern(String patternString) {
 return pruningPattern(Pattern.compile(patternString));
}
origin: org.apache.beam/beam-sdks-java-core

/** Returns an {@link ApiSurface} object representing the given package and all subpackages. */
public static ApiSurface ofPackage(Package aPackage, ClassLoader classLoader) throws IOException {
 return ofPackage(aPackage.getName(), classLoader);
}
origin: org.apache.beam/beam-sdks-java-core

@SuppressWarnings({"rawtypes", "unchecked"})
private void assertExposed(final Class classToExamine, final Class... exposedClasses) {
 final ApiSurface apiSurface = ApiSurface.ofClass(classToExamine).pruningPrefix("java");
 final ImmutableSet<Matcher<Class<?>>> allowed =
   FluentIterable.from(
       Iterables.concat(Sets.newHashSet(classToExamine), Sets.newHashSet(exposedClasses)))
     .transform(Matchers::<Class<?>>equalTo)
     .toSet();
 assertThat(apiSurface, containsOnlyClassesMatching(allowed));
}
origin: org.apache.beam/beam-sdks-java-core

@Test
public void testprunedPattern() throws Exception {
 ApiSurface apiSurface = ApiSurface.ofClass(NotPruned.class).pruningClass(PrunedPattern.class);
 assertThat(apiSurface.getExposedClasses(), containsInAnyOrder((Class) NotPruned.class));
}
origin: org.apache.beam/beam-sdks-java-core

/**
 * A factory method to create an {@link ApiSurface} matcher, producing a positive match if the
 * queried api surface contains classes ONLY from specified package names.
 */
public static Matcher<ApiSurface> containsOnlyPackages(final Set<String> packageNames) {
 final Function<String, Matcher<Class<?>>> packageNameToClassMatcher =
   ApiSurface::classesInPackage;
 final ImmutableSet<Matcher<Class<?>>> classesInPackages =
   FluentIterable.from(packageNames).transform(packageNameToClassMatcher).toSet();
 return containsOnlyClassesMatching(classesInPackages);
}
origin: org.apache.beam/beam-sdks-java-core

private boolean verifyNoDisallowed(
  final ApiSurface checkedApiSurface,
  final Set<Matcher<Class<?>>> allowedClasses,
  final Description mismatchDescription) {
 /* <helper_lambdas> */
 final Function<Class<?>, List<Class<?>>> toExposure = checkedApiSurface::getAnyExposurePath;
 final Maps.EntryTransformer<Class<?>, List<Class<?>>, String> toMessage =
   (aClass, exposure) ->
     aClass + " exposed via:\n\t\t" + Joiner.on("\n\t\t").join(exposure);
 final Predicate<Class<?>> disallowed = aClass -> !classIsAllowed(aClass, allowedClasses);
 /* </helper_lambdas> */
 final FluentIterable<Class<?>> disallowedClasses =
   FluentIterable.from(checkedApiSurface.getExposedClasses()).filter(disallowed);
 final ImmutableMap<Class<?>, List<Class<?>>> exposures =
   Maps.toMap(disallowedClasses, toExposure);
 final ImmutableList<String> messages =
   FluentIterable.from(Maps.transformEntries(exposures, toMessage).values())
     .toSortedList(Ordering.natural());
 if (!messages.isEmpty()) {
  mismatchDescription.appendText(
    "The following disallowed classes appeared on the API surface:\n\t"
      + Joiner.on("\n\t").join(messages));
 }
 return messages.isEmpty();
}
origin: org.apache.beam/beam-sdks-java-core

/**
 * Returns an {@link ApiSurface} like this one, but pruning references from the provided class.
 */
public ApiSurface pruningClass(Class<?> clazz) {
 return pruningClassName(clazz.getName());
}
origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform

ApiSurface.ofPackage(thisPackage, thisClassLoader)
  .pruningPattern(BigqueryMatcher.class.getName())
  .pruningPattern(BigqueryClient.class.getName())
  .pruningPattern("org[.]apache[.]beam[.].*Test.*")
  .pruningPattern("org[.]apache[.]beam[.].*IT")
  .pruningPattern("java[.]lang.*")
  .pruningPattern("java[.]util.*");
  classesInPackage("com.google.api.core"),
  classesInPackage("com.google.api.client.googleapis"),
  classesInPackage("com.google.api.client.http"),
  classesInPackage("com.google.api.client.json"),
  classesInPackage("com.google.api.client.util"),
  classesInPackage("com.google.api.services.bigquery.model"),
  classesInPackage("com.google.auth"),
  classesInPackage("com.google.bigtable.v2"),
  classesInPackage("com.google.cloud.bigtable.config"),
  classesInPackage("com.google.spanner.v1"),
  Matchers.equalTo(com.google.api.gax.rpc.ApiException.class),
  Matchers.<Class<?>>equalTo(com.google.api.gax.paging.Page.class),
  Matchers.<Class<?>>equalTo(com.google.cloud.Date.class),
  Matchers.<Class<?>>equalTo(com.google.cloud.Timestamp.class),
  classesInPackage("com.google.cloud.spanner"),
  classesInPackage("com.google.spanner.admin.database.v1"),
  classesInPackage("com.google.datastore.v1"),
  classesInPackage("com.google.protobuf"),
  classesInPackage("com.google.type"),
  classesInPackage("com.fasterxml.jackson.annotation"),
origin: org.apache.beam/beam-sdks-java-core

/**
 * Returns an {@link ApiSurface} like this one, but pruning transitive references from classes
 * whose full name (including package) begins with the provided prefix.
 */
public ApiSurface pruningPrefix(String prefix) {
 return pruningPattern(Pattern.compile(Pattern.quote(prefix) + ".*"));
}
origin: org.apache.beam/beam-sdks-java-core

FluentIterable.from(checkedApiSurface.getExposedClasses())
  .anyMatch(classMatcher::matches);
origin: org.apache.beam/beam-sdks-java-core

/** Returns an {@link ApiSurface} like this one, but pruning references from the named class. */
public ApiSurface pruningClassName(String className) {
 return pruningPattern(Pattern.compile(Pattern.quote(className)));
}
origin: org.apache.beam/beam-sdks-java-core

 @Test
 public void testSdkApiSurface() throws Exception {

  @SuppressWarnings("unchecked")
  final Set<String> allowed =
    ImmutableSet.of(
      "org.apache.beam",
      "com.fasterxml.jackson.annotation",
      "com.fasterxml.jackson.core",
      "com.fasterxml.jackson.databind",
      "org.apache.avro",
      "org.hamcrest",
      // via DataflowMatchers
      "org.codehaus.jackson",
      // via Avro
      "org.joda.time",
      "org.junit");

  assertThat(getSdkApiSurface(getClass().getClassLoader()), containsOnlyPackages(allowed));
 }
}
org.apache.beam.sdk.utilApiSurface

Javadoc

Represents the API surface of a package prefix. Used for accessing public classes, methods, and the types they reference, to control what dependencies are re-exported.

For the purposes of calculating the public API surface, exposure includes any public or protected occurrence of:

  • superclasses
  • interfaces implemented
  • actual type arguments to generic types
  • array component types
  • method return types
  • method parameter types
  • type variable bounds
  • wildcard bounds

Exposure is a transitive property. The resulting map excludes primitives and array classes themselves.

It is prudent (though not required) to prune prefixes like "java" via the builder method #pruningPrefix to halt the traversal so it does not uselessly catalog references that are not interesting.

Most used methods

  • ofPackage
    Returns an ApiSurface object representing the given package and all subpackages.
  • pruningPattern
    Returns an ApiSurface like this one, but pruning transitive references from classes whose full name
  • containsOnlyClassesMatching
    See ApiSurface#containsOnlyClassesMatching(Set).
  • containsOnlyPackages
    See ApiSurface#containsOnlyPackages(Set).
  • classesInPackage
    A factory method to create a Class matcher for classes residing in a given package.
  • getExposedClasses
    Returns exposed types in this set, including arrays and primitives as specified.
  • includingClass
    Returns an ApiSurface like this one, but also including the given class.
  • pruningClass
    Returns an ApiSurface like this one, but pruning references from the provided class.
  • pruningClassName
    Returns an ApiSurface like this one, but pruning references from the named class.
  • <init>
  • addExposedTypes
    See #addExposedTypes(Type,Class).
  • constructExposedToExposers
    See #getExposedToExposers.
  • addExposedTypes,
  • constructExposedToExposers,
  • constructPrunedPattern,
  • done,
  • empty,
  • exposed,
  • getAnyExposurePath,
  • getExposedInvokables,
  • getExposedToExposers,
  • getPrunedPattern

Popular in Java

  • Creating JSON documents from java classes using gson
  • setScale (BigDecimal)
  • getSharedPreferences (Context)
  • findViewById (Activity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now