<commit_before>package com.imcode.imcms.persistence.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "category_types")
public class CategoryType implements Cloneable, Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "category_type_id")
    private Integer id;

    @NotNull
    private String name;

    @Min(value = 0)
    @Max(value = 1)
    @Column(name = "max_choices", nullable = false)
    private int maxChoices;

    @NotNull
    private boolean inherited;

    @Column(name = "is_image_archive", nullable = false)
    private boolean imageArchive;

    @OneToMany(mappedBy = "type", fetch = FetchType.LAZY)
    private List<CategoryJPA> categories;

    public CategoryType(String name, int maxChoices, boolean inherited, boolean imageArchive) {
        this(null, name, maxChoices, inherited, imageArchive);
    }

    public CategoryType(Integer id, String name, int maxChoices, boolean inherited, boolean imageArchive) {
        this(id, name, maxChoices, inherited, imageArchive, null);
    }

    @Override
    public CategoryType clone() {
        try {
            return (CategoryType) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new AssertionError(e);
        }
    }

    /**
     * Checks whether category type is multi select. Can be only 0 or 1.
     * {@link #maxChoices} = 0 - is multi select
     * {@link #maxChoices} = 1 - is single select
     *
     * @return is category type contains one or more categories
     */
    @JsonIgnore
    @Transient
    public boolean isMultiSelect() {
        return maxChoices == 0;
    }

}<commit_msg>IMCMS-255 - Upgrade server side to work with new client: - Simplified CategoryType class.<commit_after>package com.imcode.imcms.persistence.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "category_types")
public class CategoryType {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "category_type_id")
    private Integer id;

    @NotNull
    private String name;

    @Min(value = 0)
    @Max(value = 1)
    @Column(name = "max_choices", nullable = false)
    private int maxChoices;

    @NotNull
    private boolean inherited;

    @Column(name = "is_image_archive", nullable = false)
    private boolean imageArchive;

    @OneToMany(mappedBy = "type", fetch = FetchType.LAZY)
    private List<CategoryJPA> categories;

    public CategoryType(String name, int maxChoices, boolean inherited, boolean imageArchive) {
        this(null, name, maxChoices, inherited, imageArchive);
    }

    public CategoryType(Integer id, String name, int maxChoices, boolean inherited, boolean imageArchive) {
        this(id, name, maxChoices, inherited, imageArchive, null);
    }

    /**
     * Checks whether category type is multi select. Can be only 0 or 1.
     * {@link #maxChoices} = 0 - is multi select
     * {@link #maxChoices} = 1 - is single select
     *
     * @return is category type contains one or more categories
     */
    @JsonIgnore
    @Transient
    public boolean isMultiSelect() {
        return maxChoices == 0;
    }

}
{'fraction_non_alphanumeric': 0.09527518172377986, 'fraction_numerical': 0.004413291796469367, 'mean_word_length': 3.527614571092832, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1088927', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1106, 'n_words': 316}