<commit_before>package com.faforever.client.query;

import com.faforever.client.fx.Controller;
import com.faforever.client.i18n.I18n;
import com.faforever.client.util.ProgrammingError;
import com.faforever.client.util.ReflectionUtil;
import com.github.rutledgepaulv.qbuilders.builders.QBuilder;
import com.github.rutledgepaulv.qbuilders.conditions.Condition;
import com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator;
import com.github.rutledgepaulv.qbuilders.properties.concrete.BooleanProperty;
import com.github.rutledgepaulv.qbuilders.properties.concrete.EnumProperty;
import com.github.rutledgepaulv.qbuilders.properties.concrete.InstantProperty;
import com.github.rutledgepaulv.qbuilders.properties.concrete.StringProperty;
import com.github.rutledgepaulv.qbuilders.properties.virtual.EquitableProperty;
import com.github.rutledgepaulv.qbuilders.properties.virtual.ListableProperty;
import com.github.rutledgepaulv.qbuilders.properties.virtual.NumberProperty;
import com.github.rutledgepaulv.qbuilders.properties.virtual.Property;
import com.google.common.collect.ImmutableMap;
import javafx.beans.binding.Bindings;
import javafx.collections.FXCollections;
import javafx.collections.transformation.FilteredList;
import javafx.scene.Node;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.layout.HBox;
import javafx.util.StringConverter;
import lombok.SneakyThrows;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;

import java.lang.reflect.ParameterizedType;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.Temporal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.EQ;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.GT;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.GTE;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.IN;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.LT;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.LTE;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.NE;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.NIN;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.RE;

/**
 * Controller for building a specification in the sense of Domain Driven Design, e.g. {@code login == "Someone"} or
 * {@code rating > 500}. The specification can then be converted into a condition to be used in a {@link QBuilder}.
 * Before it can be used, the type of the object to query has to be defined first by using {@link #setRootType(Class)}.
 * This controller consists of a property ChoiceBox, an operator ChoiceBox and a value field. The items available in the
 * operator ChoiceBox depend on the selected property and its respective type in the target class.
 */
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class SpecificationController implements Controller<Node> {

  private static final Map<ComparisonOperator, String> operatorToI18nKey = ImmutableMap.<ComparisonOperator, String>builder()
      .put(EQ, "query.equals")
      .put(NE, "query.notEquals")
      .put(GT, "query.greaterThan")
      .put(GTE, "query.greaterThanEquals")
      .put(LT, "query.lessThan")
      .put(LTE, "query.lessThanEquals")
      .put(IN, "query.in")
      .put(NIN, "query.notIn")
      .put(RE, "query.contains")
      .build();

  private static final Map<Class<?>, Collection<ComparisonOperator>> VALID_OPERATORS =
      ImmutableMap.<Class<?>, Collection<ComparisonOperator>>builder()
          .put(Number.class, Arrays.asList(EQ, NE, GT, GTE, LT, LTE, IN, NIN))<commit_msg>Move operator "query.contains" from end of ComparisonOperator map to beginning to make it default (first element in comboboxes is selected initially).<commit_after>package com.faforever.client.query;

import com.faforever.client.fx.Controller;
import com.faforever.client.i18n.I18n;
import com.faforever.client.util.ProgrammingError;
import com.faforever.client.util.ReflectionUtil;
import com.github.rutledgepaulv.qbuilders.builders.QBuilder;
import com.github.rutledgepaulv.qbuilders.conditions.Condition;
import com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator;
import com.github.rutledgepaulv.qbuilders.properties.concrete.BooleanProperty;
import com.github.rutledgepaulv.qbuilders.properties.concrete.EnumProperty;
import com.github.rutledgepaulv.qbuilders.properties.concrete.InstantProperty;
import com.github.rutledgepaulv.qbuilders.properties.concrete.StringProperty;
import com.github.rutledgepaulv.qbuilders.properties.virtual.EquitableProperty;
import com.github.rutledgepaulv.qbuilders.properties.virtual.ListableProperty;
import com.github.rutledgepaulv.qbuilders.properties.virtual.NumberProperty;
import com.github.rutledgepaulv.qbuilders.properties.virtual.Property;
import com.google.common.collect.ImmutableMap;
import javafx.beans.binding.Bindings;
import javafx.collections.FXCollections;
import javafx.collections.transformation.FilteredList;
import javafx.scene.Node;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.DatePicker;
import javafx.scene.layout.HBox;
import javafx.util.StringConverter;
import lombok.SneakyThrows;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;

import java.lang.reflect.ParameterizedType;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.Temporal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.EQ;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.GT;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.GTE;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.IN;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.LT;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.LTE;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.NE;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.NIN;
import static com.github.rutledgepaulv.qbuilders.operators.ComparisonOperator.RE;

/**
 * Controller for building a specification in the sense of Domain Driven Design, e.g. {@code login == "Someone"} or
 * {@code rating > 500}. The specification can then be converted into a condition to be used in a {@link QBuilder}.
 * Before it can be used, the type of the object to query has to be defined first by using {@link #setRootType(Class)}.
 * This controller consists of a property ChoiceBox, an operator ChoiceBox and a value field. The items available in the
 * operator ChoiceBox depend on the selected property and its respective type in the target class.
 */
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class SpecificationController implements Controller<Node> {

  private static final Map<ComparisonOperator, String> operatorToI18nKey = ImmutableMap.<ComparisonOperator, String>builder()
      .put(RE, "query.contains")
      .put(EQ, "query.equals")
      .put(NE, "query.notEquals")
      .put(GT, "query.greaterThan")
      .put(GTE, "query.greaterThanEquals")
      .put(LT, "query.lessThan")
      .put(LTE, "query.lessThanEquals")
      .put(IN, "query.in")
      .put(NIN, "query.notIn")
      .build();

  private static final Map<Class<?>, Collection<ComparisonOperator>> VALID_OPERATORS =
      ImmutableMap.<Class<?>, Collection<ComparisonOperator>>builder()
          .put(Number.class, Arrays.asList(EQ, NE, GT, GTE, LT, LTE, IN, NIN))
{'fraction_non_alphanumeric': 0.0996934256841149, 'fraction_numerical': 0.002043828772567276, 'mean_word_length': 6.018326693227092, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5045113', 'n_tokens_mistral': 2696, 'n_tokens_neox': 2611, 'n_words': 541}