<commit_before>/* Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.api.codegen.packagegen.java;

import com.google.api.codegen.common.TargetLanguage;
import com.google.api.codegen.config.ApiModel;
import com.google.api.codegen.config.PackageMetadataConfig;
import com.google.api.codegen.packagegen.PackagingArtifactType;
import com.google.api.codegen.transformer.PackageMetadataTransformer;
import com.google.api.codegen.transformer.java.JavaPackageMetadataNamer;
import com.google.api.codegen.viewmodel.metadata.PackageDependencyView;
import com.google.api.codegen.viewmodel.metadata.PackageMetadataView;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/** Responsible for producing packaging related views for Java */
public class JavaPackageTransformer {
  // TODO determine if an API uses resource names from GAPIC config
  // https://github.com/googleapis/toolkit/issues/1668
  private ImmutableSet<String> SERVICES_WITH_NO_RESOURCE_NAMES =
      ImmutableSet.of("common-protos", "language", "speech", "video-intelligence", "vision");

  private final PackageMetadataTransformer metadataTransformer = new PackageMetadataTransformer();
  private final Map<String, String> snippetsOutput;
  private final PackagingArtifactType artifactType;

  public JavaPackageTransformer(
      Map<String, String> snippetsOutput, PackagingArtifactType artifactType) {
    this.snippetsOutput = ImmutableMap.copyOf(snippetsOutput);
    this.artifactType = artifactType;
  }

  protected Map<String, String> getSnippetsOutput() {
    return snippetsOutput;
  }

  public List<PackageMetadataView> transform(ApiModel model, PackageMetadataConfig config) {
    List<PackageMetadataView> views = new ArrayList<>();
    for (PackageMetadataView.Builder builder :
        generateMetadataViewBuilders(model, config, artifactType)) {
      views.add(builder.build());
    }
    return views;
  }

  /**
   * Creates a partially initialized builders that can be used to build PackageMetadataViews later.
   */
  protected final List<PackageMetadataView.Builder> generateMetadataViewBuilders(<commit_msg>Vision will be adding resource names (#2085)<commit_after>/* Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.api.codegen.packagegen.java;

import com.google.api.codegen.common.TargetLanguage;
import com.google.api.codegen.config.ApiModel;
import com.google.api.codegen.config.PackageMetadataConfig;
import com.google.api.codegen.packagegen.PackagingArtifactType;
import com.google.api.codegen.transformer.PackageMetadataTransformer;
import com.google.api.codegen.transformer.java.JavaPackageMetadataNamer;
import com.google.api.codegen.viewmodel.metadata.PackageDependencyView;
import com.google.api.codegen.viewmodel.metadata.PackageMetadataView;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/** Responsible for producing packaging related views for Java */
public class JavaPackageTransformer {
  // TODO determine if an API uses resource names from GAPIC config
  // https://github.com/googleapis/toolkit/issues/1668
  private ImmutableSet<String> SERVICES_WITH_NO_RESOURCE_NAMES =
      ImmutableSet.of("common-protos", "language", "speech", "video-intelligence");

  private final PackageMetadataTransformer metadataTransformer = new PackageMetadataTransformer();
  private final Map<String, String> snippetsOutput;
  private final PackagingArtifactType artifactType;

  public JavaPackageTransformer(
      Map<String, String> snippetsOutput, PackagingArtifactType artifactType) {
    this.snippetsOutput = ImmutableMap.copyOf(snippetsOutput);
    this.artifactType = artifactType;
  }

  protected Map<String, String> getSnippetsOutput() {
    return snippetsOutput;
  }

  public List<PackageMetadataView> transform(ApiModel model, PackageMetadataConfig config) {
    List<PackageMetadataView> views = new ArrayList<>();
    for (PackageMetadataView.Builder builder :
        generateMetadataViewBuilders(model, config, artifactType)) {
      views.add(builder.build());
    }
    return views;
  }

  /**
   * Creates a partially initialized builders that can be used to build PackageMetadataViews later.
   */
  protected final List<PackageMetadataView.Builder> generateMetadataViewBuilders(
{'fraction_non_alphanumeric': 0.0857812218417733, 'fraction_numerical': 0.005045954225986664, 'mean_word_length': 5.0064935064935066, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5399280', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1451, 'n_words': 424}