<commit_before>/*
 * DBeaver - Universal Database Manager
 * Copyright (C) 2010-2020 DBeaver Corp and others
 *
 * 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 org.jkiss.dbeaver.model.data;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.exec.DBCLogicalOperator;
import org.jkiss.utils.ArrayUtils;
import org.jkiss.utils.CommonUtils;

import java.util.Arrays;

/**
 * Attribute constraint
 */
public class DBDAttributeConstraintBase {

    public static int NULL_VISUAL_POSITION = -1;

    private int orderPosition;
    private boolean orderDescending;

    @Nullable
    private String criteria;
    @Nullable
    private DBCLogicalOperator operator;
    private boolean reverseOperator;
    @Nullable
    private Object value;

    private boolean visible;
    private int visualPosition;

    // Used to generate expressions
    @Nullable
    private String entityAlias;

    @Nullable
    private Object[] options;

    public DBDAttributeConstraintBase() {
    }

    public DBDAttributeConstraintBase(@NotNull DBDAttributeConstraintBase source) {
        copyFrom(source);
    }

    public void copyFrom(@NotNull DBDAttributeConstraintBase source) {
        this.orderPosition = source.orderPosition;
        this.orderDescending = source.orderDescending;
        this.criteria = source.criteria;
        this.operator = source.operator;
        this.reverseOperator = source.reverseOperator;
        this.value = source.value;
        this.visible = source.visible;
        this.visualPosition = source.visualPosition;
        this.options = source.options;
    }

    public int getOrderPosition() {
        return orderPosition;
    }

    public void setOrderPosition(int orderPosition) {
        this.orderPosition = orderPosition;
    }

    public boolean isOrderDescending() {
        return orderDescending;
    }

    public void setOrderDescending(boolean orderDescending) {
        this.orderDescending = orderDescending;
    }

    @Nullable
    public String getCriteria() {
        return criteria;
    }

    public void setCriteria(@Nullable String criteria) {
        this.criteria = criteria;
        this.operator = null;
        this.reverseOperator = false;
        this.value = null;
    }

    @Nullable
    public DBCLogicalOperator getOperator() {
        return operator;
    }

    public void setOperator(@Nullable DBCLogicalOperator operator) {
        this.criteria = null;
        this.operator = operator;
    }

    public boolean isReverseOperator() {
        return reverseOperator;
    }

    public void setReverseOperator(boolean reverseOperator) {
        this.reverseOperator = reverseOperator;
    }

    @Nullable
    public Object getValue() {
        return value;
    }

    public void setValue(@Nullable Object value) {
        this.criteria = null;
        this.value = value;
    }

    public boolean hasFilter() {
        return hasCondition();
    }

    public boolean isDirty() {
        return hasFilter() || !visible || orderPosition > 0 || !ArrayUtils.isEmpty(options);
    }

    public boolean hasCondition() {
        return !CommonUtils.isEmpty(criteria) || operator != null;<commit_msg>#9632 Ordering check fixed<commit_after>/*
 * DBeaver - Universal Database Manager
 * Copyright (C) 2010-2020 DBeaver Corp and others
 *
 * 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 org.jkiss.dbeaver.model.data;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.exec.DBCLogicalOperator;
import org.jkiss.utils.ArrayUtils;
import org.jkiss.utils.CommonUtils;

import java.util.Arrays;

/**
 * Attribute constraint
 */
public class DBDAttributeConstraintBase {

    public static int NULL_VISUAL_POSITION = -1;

    private int orderPosition;
    private boolean orderDescending;

    @Nullable
    private String criteria;
    @Nullable
    private DBCLogicalOperator operator;
    private boolean reverseOperator;
    @Nullable
    private Object value;

    private boolean visible;
    private int visualPosition;

    // Used to generate expressions
    @Nullable
    private String entityAlias;

    @Nullable
    private Object[] options;

    public DBDAttributeConstraintBase() {
    }

    public DBDAttributeConstraintBase(@NotNull DBDAttributeConstraintBase source) {
        copyFrom(source);
    }

    public void copyFrom(@NotNull DBDAttributeConstraintBase source) {
        this.orderPosition = source.orderPosition;
        this.orderDescending = source.orderDescending;
        this.criteria = source.criteria;
        this.operator = source.operator;
        this.reverseOperator = source.reverseOperator;
        this.value = source.value;
        this.visible = source.visible;
        this.visualPosition = source.visualPosition;
        this.options = source.options;
    }

    public int getOrderPosition() {
        return orderPosition;
    }

    public void setOrderPosition(int orderPosition) {
        this.orderPosition = orderPosition;
    }

    public boolean isOrderDescending() {
        return orderDescending;
    }

    public void setOrderDescending(boolean orderDescending) {
        this.orderDescending = orderDescending;
    }

    @Nullable
    public String getCriteria() {
        return criteria;
    }

    public void setCriteria(@Nullable String criteria) {
        this.criteria = criteria;
        this.operator = null;
        this.reverseOperator = false;
        this.value = null;
    }

    @Nullable
    public DBCLogicalOperator getOperator() {
        return operator;
    }

    public void setOperator(@Nullable DBCLogicalOperator operator) {
        this.criteria = null;
        this.operator = operator;
    }

    public boolean isReverseOperator() {
        return reverseOperator;
    }

    public void setReverseOperator(boolean reverseOperator) {
        this.reverseOperator = reverseOperator;
    }

    @Nullable
    public Object getValue() {
        return value;
    }

    public void setValue(@Nullable Object value) {
        this.criteria = null;
        this.value = value;
    }

    public boolean hasFilter() {
        return hasCondition() || orderPosition > 0 || !ArrayUtils.isEmpty(options);
    }

    public boolean isDirty() {
        return hasFilter() || !visible;
    }

    public boolean hasCondition() {
        return !CommonUtils.isEmpty(criteria) || operator != null;
{'fraction_non_alphanumeric': 0.07840772014475271, 'fraction_numerical': 0.0042889693070633965, 'mean_word_length': 2.910901467505241, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5401153', 'n_tokens_mistral': 1988, 'n_tokens_neox': 1912, 'n_words': 574}