// Path: src/main/java/com/google/cloud/solutions/datalineage/model/BigQueryTableEntity.java
// @AutoValue
// public abstract class BigQueryTableEntity implements DataEntityConvertible, Serializable {
// 
//   public abstract String getProjectId();
// 
//   public abstract String getDataset();
// 
//   public abstract String getTable();
// 
//   /**
//    * Returns {@code true} if the table is a temporary table.
//    * <p> It uses rule dataset name starts with '_' or table name starts with '_' or 'anon'.
//    */
//   public final boolean isTempTable() {
//     return getDataset().startsWith("_")
//         || getTable().startsWith("_")
//         || getTable().startsWith("anon");
//   }
// 
//   public static Builder builder() {
//     return new AutoValue_BigQueryTableEntity.Builder();
//   }
// 
//   public static BigQueryTableEntity create(String projectId, String dataset, String table) {
//     return builder()
//         .setProjectId(projectId)
//         .setDataset(dataset)
//         .setTable(table)
//         .build();
//   }
// 
//   @Override
//   public DataEntity dataEntity() {
//     return DataEntity.newBuilder()
//         .setKind(DataEntityTypes.BIGQUERY_TABLE)
//         .setLinkedResource(
//             String.format("//bigquery.googleapis.com/projects/%s/datasets/%s/tables/%s",
//                 getProjectId(),
//                 getDataset(),
//                 getTable()))
//         .setSqlResource(
//             String.format("bigquery.table.%s.%s.%s", getProjectId(), getDataset(), getTable()))
//         .build();
//   }
// 
//   public String getLegacySqlName() {
//     return String.format("%s:%s.%s", getProjectId(), getDataset(), getTable());
//   }
// 
//   public String getStandSqlName() {
//     return String.format("%s.%s.%s", getProjectId(), getDataset(), getTable());
//   }
// 
//   @AutoValue.Builder
//   public abstract static class Builder {
// 
//     public abstract Builder setProjectId(String projectId);
// 
//     public abstract Builder setDataset(String dataset);
// 
//     public abstract Builder setTable(String table);
// 
//     public abstract BigQueryTableEntity build();
//   }
// }


import com.google.cloud.solutions.datalineage.model.BigQueryTableEntity;
import com.google.common.collect.ImmutableList;
import com.google.common.flogger.GoogleLogger;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
 * Copyright 2020 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
 *
 *      http://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.cloud.solutions.datalineage.extractor;


/**
 * A Factory to create BigQuery table entity by parsing different naming formats.
 */
public abstract class BigQueryTableCreator {

  private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();

  /**
   * Matches the given String as a Legacy or Standard Table name. If no match found, it returns a
   *
   * @param bigQueryTableName the table name in legacy or standard SQL format.
   * @return Table information with valid values or if no match found then tableName set as the
   * input String or empty table name.
   */
  public static BigQueryTableEntity usingBestEffort(String bigQueryTableName) {
    if (bigQueryTableName != null && bigQueryTableName.startsWith("$")) {
// Path: src/main/java/com/google/cloud/solutions/datalineage/model/BigQueryTableEntity.java
// @AutoValue
// public abstract class BigQueryTableEntity implements DataEntityConvertible, Serializable {
// 
//   public abstract String getProjectId();
// 
//   public abstract String getDataset();
// 
//   public abstract String getTable();
// 
//   /**
//    * Returns {@code true} if the table is a temporary table.
//    * <p> It uses rule dataset name starts with '_' or table name starts with '_' or 'anon'.
//    */
//   public final boolean isTempTable() {
//     return getDataset().startsWith("_")
//         || getTable().startsWith("_")
//         || getTable().startsWith("anon");
//   }
// 
//   public static Builder builder() {
//     return new AutoValue_BigQueryTableEntity.Builder();
//   }
// 
//   public static BigQueryTableEntity create(String projectId, String dataset, String table) {
//     return builder()
//         .setProjectId(projectId)
//         .setDataset(dataset)
//         .setTable(table)
//         .build();
//   }
// 
//   @Override
//   public DataEntity dataEntity() {
//     return DataEntity.newBuilder()
//         .setKind(DataEntityTypes.BIGQUERY_TABLE)
//         .setLinkedResource(
//             String.format("//bigquery.googleapis.com/projects/%s/datasets/%s/tables/%s",
//                 getProjectId(),
//                 getDataset(),
//                 getTable()))
//         .setSqlResource(
//             String.format("bigquery.table.%s.%s.%s", getProjectId(), getDataset(), getTable()))
//         .build();
//   }
// 
//   public String getLegacySqlName() {
//     return String.format("%s:%s.%s", getProjectId(), getDataset(), getTable());
//   }
// 
//   public String getStandSqlName() {
//     return String.format("%s.%s.%s", getProjectId(), getDataset(), getTable());
//   }
// 
//   @AutoValue.Builder
//   public abstract static class Builder {
// 
//     public abstract Builder setProjectId(String projectId);
// 
//     public abstract Builder setDataset(String dataset);
// 
//     public abstract Builder setTable(String table);
// 
//     public abstract BigQueryTableEntity build();
//   }
// }


// Path: src/main/java/com/google/cloud/solutions/datalineage/extractor/BigQueryTableCreator.java
import com.google.cloud.solutions.datalineage.model.BigQueryTableEntity;
import com.google.common.collect.ImmutableList;
import com.google.common.flogger.GoogleLogger;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/*
 * Copyright 2020 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
 *
 *      http://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.cloud.solutions.datalineage.extractor;


/**
 * A Factory to create BigQuery table entity by parsing different naming formats.
 */
public abstract class BigQueryTableCreator {

  private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();

  /**
   * Matches the given String as a Legacy or Standard Table name. If no match found, it returns a
   *
   * @param bigQueryTableName the table name in legacy or standard SQL format.
   * @return Table information with valid values or if no match found then tableName set as the
   * input String or empty table name.
   */
  public static BigQueryTableEntity usingBestEffort(String bigQueryTableName) {
    if (bigQueryTableName != null && bigQueryTableName.startsWith("$")) {
      return BigQueryTableEntity.create(null, null, bigQueryTableName);