<commit_before>/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.notifications.filters.internal;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.xwiki.notifications.NotificationFormat;
import org.xwiki.notifications.filters.NotificationFilterPreference;
import org.xwiki.notifications.filters.NotificationFilterType;
import org.xwiki.text.StringUtils;

/**
 * Default implementation of {@link NotificationFilterPreference}.
 *
 * @since 10.8RC1
 * @since 9.11.8
 * @version $Id $
 */
public class DefaultNotificationFilterPreference implements NotificationFilterPreference
{
    private static final String LIST_SEPARATOR = ",";

    private String id;

    private long internalId;

    private String owner;

    private String filterName;

    private String providerHint;

    private boolean enabled;

    private boolean active;

    private NotificationFilterType filterType;

    private Set<NotificationFormat> notificationFormats = new HashSet<>();

    private Date startingDate;

    private Set<String> eventTypes = new HashSet<>();

    private String user;

    private String pageOnly;

    private String page;

    private String wiki;

    /**
     * Construct an empty DefaultNotificationFilterPreference.
     */
    public DefaultNotificationFilterPreference()
    {

    }

    /**
     * Construct a DefaultNotificationFilterPreference which is a copy of the given notificationFilterPreference.
     * @param notificationFilterPreference object to copy
     */
    public DefaultNotificationFilterPreference(NotificationFilterPreference notificationFilterPreference)
    {
        if (notificationFilterPreference instanceof DefaultNotificationFilterPreference) {
            this.internalId = ((DefaultNotificationFilterPreference) notificationFilterPreference).internalId;
            this.owner = ((DefaultNotificationFilterPreference) notificationFilterPreference).owner;
        }

        this.id = notificationFilterPreference.getId();
        this.filterName = notificationFilterPreference.getFilterName();
        this.providerHint = notificationFilterPreference.getProviderHint();
        this.enabled = notificationFilterPreference.isEnabled();
        this.active = notificationFilterPreference.isActive();
        this.filterType = notificationFilterPreference.getFilterType();
        this.notificationFormats = notificationFilterPreference.getNotificationFormats();
        this.startingDate = notificationFilterPreference.getStartingDate();
        this.eventTypes = new HashSet<>(notificationFilterPreference.getEventTypes());
        this.user = notificationFilterPreference.getUser();
        this.pageOnly = notificationFilterPreference.getPageOnly();
        this.page = notificationFilterPreference.getPage();
        this.wiki = notificationFilterPreference.getWiki();

        this.setNotificationFormats(notificationFilterPreference.getNotificationFormats());
    }

    /**
     * @param id the unique identifier to set
     */
    public void setId(String id)
    {
        this.id = id;
    }

    /**
     * @return the internal id used to store the preference
     */
    public long getInternalId()
    {
        return internalId;
    }

    /**
     * @param internalId the internal id used to store the preference
     */
    public void setInternalId(long internalId)
    {
        this.internalId = internalId;
        this.id = String.format("NFP_%x", internalId);
    }

    /**
     * @return the owner of the preference
     */
    public String getOwner()
    {
        return owner;
    }

    /**
     * @param owner the owner of the preference
     */
    public void setOwner(String owner)
    {
        this.owner = owner;
    }

    /**
     * @param filterName the name of the filter concerned by the preference
     */
    public void setFilterName(String filterName)
    {
        this.filterName = filterName;
    }

    /**
     * @param providerHint the name of the provider that have built this preference
     */
    public void setProviderHint(String providerHint)
    {
        this.providerHint = providerHint;
    }

    /**
     * @param enabled if the preference is enabled or not
     */
    public void setEnabled(boolean enabled)
    {
        this.enabled = enabled;
    }

    /**<commit_msg>[misc] Codestyle<commit_after>/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.notifications.filters.internal;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.xwiki.notifications.NotificationFormat;
import org.xwiki.notifications.filters.NotificationFilterPreference;
import org.xwiki.notifications.filters.NotificationFilterType;
import org.xwiki.text.StringUtils;

/**
 * Default implementation of {@link NotificationFilterPreference}.
 *
 * @since 10.8RC1
 * @since 9.11.8
 * @version $Id $
 */
public class DefaultNotificationFilterPreference implements NotificationFilterPreference
{
    private static final String LIST_SEPARATOR = ",";

    private String id;

    private long internalId;

    private String owner;

    private String filterName;

    private String providerHint;

    private boolean enabled;

    private boolean active;

    private NotificationFilterType filterType;

    private Set<NotificationFormat> notificationFormats = new HashSet<>();

    private Date startingDate;

    private Set<String> eventTypes = new HashSet<>();

    private String user;

    private String pageOnly;

    private String page;

    private String wiki;

    /**
     * Construct an empty DefaultNotificationFilterPreference.
     */
    public DefaultNotificationFilterPreference()
    {

    }

    /**
     * Construct a DefaultNotificationFilterPreference which is a copy of the given notificationFilterPreference.
     * @param notificationFilterPreference object to copy
     */
    public DefaultNotificationFilterPreference(NotificationFilterPreference notificationFilterPreference)
    {
        if (notificationFilterPreference instanceof DefaultNotificationFilterPreference) {
            this.internalId = ((DefaultNotificationFilterPreference) notificationFilterPreference).internalId;
            this.owner = ((DefaultNotificationFilterPreference) notificationFilterPreference).owner;
        }

        this.id = notificationFilterPreference.getId();
        this.filterName = notificationFilterPreference.getFilterName();
        this.providerHint = notificationFilterPreference.getProviderHint();
        this.enabled = notificationFilterPreference.isEnabled();
        this.active = notificationFilterPreference.isActive();
        this.filterType = notificationFilterPreference.getFilterType();
        this.notificationFormats = notificationFilterPreference.getNotificationFormats();
        this.startingDate = notificationFilterPreference.getStartingDate();
        this.eventTypes = new HashSet<>(notificationFilterPreference.getEventTypes());
        this.user = notificationFilterPreference.getUser();
        this.pageOnly = notificationFilterPreference.getPageOnly();
        this.page = notificationFilterPreference.getPage();
        this.wiki = notificationFilterPreference.getWiki();

        this.setNotificationFormats(notificationFilterPreference.getNotificationFormats());
    }

    /**
     * @param id the unique identifier to set
     */
    public void setId(String id)
    {
        this.id = id;
    }

    /**
     * @return the internal id used to store the preference
     */
    public long getInternalId()
    {
        return internalId;
    }

    /**
     * @param internalId the internal id used to store the preference
     */
    public void setInternalId(long internalId)
    {
        this.internalId = internalId;
        this.id = String.format("NFP_%x", internalId);
    }

    /**
     * @return the owner of the preference
     */
    public String getOwner()
    {
        return owner;
    }

    /**
     * @param owner the owner of the preference
     */
    public void setOwner(String owner)
    {
        this.owner = owner;
    }

    /**
     * @param filterName the name of the filter concerned by the preference
     */
    public void setFilterName(String filterName)
    {
        this.filterName = filterName;
    }

    /**
     * @param providerHint the name of the provider that have built this preference
     */
    public void setProviderHint(String providerHint)
    {
        this.providerHint = providerHint;
    }

    /**
     * @param enabled if the preference is enabled or not
     */
    @Override
    public void setEnabled(boolean enabled)
    {
        this.enabled = enabled;
    }

    /**
{'fraction_non_alphanumeric': 0.0774747570067, 'fraction_numerical': 0.003963385863923752, 'mean_word_length': 3.2408963585434174, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2568606', 'n_tokens_mistral': 2679, 'n_tokens_neox': 2581, 'n_words': 820}