<commit_before>package org.buddycloud.channelserver.pubsub.model.impl;

import java.util.Date;

import org.buddycloud.channelserver.pubsub.affiliation.Affiliations;
import org.buddycloud.channelserver.pubsub.model.NodeSubscription;
import org.buddycloud.channelserver.pubsub.subscription.Subscriptions;
import org.xmpp.packet.JID;
import org.xmpp.resultsetmanagement.Result;

public class NodeSubscriptionImpl implements NodeSubscription {

	private final Subscriptions subscription;
	private final JID user;
	private JID listener; // If different from user
	private final String nodeId;
	private Date lastUpdated;


	public NodeSubscriptionImpl(final String nodeId, final JID user,
			final Subscriptions subscription) {
		this(nodeId, user, user, subscription, new Date());
	}
	
	public NodeSubscriptionImpl(final String nodeId, final JID user,
			final Subscriptions subscription, Date lastUpdated) {
		this(nodeId, user, user, subscription, lastUpdated);
	}

	public NodeSubscriptionImpl(final String nodeId, final JID user,
			JID listener, final Subscriptions subscription) {
		this(nodeId, user, listener, subscription, new Date());
	}
	
	public NodeSubscriptionImpl(final String nodeId, final JID user,
			JID listener, final Subscriptions subscription, Date lastUpdated) {
		this.nodeId = nodeId;
		if (user.getResource() == null) {
			this.user = user;
		} else {
			this.user = new JID(user.toBareJID());
		}
		this.lastUpdated = lastUpdated;
		setListener(listener);
		this.subscription = subscription;
	}

	private void setListener(JID listener) {
		if (null == listener) {
			listener = this.user;
			return;
		}
		if (null == listener.getNode()) {
			this.listener = new JID(listener.getDomain());
			return;
		}
		this.listener = new JID(listener.toBareJID());
	}

	@Override
	public Subscriptions getSubscription() {
		return subscription;
	}

	@Override
	public JID getUser() {
		return user;
	}

	@Override
	public JID getListener() {
		return listener;
	}

	@Override
	public String getNodeId() {
		return nodeId;
	}

	@Override
	public final int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((listener == null) ? 0 : listener.hashCode());
		result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
		result = prime * result
				+ ((subscription == null) ? 0 : subscription.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	@Override
	public final boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof NodeSubscriptionImpl))
			return false;
		NodeSubscriptionImpl other = (NodeSubscriptionImpl) obj;
		if (listener == null) {
			if (other.listener != null)
				return false;
		} else if (!listener.equals(other.listener))
			return false;
		if (nodeId == null) {
			if (other.nodeId != null)
				return false;
		} else if (!nodeId.equals(other.nodeId))
			return false;
		if (subscription != other.subscription)
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "NodeSubscriptionImpl [subscription=" + subscription + ", user="
				+ user + ", listener=" + listener + ", nodeId=" + nodeId + "]";
	}

	@Override
	public String getUID() {
		return String.valueOf(hashCode());
	}

	@Override
	public Date getLastUpdated() {
		return lastUpdated;
	}
}<commit_msg>Changing to an unique UID for NodeSubscription.<commit_after>package org.buddycloud.channelserver.pubsub.model.impl;

import java.util.Date;

import org.buddycloud.channelserver.pubsub.affiliation.Affiliations;
import org.buddycloud.channelserver.pubsub.model.NodeSubscription;
import org.buddycloud.channelserver.pubsub.subscription.Subscriptions;
import org.xmpp.packet.JID;
import org.xmpp.resultsetmanagement.Result;

public class NodeSubscriptionImpl implements NodeSubscription {

	private final Subscriptions subscription;
	private final JID user;
	private JID listener; // If different from user
	private final String nodeId;
	private Date lastUpdated;


	public NodeSubscriptionImpl(final String nodeId, final JID user,
			final Subscriptions subscription) {
		this(nodeId, user, user, subscription, new Date());
	}
	
	public NodeSubscriptionImpl(final String nodeId, final JID user,
			final Subscriptions subscription, Date lastUpdated) {
		this(nodeId, user, user, subscription, lastUpdated);
	}

	public NodeSubscriptionImpl(final String nodeId, final JID user,
			JID listener, final Subscriptions subscription) {
		this(nodeId, user, listener, subscription, new Date());
	}
	
	public NodeSubscriptionImpl(final String nodeId, final JID user,
			JID listener, final Subscriptions subscription, Date lastUpdated) {
		this.nodeId = nodeId;
		if (user.getResource() == null) {
			this.user = user;
		} else {
			this.user = new JID(user.toBareJID());
		}
		this.lastUpdated = lastUpdated;
		setListener(listener);
		this.subscription = subscription;
	}

	private void setListener(JID listener) {
		if (null == listener) {
			listener = this.user;
			return;
		}
		if (null == listener.getNode()) {
			this.listener = new JID(listener.getDomain());
			return;
		}
		this.listener = new JID(listener.toBareJID());
	}

	@Override
	public Subscriptions getSubscription() {
		return subscription;
	}

	@Override
	public JID getUser() {
		return user;
	}

	@Override
	public JID getListener() {
		return listener;
	}

	@Override
	public String getNodeId() {
		return nodeId;
	}

	@Override
	public final int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((listener == null) ? 0 : listener.hashCode());
		result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
		result = prime * result
				+ ((subscription == null) ? 0 : subscription.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	@Override
	public final boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof NodeSubscriptionImpl))
			return false;
		NodeSubscriptionImpl other = (NodeSubscriptionImpl) obj;
		if (listener == null) {
			if (other.listener != null)
				return false;
		} else if (!listener.equals(other.listener))
			return false;
		if (nodeId == null) {
			if (other.nodeId != null)
				return false;
		} else if (!nodeId.equals(other.nodeId))
			return false;
		if (subscription != other.subscription)
			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "NodeSubscriptionImpl [subscription=" + subscription + ", user="
				+ user + ", listener=" + listener + ", nodeId=" + nodeId + "]";
	}

	@Override
	public String getUID() {
		return toString();
	}

	@Override
	public Date getLastUpdated() {
		return lastUpdated;
	}
}
{'fraction_non_alphanumeric': 0.11609423786545557, 'fraction_numerical': 0.0019869429463525404, 'mean_word_length': 4.029978586723769, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5538304', 'n_tokens_mistral': 2377, 'n_tokens_neox': 2167, 'n_words': 618}