<commit_before>// Copyright (C) 2017 The Android Open Source Project
//
// 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.gerrit.server.group.db;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountGroup;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;

// TODO(aliceks): Add Javadoc descriptions to this file.
@AutoValue
public abstract class InternalGroupUpdate {
  public abstract Optional<AccountGroup.NameKey> getName();

  // TODO(aliceks): Mention empty string (not null!) -> unset value in Javadoc.
  public abstract Optional<String> getDescription();

  public abstract Optional<AccountGroup.UUID> getOwnerGroupUUID();

  public abstract Optional<Boolean> getVisibleToAll();

  public abstract Function<ImmutableSet<Account.Id>, ? extends Set<Account.Id>>
      getMemberModification();

  public abstract Function<ImmutableSet<AccountGroup.UUID>, ? extends Set<AccountGroup.UUID>>
      getSubgroupModification();

  public static Builder builder() {
    return new AutoValue_InternalGroupUpdate.Builder()
        .setMemberModification(Function.identity())
        .setSubgroupModification(Function.identity());
  }

  @AutoValue.Builder
  public abstract static class Builder {
    public abstract Builder setName(AccountGroup.NameKey name);

    public abstract Builder setDescription(String description);

    public abstract Builder setOwnerGroupUUID(AccountGroup.UUID ownerGroupUUID);

    public abstract Builder setVisibleToAll(boolean visibleToAll);

    public abstract Builder setMemberModification(
        Function<ImmutableSet<Account.Id>, ? extends Set<Account.Id>> memberModification);

    public abstract Builder setSubgroupModification(
        Function<ImmutableSet<AccountGroup.UUID>, ? extends Set<AccountGroup.UUID>>
            subgroupModification);<commit_msg>InternalGroupUpdate: Use named types for modification functions<commit_after>// Copyright (C) 2017 The Android Open Source Project
//
// 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.gerrit.server.group.db;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountGroup;
import java.util.Optional;
import java.util.Set;

// TODO(aliceks): Add Javadoc descriptions to this file.
@AutoValue
public abstract class InternalGroupUpdate {
  @FunctionalInterface
  public interface MemberModification {
    Set<Account.Id> apply(ImmutableSet<Account.Id> in);
  }

  @FunctionalInterface
  public interface SubgroupModification {
    Set<AccountGroup.UUID> apply(ImmutableSet<AccountGroup.UUID> in);
  }

  public abstract Optional<AccountGroup.NameKey> getName();

  // TODO(aliceks): Mention empty string (not null!) -> unset value in Javadoc.
  public abstract Optional<String> getDescription();

  public abstract Optional<AccountGroup.UUID> getOwnerGroupUUID();

  public abstract Optional<Boolean> getVisibleToAll();

  public abstract MemberModification getMemberModification();

  public abstract SubgroupModification getSubgroupModification();

  public static Builder builder() {
    return new AutoValue_InternalGroupUpdate.Builder()
        .setMemberModification(in -> in)
        .setSubgroupModification(in -> in);
  }

  @AutoValue.Builder
  public abstract static class Builder {
    public abstract Builder setName(AccountGroup.NameKey name);

    public abstract Builder setDescription(String description);

    public abstract Builder setOwnerGroupUUID(AccountGroup.UUID ownerGroupUUID);

    public abstract Builder setVisibleToAll(boolean visibleToAll);

    public abstract Builder setMemberModification(MemberModification memberModification);

    public abstract Builder setSubgroupModification(SubgroupModification subgroupModification);
{'fraction_non_alphanumeric': 0.08510212254705647, 'fraction_numerical': 0.0032038446135362435, 'mean_word_length': 4.7546082949308754, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 31, 'https://': 0, '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': '3139126', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1261, 'n_words': 417}