SuggestionResult class

Пакет: com.hypixel.hytale.server.core.command.system.suggestion

Файл: com/hypixel/hytale/server/core/command/system/suggestion/SuggestionResult.java

Поля (1)

МодификаторыТипИмя
final List<String> suggestions

Методы (4)

МодификаторыВозвратСигнатура
public boolean isFullboolean isFull()
public boolean isTruncatedboolean isTruncated()
public void markTruncatedvoid markTruncated()
abstract this this(Integer.MAX_VALUE)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.command.system.suggestion;

class="kw">import it.unimi.dsi.fastutil.objects.ObjectArrayList;
class="kw">import java.util.List;
class="kw">import java.util.function.Function;
class="kw">import javax.annotation.Nonnull;

class="kw">public class SuggestionResult {
   class="kw">private class="kw">final List<String> suggestions = new ObjectArrayList();
   class="kw">private class="kw">final List<Boolean> continuations = new ObjectArrayList();
   class="kw">private class="kw">final int maxSuggestions;
   class="kw">private boolean truncated;

   class="kw">public SuggestionResult() {
      this(Integer.MAX_VALUE);
   }

   class="kw">public SuggestionResult(int var1) {
      this.maxSuggestions = var1;
   }

   @Nonnull
   class="kw">public SuggestionResult suggest(@Nonnull String var1) {
      if (this.isFull()) {
         this.truncated = true;
         class="kw">return this;
      } else {
         this.suggestions.add(var1);
         this.continuations.add(false);
         class="kw">return this;
      }
   }

   @Nonnull
   class="kw">public SuggestionResult suggestContinuation(@Nonnull String var1) {
      if (this.isFull()) {
         this.truncated = true;
         class="kw">return this;
      } else {
         this.suggestions.add(var1);
         this.continuations.add(true);
         class="kw">return this;
      }
   }

   @Nonnull
   class="kw">public <DataType> SuggestionResult suggest(@Nonnull Function<DataType, String> var1, @Nonnull DataType var2) {
      class="kw">return this.suggest(var1.apply(var2));
   }

   @Nonnull
   class="kw">public SuggestionResult suggest(@Nonnull Object var1) {
      class="kw">return this.suggest(var1.toString());
   }

   @Nonnull
   class="kw">public List<String> getSuggestions() {
      class="kw">return this.suggestions;
   }

   @Nonnull
   class="kw">public List<Boolean> getContinuations() {
      class="kw">return this.continuations;
   }

   class="kw">public void markTruncated() {
      this.truncated = true;
   }

   class="kw">public boolean isTruncated() {
      class="kw">return this.truncated;
   }

   class="kw">public boolean isFull() {
      class="kw">return this.suggestions.size() >= this.maxSuggestions;
   }
}