<commit_before>/*
 * Copyright 2021 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.android.as.oss.networkusage.db;

import static java.util.Comparator.comparing;

import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.VisibleForTesting;
import androidx.room.Embedded;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import arcs.core.data.proto.PolicyProto;
import com.google.auto.value.AutoValue;
import com.google.auto.value.AutoValue.CopyAnnotations;
import com.google.common.base.Preconditions;
import com.ryanharter.auto.value.parcel.ParcelAdapter;
import com.ryanharter.auto.value.parcel.TypeAdapter;
import java.time.Instant;
import java.util.Comparator;

/** Room entity representing an entry of PCS's Network Usage Log. */
@AutoValue
@Entity(tableName = "NetworkUsageLog")
public abstract class NetworkUsageEntity implements Parcelable {

  /** Comparator for sorting by decreasing creation time. */
  public static final Comparator<NetworkUsageEntity> BY_LATEST_TIMESTAMP =
      comparing((NetworkUsageEntity arg) -> arg.creationTime(), Comparator.reverseOrder());

  @CopyAnnotations
  @PrimaryKey(autoGenerate = true)
  public abstract int id();

  @CopyAnnotations
  @Embedded
  public abstract ConnectionDetails connectionDetails();

  /** Required for HTTP and PIR downloads only. The download url. */
  public abstract String url();

  /** The success status of the download/upload. */
  public abstract Status status();

  /** The download/upload size in bytes. */
  public abstract long size();

  /** The instantaneous point of creation of the entry. */
  public abstract Instant creationTime();

  /** Required for FC_TRAINING events only. The policy that the query is compliant with. */
  @CopyAnnotations
  @ParcelAdapter(PolicyProtoTypeAdapter.class)
  public abstract PolicyProto policyProto();

  public static Builder builder() {
    return new AutoValue_NetworkUsageEntity.Builder();
  }

  @VisibleForTesting
  public abstract Builder toBuilder();
<commit_msg>Remove @VisibleForTesting from NetworkUsageEntity#toBuilder()<commit_after>/*
 * Copyright 2021 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.android.as.oss.networkusage.db;

import static java.util.Comparator.comparing;

import android.os.Parcel;
import android.os.Parcelable;
import androidx.room.Embedded;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import arcs.core.data.proto.PolicyProto;
import com.google.auto.value.AutoValue;
import com.google.auto.value.AutoValue.CopyAnnotations;
import com.google.common.base.Preconditions;
import com.ryanharter.auto.value.parcel.ParcelAdapter;
import com.ryanharter.auto.value.parcel.TypeAdapter;
import java.time.Instant;
import java.util.Comparator;

/** Room entity representing an entry of PCS's Network Usage Log. */
@AutoValue
@Entity(tableName = "NetworkUsageLog")
public abstract class NetworkUsageEntity implements Parcelable {

  /** Comparator for sorting by decreasing creation time. */
  public static final Comparator<NetworkUsageEntity> BY_LATEST_TIMESTAMP =
      comparing((NetworkUsageEntity arg) -> arg.creationTime(), Comparator.reverseOrder());

  @CopyAnnotations
  @PrimaryKey(autoGenerate = true)
  public abstract int id();

  @CopyAnnotations
  @Embedded
  public abstract ConnectionDetails connectionDetails();

  /** Required for HTTP and PIR downloads only. The download url. */
  public abstract String url();

  /** The success status of the download/upload. */
  public abstract Status status();

  /** The download/upload size in bytes. */
  public abstract long size();

  /** The instantaneous point of creation of the entry. */
  public abstract Instant creationTime();

  /** Required for FC_TRAINING events only. The policy that the query is compliant with. */
  @CopyAnnotations
  @ParcelAdapter(PolicyProtoTypeAdapter.class)
  public abstract PolicyProto policyProto();

  public static Builder builder() {
    return new AutoValue_NetworkUsageEntity.Builder();
  }

  public abstract Builder toBuilder();

{'fraction_non_alphanumeric': 0.08919182083739045, 'fraction_numerical': 0.00311587147030185, 'mean_word_length': 4.576547231270358, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6273222', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1339, 'n_words': 480}