Search in sources :

Example 1 with JavaPackageMetadataNamer

use of com.google.api.codegen.transformer.java.JavaPackageMetadataNamer in project toolkit by googleapis.

the class JavaPackageMetadataTransformer method generateMetadataViewBuilders.

/**
 * Creates a partially initialized builders that can be used to build PackageMetadataViews later.
 */
protected final List<PackageMetadataView.Builder> generateMetadataViewBuilders(ApiModel model, PackageMetadataConfig config, ArtifactType artifactType) {
    JavaPackageMetadataNamer namer = new JavaPackageMetadataNamer(config.packageName(TargetLanguage.JAVA), artifactType);
    List<PackageDependencyView> additionalDependencies = new ArrayList<>();
    if (!SERVICES_WITH_NO_RESOURCE_NAMES.contains(config.shortName())) {
        PackageDependencyView packageDependency = PackageDependencyView.newBuilder().group("com.google.api").name("api-common").versionBound(config.apiCommonVersionBound(TargetLanguage.JAVA)).build();
        additionalDependencies.add(packageDependency);
    }
    ArrayList<PackageMetadataView.Builder> viewBuilders = new ArrayList<>();
    for (Map.Entry<String, String> entry : getSnippetsOutput().entrySet()) {
        PackageMetadataView.Builder viewBuilder = metadataTransformer.generateMetadataView(namer, config, model, entry.getKey(), entry.getValue(), TargetLanguage.JAVA).additionalDependencies(additionalDependencies).identifier(namer.getMetadataIdentifier()).protoPackageName(namer.getProtoPackageName()).grpcPackageName(namer.getGrpcPackageName()).publishProtos(artifactType == ArtifactType.PROTOBUF);
        viewBuilders.add(viewBuilder);
    }
    return viewBuilders;
}
Also used : JavaPackageMetadataNamer(com.google.api.codegen.transformer.java.JavaPackageMetadataNamer) ArrayList(java.util.ArrayList) PackageMetadataView(com.google.api.codegen.viewmodel.metadata.PackageMetadataView) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) PackageDependencyView(com.google.api.codegen.viewmodel.metadata.PackageDependencyView)

Example 2 with JavaPackageMetadataNamer

use of com.google.api.codegen.transformer.java.JavaPackageMetadataNamer in project toolkit by googleapis.

the class JavaPackageTransformer method generateMetadataViewBuilders.

/**
 * Creates a partially initialized builders that can be used to build PackageMetadataViews later.
 */
protected final List<PackageMetadataView.Builder> generateMetadataViewBuilders(ApiModel model, PackageMetadataConfig config, PackagingArtifactType artifactType) {
    String packageName = config.packageName();
    JavaPackageMetadataNamer namer = new JavaPackageMetadataNamer(packageName, artifactType);
    List<PackageDependencyView> additionalDependencies = new ArrayList<>();
    if (!SERVICES_WITH_NO_RESOURCE_NAMES.contains(config.shortName())) {
        PackageDependencyView packageDependency = PackageDependencyView.newBuilder().group("com.google.api").name("api-common").versionBound(config.apiCommonVersionBound(TargetLanguage.JAVA)).build();
        additionalDependencies.add(packageDependency);
    }
    ArrayList<PackageMetadataView.Builder> viewBuilders = new ArrayList<>();
    for (Map.Entry<String, String> entry : getSnippetsOutput().entrySet()) {
        PackageMetadataView.Builder viewBuilder = metadataTransformer.generateMetadataView(namer, config, model, entry.getKey(), entry.getValue(), TargetLanguage.JAVA).additionalDependencies(additionalDependencies).packageName(packageName).identifier(namer.getMetadataIdentifier()).protoPackageName(namer.getProtoPackageName()).grpcPackageName(namer.getGrpcPackageName()).publishProtos(artifactType == PackagingArtifactType.PROTOBUF);
        viewBuilders.add(viewBuilder);
    }
    return viewBuilders;
}
Also used : JavaPackageMetadataNamer(com.google.api.codegen.transformer.java.JavaPackageMetadataNamer) ArrayList(java.util.ArrayList) PackageMetadataView(com.google.api.codegen.viewmodel.metadata.PackageMetadataView) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) PackageDependencyView(com.google.api.codegen.viewmodel.metadata.PackageDependencyView)

Aggregations

JavaPackageMetadataNamer (com.google.api.codegen.transformer.java.JavaPackageMetadataNamer)2 PackageDependencyView (com.google.api.codegen.viewmodel.metadata.PackageDependencyView)2 PackageMetadataView (com.google.api.codegen.viewmodel.metadata.PackageMetadataView)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2