All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.gerrit.server.account.Preferences Maven / Gradle / Ivy

There is a newer version: 3.10.0
Show newest version
// Copyright (C) 2019 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.account;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace;
import com.google.gerrit.extensions.client.EditPreferencesInfo;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DateFormat;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DefaultBase;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DiffView;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DownloadCommand;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailFormat;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.TimeFormat;
import com.google.gerrit.extensions.client.KeyMapType;
import com.google.gerrit.extensions.client.MenuItem;
import com.google.gerrit.extensions.client.Theme;
import java.util.Optional;

@AutoValue
public abstract class Preferences {
  @AutoValue
  public abstract static class General {
    public abstract Optional changesPerPage();

    public abstract Optional downloadScheme();

    public abstract Optional downloadCommand();

    public abstract Optional dateFormat();

    public abstract Optional timeFormat();

    public abstract Optional expandInlineDiffs();

    public abstract Optional highlightAssigneeInChangeTable();

    public abstract Optional relativeDateInChangeTable();

    public abstract Optional diffView();

    public abstract Optional sizeBarInChangeTable();

    public abstract Optional legacycidInChangeTable();

    public abstract Optional muteCommonPathPrefixes();

    public abstract Optional signedOffBy();

    public abstract Optional emailStrategy();

    public abstract Optional emailFormat();

    public abstract Optional defaultBaseForMerges();

    public abstract Optional publishCommentsOnPush();

    public abstract Optional workInProgressByDefault();

    public abstract Optional> my();

    public abstract Optional> changeTable();

    @AutoValue.Builder
    public abstract static class Builder {
      abstract Builder changesPerPage(@Nullable Integer val);

      abstract Builder downloadScheme(@Nullable String val);

      abstract Builder downloadCommand(@Nullable DownloadCommand val);

      abstract Builder dateFormat(@Nullable DateFormat val);

      abstract Builder timeFormat(@Nullable TimeFormat val);

      abstract Builder expandInlineDiffs(@Nullable Boolean val);

      abstract Builder highlightAssigneeInChangeTable(@Nullable Boolean val);

      abstract Builder relativeDateInChangeTable(@Nullable Boolean val);

      abstract Builder diffView(@Nullable DiffView val);

      abstract Builder sizeBarInChangeTable(@Nullable Boolean val);

      abstract Builder legacycidInChangeTable(@Nullable Boolean val);

      abstract Builder muteCommonPathPrefixes(@Nullable Boolean val);

      abstract Builder signedOffBy(@Nullable Boolean val);

      abstract Builder emailStrategy(@Nullable EmailStrategy val);

      abstract Builder emailFormat(@Nullable EmailFormat val);

      abstract Builder defaultBaseForMerges(@Nullable DefaultBase val);

      abstract Builder publishCommentsOnPush(@Nullable Boolean val);

      abstract Builder workInProgressByDefault(@Nullable Boolean val);

      abstract Builder my(@Nullable ImmutableList val);

      abstract Builder changeTable(@Nullable ImmutableList val);

      abstract General build();
    }

    public static General fromInfo(GeneralPreferencesInfo info) {
      return (new AutoValue_Preferences_General.Builder())
          .changesPerPage(info.changesPerPage)
          .downloadScheme(info.downloadScheme)
          .downloadCommand(info.downloadCommand)
          .dateFormat(info.dateFormat)
          .timeFormat(info.timeFormat)
          .expandInlineDiffs(info.expandInlineDiffs)
          .highlightAssigneeInChangeTable(info.highlightAssigneeInChangeTable)
          .relativeDateInChangeTable(info.relativeDateInChangeTable)
          .diffView(info.diffView)
          .sizeBarInChangeTable(info.sizeBarInChangeTable)
          .legacycidInChangeTable(info.legacycidInChangeTable)
          .muteCommonPathPrefixes(info.muteCommonPathPrefixes)
          .signedOffBy(info.signedOffBy)
          .emailStrategy(info.emailStrategy)
          .emailFormat(info.emailFormat)
          .defaultBaseForMerges(info.defaultBaseForMerges)
          .publishCommentsOnPush(info.publishCommentsOnPush)
          .workInProgressByDefault(info.workInProgressByDefault)
          .my(info.my == null ? null : ImmutableList.copyOf(info.my))
          .changeTable(info.changeTable == null ? null : ImmutableList.copyOf(info.changeTable))
          .build();
    }

    public GeneralPreferencesInfo toInfo() {
      GeneralPreferencesInfo info = new GeneralPreferencesInfo();
      info.changesPerPage = changesPerPage().orElse(null);
      info.downloadScheme = downloadScheme().orElse(null);
      info.downloadCommand = downloadCommand().orElse(null);
      info.dateFormat = dateFormat().orElse(null);
      info.timeFormat = timeFormat().orElse(null);
      info.expandInlineDiffs = expandInlineDiffs().orElse(null);
      info.highlightAssigneeInChangeTable = highlightAssigneeInChangeTable().orElse(null);
      info.relativeDateInChangeTable = relativeDateInChangeTable().orElse(null);
      info.diffView = diffView().orElse(null);
      info.sizeBarInChangeTable = sizeBarInChangeTable().orElse(null);
      info.legacycidInChangeTable = legacycidInChangeTable().orElse(null);
      info.muteCommonPathPrefixes = muteCommonPathPrefixes().orElse(null);
      info.signedOffBy = signedOffBy().orElse(null);
      info.emailStrategy = emailStrategy().orElse(null);
      info.emailFormat = emailFormat().orElse(null);
      info.defaultBaseForMerges = defaultBaseForMerges().orElse(null);
      info.publishCommentsOnPush = publishCommentsOnPush().orElse(null);
      info.workInProgressByDefault = workInProgressByDefault().orElse(null);
      info.my = my().orElse(null);
      info.changeTable = changeTable().orElse(null);
      return info;
    }
  }

  @AutoValue
  public abstract static class Edit {
    public abstract Optional tabSize();

    public abstract Optional lineLength();

    public abstract Optional indentUnit();

    public abstract Optional cursorBlinkRate();

    public abstract Optional hideTopMenu();

    public abstract Optional showTabs();

    public abstract Optional showWhitespaceErrors();

    public abstract Optional syntaxHighlighting();

    public abstract Optional hideLineNumbers();

    public abstract Optional matchBrackets();

    public abstract Optional lineWrapping();

    public abstract Optional indentWithTabs();

    public abstract Optional autoCloseBrackets();

    public abstract Optional showBase();

    public abstract Optional theme();

    public abstract Optional keyMapType();

    @AutoValue.Builder
    public abstract static class Builder {
      abstract Builder tabSize(@Nullable Integer val);

      abstract Builder lineLength(@Nullable Integer val);

      abstract Builder indentUnit(@Nullable Integer val);

      abstract Builder cursorBlinkRate(@Nullable Integer val);

      abstract Builder hideTopMenu(@Nullable Boolean val);

      abstract Builder showTabs(@Nullable Boolean val);

      abstract Builder showWhitespaceErrors(@Nullable Boolean val);

      abstract Builder syntaxHighlighting(@Nullable Boolean val);

      abstract Builder hideLineNumbers(@Nullable Boolean val);

      abstract Builder matchBrackets(@Nullable Boolean val);

      abstract Builder lineWrapping(@Nullable Boolean val);

      abstract Builder indentWithTabs(@Nullable Boolean val);

      abstract Builder autoCloseBrackets(@Nullable Boolean val);

      abstract Builder showBase(@Nullable Boolean val);

      abstract Builder theme(@Nullable Theme val);

      abstract Builder keyMapType(@Nullable KeyMapType val);

      abstract Edit build();
    }

    public static Edit fromInfo(EditPreferencesInfo info) {
      return (new AutoValue_Preferences_Edit.Builder())
          .tabSize(info.tabSize)
          .lineLength(info.lineLength)
          .indentUnit(info.indentUnit)
          .cursorBlinkRate(info.cursorBlinkRate)
          .hideTopMenu(info.hideTopMenu)
          .showTabs(info.showTabs)
          .showWhitespaceErrors(info.showWhitespaceErrors)
          .syntaxHighlighting(info.syntaxHighlighting)
          .hideLineNumbers(info.hideLineNumbers)
          .matchBrackets(info.matchBrackets)
          .lineWrapping(info.lineWrapping)
          .indentWithTabs(info.indentWithTabs)
          .autoCloseBrackets(info.autoCloseBrackets)
          .showBase(info.showBase)
          .theme(info.theme)
          .keyMapType(info.keyMapType)
          .build();
    }

    public EditPreferencesInfo toInfo() {
      EditPreferencesInfo info = new EditPreferencesInfo();
      info.tabSize = tabSize().orElse(null);
      info.lineLength = lineLength().orElse(null);
      info.indentUnit = indentUnit().orElse(null);
      info.cursorBlinkRate = cursorBlinkRate().orElse(null);
      info.hideTopMenu = hideTopMenu().orElse(null);
      info.showTabs = showTabs().orElse(null);
      info.showWhitespaceErrors = showWhitespaceErrors().orElse(null);
      info.syntaxHighlighting = syntaxHighlighting().orElse(null);
      info.hideLineNumbers = hideLineNumbers().orElse(null);
      info.matchBrackets = matchBrackets().orElse(null);
      info.lineWrapping = lineWrapping().orElse(null);
      info.indentWithTabs = indentWithTabs().orElse(null);
      info.autoCloseBrackets = autoCloseBrackets().orElse(null);
      info.showBase = showBase().orElse(null);
      info.theme = theme().orElse(null);
      info.keyMapType = keyMapType().orElse(null);
      return info;
    }
  }

  @AutoValue
  public abstract static class Diff {
    public abstract Optional context();

    public abstract Optional tabSize();

    public abstract Optional fontSize();

    public abstract Optional lineLength();

    public abstract Optional cursorBlinkRate();

    public abstract Optional expandAllComments();

    public abstract Optional intralineDifference();

    public abstract Optional manualReview();

    public abstract Optional showLineEndings();

    public abstract Optional showTabs();

    public abstract Optional showWhitespaceErrors();

    public abstract Optional syntaxHighlighting();

    public abstract Optional hideTopMenu();

    public abstract Optional autoHideDiffTableHeader();

    public abstract Optional hideLineNumbers();

    public abstract Optional renderEntireFile();

    public abstract Optional hideEmptyPane();

    public abstract Optional matchBrackets();

    public abstract Optional lineWrapping();

    public abstract Optional theme();

    public abstract Optional ignoreWhitespace();

    public abstract Optional retainHeader();

    public abstract Optional skipDeleted();

    public abstract Optional skipUnchanged();

    public abstract Optional skipUncommented();

    @AutoValue.Builder
    public abstract static class Builder {
      abstract Builder context(@Nullable Integer val);

      abstract Builder tabSize(@Nullable Integer val);

      abstract Builder fontSize(@Nullable Integer val);

      abstract Builder lineLength(@Nullable Integer val);

      abstract Builder cursorBlinkRate(@Nullable Integer val);

      abstract Builder expandAllComments(@Nullable Boolean val);

      abstract Builder intralineDifference(@Nullable Boolean val);

      abstract Builder manualReview(@Nullable Boolean val);

      abstract Builder showLineEndings(@Nullable Boolean val);

      abstract Builder showTabs(@Nullable Boolean val);

      abstract Builder showWhitespaceErrors(@Nullable Boolean val);

      abstract Builder syntaxHighlighting(@Nullable Boolean val);

      abstract Builder hideTopMenu(@Nullable Boolean val);

      abstract Builder autoHideDiffTableHeader(@Nullable Boolean val);

      abstract Builder hideLineNumbers(@Nullable Boolean val);

      abstract Builder renderEntireFile(@Nullable Boolean val);

      abstract Builder hideEmptyPane(@Nullable Boolean val);

      abstract Builder matchBrackets(@Nullable Boolean val);

      abstract Builder lineWrapping(@Nullable Boolean val);

      abstract Builder theme(@Nullable Theme val);

      abstract Builder ignoreWhitespace(@Nullable Whitespace val);

      abstract Builder retainHeader(@Nullable Boolean val);

      abstract Builder skipDeleted(@Nullable Boolean val);

      abstract Builder skipUnchanged(@Nullable Boolean val);

      abstract Builder skipUncommented(@Nullable Boolean val);

      abstract Diff build();
    }

    public static Diff fromInfo(DiffPreferencesInfo info) {
      return (new AutoValue_Preferences_Diff.Builder())
          .context(info.context)
          .tabSize(info.tabSize)
          .fontSize(info.fontSize)
          .lineLength(info.lineLength)
          .cursorBlinkRate(info.cursorBlinkRate)
          .expandAllComments(info.expandAllComments)
          .intralineDifference(info.intralineDifference)
          .manualReview(info.manualReview)
          .showLineEndings(info.showLineEndings)
          .showTabs(info.showTabs)
          .showWhitespaceErrors(info.showWhitespaceErrors)
          .syntaxHighlighting(info.syntaxHighlighting)
          .hideTopMenu(info.hideTopMenu)
          .autoHideDiffTableHeader(info.autoHideDiffTableHeader)
          .hideLineNumbers(info.hideLineNumbers)
          .renderEntireFile(info.renderEntireFile)
          .hideEmptyPane(info.hideEmptyPane)
          .matchBrackets(info.matchBrackets)
          .lineWrapping(info.lineWrapping)
          .theme(info.theme)
          .ignoreWhitespace(info.ignoreWhitespace)
          .retainHeader(info.retainHeader)
          .skipDeleted(info.skipDeleted)
          .skipUnchanged(info.skipUnchanged)
          .skipUncommented(info.skipUncommented)
          .build();
    }

    public DiffPreferencesInfo toInfo() {
      DiffPreferencesInfo info = new DiffPreferencesInfo();
      info.context = context().orElse(null);
      info.tabSize = tabSize().orElse(null);
      info.fontSize = fontSize().orElse(null);
      info.lineLength = lineLength().orElse(null);
      info.cursorBlinkRate = cursorBlinkRate().orElse(null);
      info.expandAllComments = expandAllComments().orElse(null);
      info.intralineDifference = intralineDifference().orElse(null);
      info.manualReview = manualReview().orElse(null);
      info.showLineEndings = showLineEndings().orElse(null);
      info.showTabs = showTabs().orElse(null);
      info.showWhitespaceErrors = showWhitespaceErrors().orElse(null);
      info.syntaxHighlighting = syntaxHighlighting().orElse(null);
      info.hideTopMenu = hideTopMenu().orElse(null);
      info.autoHideDiffTableHeader = autoHideDiffTableHeader().orElse(null);
      info.hideLineNumbers = hideLineNumbers().orElse(null);
      info.renderEntireFile = renderEntireFile().orElse(null);
      info.hideEmptyPane = hideEmptyPane().orElse(null);
      info.matchBrackets = matchBrackets().orElse(null);
      info.lineWrapping = lineWrapping().orElse(null);
      info.theme = theme().orElse(null);
      info.ignoreWhitespace = ignoreWhitespace().orElse(null);
      info.retainHeader = retainHeader().orElse(null);
      info.skipDeleted = skipDeleted().orElse(null);
      info.skipUnchanged = skipUnchanged().orElse(null);
      info.skipUncommented = skipUncommented().orElse(null);
      return info;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy