<commit_before>package org.synyx.minos.core.web.menu;

import org.springframework.util.StringUtils;

import org.synyx.minos.util.Assert;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


/**
 * Class to define a {@link MenuItem}. Allows definition of basic properties like title, description and so on.
 * {@link MenuItem}s can be ordered using the {@code position} property. Title and description will be resolved via
 * {@link java.util.ResourceBundle}s.
 *
 * @author <NAME> - <EMAIL>
 * @author <NAME> - <EMAIL>
 */
public final class MenuItem implements Comparable<MenuItem> {

    public static final String PATH_SEPARATOR = "/";

    private static final String TITLE_POSTFIX = ".title";
    private static final String DESCRIPTION_POSTFIX = ".description";

    private final String id;
    private String path;

    private UrlResolver urlStrategy;
    private String title;
    private String description;
    private Integer position = 0;

    private List<String> permissions = new ArrayList<String>();

    private MenuItem(String id) {

        this.id = id;
    }

    public String getId() {

        return id;
    }


    /**
     * Returns the {@link UrlResolver} for the {@link MenuItem} shall link to.
     *
     * @return the {@link UrlResolver} of this
     */
    public UrlResolver getUrlResolver() {

        return urlStrategy;
    }


    /**
     * Returns the title of the {@link MenuItem}. Will be resolved against a resource bundle.
     *
     * @return the title
     */
    public String getTitle() {

        return title;
    }


    /**
     * Returns the description of the {@link MenuItem}.
     *
     * @return the description
     */
    public String getDescription() {

        return description;
    }


    /**
     * Returns the position of the menu item. 0 means first one.
     *
     * @return the position
     */
    public int getPosition() {

        return position;
    }


    /**
     * Returns the permission required to access this {@link MenuItem}. Includes permissions from parent menu items,
     * too.
     *
     * @return the permissions
     */
    public List<String> getPermissions() {

        return Collections.unmodifiableList(permissions);
    }


    @Override
    public int compareTo(MenuItem item) {

        return this.position.compareTo(item.getPosition());
    }


    @Override
    public String toString() {

        StringBuilder builder = new StringBuilder(title);
        builder.append(", URL: ").append("...who knows yet...");
        builder.append(", Position: ").append(position);
        builder.append(", Permissions: ").append(StringUtils.collectionToCommaDelimitedString(getPermissions()));

        return builder.toString();
    }


    @Override
    protected Object clone() throws CloneNotSupportedException {

        return typeSaveClone();
    }


    protected MenuItem typeSaveClone() {

        return deepCopy(this).build();
    }


    @Override
    public int hashCode() {

        return getPath().hashCode();
    }


    @Override
    public boolean equals(Object obj) {

        if (this == obj) {
            return true;
        }

        if (obj == null)
            return false;

        if (getClass() != obj.getClass())
            return false;

        MenuItem other = (MenuItem) obj;

        return other.path.equals(path);
    }


    public String getPath() {

        return path == null ? id : path;
    }<commit_msg>Code hygiene: Added curly braces to if statements where they were missing (IfStmtsMustUseBraces), refs #460<commit_after>package org.synyx.minos.core.web.menu;

import org.springframework.util.StringUtils;

import org.synyx.minos.util.Assert;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


/**
 * Class to define a {@link MenuItem}. Allows definition of basic properties like title, description and so on.
 * {@link MenuItem}s can be ordered using the {@code position} property. Title and description will be resolved via
 * {@link java.util.ResourceBundle}s.
 *
 * @author <NAME> - <EMAIL>
 * @author <NAME> - <EMAIL>
 */
public final class MenuItem implements Comparable<MenuItem> {

    public static final String PATH_SEPARATOR = "/";

    private static final String TITLE_POSTFIX = ".title";
    private static final String DESCRIPTION_POSTFIX = ".description";

    private final String id;
    private String path;

    private UrlResolver urlStrategy;
    private String title;
    private String description;
    private Integer position = 0;

    private List<String> permissions = new ArrayList<String>();

    private MenuItem(String id) {

        this.id = id;
    }

    public String getId() {

        return id;
    }


    /**
     * Returns the {@link UrlResolver} for the {@link MenuItem} shall link to.
     *
     * @return the {@link UrlResolver} of this
     */
    public UrlResolver getUrlResolver() {

        return urlStrategy;
    }


    /**
     * Returns the title of the {@link MenuItem}. Will be resolved against a resource bundle.
     *
     * @return the title
     */
    public String getTitle() {

        return title;
    }


    /**
     * Returns the description of the {@link MenuItem}.
     *
     * @return the description
     */
    public String getDescription() {

        return description;
    }


    /**
     * Returns the position of the menu item. 0 means first one.
     *
     * @return the position
     */
    public int getPosition() {

        return position;
    }


    /**
     * Returns the permission required to access this {@link MenuItem}. Includes permissions from parent menu items,
     * too.
     *
     * @return the permissions
     */
    public List<String> getPermissions() {

        return Collections.unmodifiableList(permissions);
    }


    @Override
    public int compareTo(MenuItem item) {

        return this.position.compareTo(item.getPosition());
    }


    @Override
    public String toString() {

        StringBuilder builder = new StringBuilder(title);
        builder.append(", URL: ").append("...who knows yet...");
        builder.append(", Position: ").append(position);
        builder.append(", Permissions: ").append(StringUtils.collectionToCommaDelimitedString(getPermissions()));

        return builder.toString();
    }


    @Override
    protected Object clone() throws CloneNotSupportedException {

        return typeSaveClone();
    }


    protected MenuItem typeSaveClone() {

        return deepCopy(this).build();
    }


    @Override
    public int hashCode() {

        return getPath().hashCode();
    }


    @Override
    public boolean equals(Object obj) {

        if (this == obj) {
            return true;
        }

        if (obj == null) {
            return false;
        }

        if (getClass() != obj.getClass()) {
            return false;
        }

        MenuItem other = (MenuItem) obj;

        return other.path.equals(path);
    }


    public String getPath() {

        return path == null ? id : path;
    }
{'fraction_non_alphanumeric': 0.10372565622353937, 'fraction_numerical': 0.0009878633926051368, 'mean_word_length': 2.3892874222859875, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '6079953', 'n_tokens_mistral': 1974, 'n_tokens_neox': 1868, 'n_words': 604}