<commit_before>package jfmi.control;


/** Represents an association between a file and a tag.
  */
public class FileTagging implements Comparable<FileTagging> {

	// PRIVATE INSTANCE Fields
	int taggingId;
	int fileId;
	String tag;
	String comment;

	//************************************************************
	// PUBLIC INSTANCE Methods
	//************************************************************

	/** Constructs a default FileTagging with negative tagging and file ids,
	  and empty tag and comment.
	  */
	public FileTagging()
	{
		this(-1, -1, "", "");
	}

	/** Constructs a new FileTagging with the specified tagging id, file id,
	  tag, and comment.
	  @param tid value for taggingId
	  @param fid value for fileId
	  @param tagVal value for tag
	  @param commentVal value for comment
	  */
	public FileTagging(int tid, int fid, String tagVal, String commentVal)
	{
		setTaggingId(tid);
		setFileId(fid);
		setTag(tagVal);
		setComment(commentVal);
	}

	/** Determines whether or not the instance is equal to another FileTagging
	  instance.
	  @param other the FileTagging instance to test for equality against
	  @return true if the instance is equal to the parameter instance
	  */
	public boolean equals(FileTagging other)
	{
		return taggingId == other.taggingId 
				&& fileId == other.fileId
				&& tag.equals(tag)
				&& comment.equals(comment);
	}

	/** Retrieves the tagging's id.
	  @return value of the taggingId field.
	  */
	public int getTaggingId()
	{
		return taggingId;
	}

	/** Retrieves the id of the tagging's associated file.
	  @return the value of the fileId field
	  */
	public int getFileId()
	{
		return fileId;
	}

	/** Retrieves the tag associated with this tagging.
	  @return the value of the tag field
	  */
	public String getTag()
	{
		return tag;
	}

	/** Retrieves the comment associated with this tagging.
	  @return the value of the comment field
	  */
	public String getComment()
	{
		return comment;
	}

	/** Sets the id of this tagging.
	  @param id the new value for the taggingId field
	  */
	public void setTaggingId(int id)
	{
		taggingId = id;
	}

	/** Sets the id of the file associated with this tagging.
	  @param id the new value for the fileId field
	  */
	public void setFileId(int id)
	{
		fileId = id;
	}

	/** Sets the value of the tag associated with this tagging. If the parameter
	  is null, the tag is set to the empty string, "".
	  @param newTag the new value for the tag field
	  */
	public void setTag(String newTag)
	{
		if (newTag == null) {
			tag = "";
		} else {
			tag = newTag;
		}
	}

	/** Sets the value of the comment associated with this tagging. If the
	  parameter is null, the comment is set to the empty string, "".
	  @param newComment the new value for the comment field
	  */
	public void setComment(String newComment)
	{
		if (newComment == null) {
			comment = "";
		} else {
			comment = newComment;
		}
	}

	/**
	  @return a String representation of the FileTagging
	  */
	public String toString()
	{
		StringBuilder string = new StringBuilder("");
		string.append("[");
		string.append(tag);
		string.append("] ");
		string.append(comment);
		return string.toString();
	}

	//************************************************************
	// IMPLEMENTATION of Comparable<FileTagging>
	//************************************************************

	/** Compares this object with the specified object for order. The natural
	  ordering implemented by this class is consistent with equals().
	  @param o the object to compare this instance against
	  @return -1, 0, 1 as this object is less than, equal to, or greater than
			the parameter
	  */
	public int compareTo(FileTagging o)
	{
		if (this.equals(o)) {
			return 0;
		} 

		if (taggingId == o.taggingId) {
			if (fileId == o.fileId) {
				if (tag.equals(o.tag)) {
					return comment.compareTo(o.comment);
				} else {
					return tag.compareTo(o.tag);
				}

			} else {
				return ((Integer)fileId).compareTo(o.fileId);
			}

		} else {
			return ((Integer)taggingId).compareTo(o.taggingId);
		}
	}

}<commit_msg>Changed FileTagging implementation of compareTo()<commit_after>package jfmi.control;


/** Represents an association between a file and a tag.
  */
public class FileTagging implements Comparable<FileTagging> {

	// PRIVATE INSTANCE Fields
	int taggingId;
	int fileId;
	String tag;
	String comment;

	//************************************************************
	// PUBLIC INSTANCE Methods
	//************************************************************

	/** Constructs a default FileTagging with negative tagging and file ids,
	  and empty tag and comment.
	  */
	public FileTagging()
	{
		this(-1, -1, "", "");
	}

	/** Constructs a new FileTagging with the specified tagging id, file id,
	  tag, and comment.
	  @param tid value for taggingId
	  @param fid value for fileId
	  @param tagVal value for tag
	  @param commentVal value for comment
	  */
	public FileTagging(int tid, int fid, String tagVal, String commentVal)
	{
		setTaggingId(tid);
		setFileId(fid);
		setTag(tagVal);
		setComment(commentVal);
	}

	/** Determines whether or not the instance is equal to another FileTagging
	  instance.
	  @param other the FileTagging instance to test for equality against
	  @return true if the instance is equal to the parameter instance
	  */
	public boolean equals(FileTagging other)
	{
		return taggingId == other.taggingId 
				&& fileId == other.fileId
				&& tag.equals(tag)
				&& comment.equals(comment);
	}

	/** Retrieves the tagging's id.
	  @return value of the taggingId field.
	  */
	public int getTaggingId()
	{
		return taggingId;
	}

	/** Retrieves the id of the tagging's associated file.
	  @return the value of the fileId field
	  */
	public int getFileId()
	{
		return fileId;
	}

	/** Retrieves the tag associated with this tagging.
	  @return the value of the tag field
	  */
	public String getTag()
	{
		return tag;
	}

	/** Retrieves the comment associated with this tagging.
	  @return the value of the comment field
	  */
	public String getComment()
	{
		return comment;
	}

	/** Sets the id of this tagging.
	  @param id the new value for the taggingId field
	  */
	public void setTaggingId(int id)
	{
		taggingId = id;
	}

	/** Sets the id of the file associated with this tagging.
	  @param id the new value for the fileId field
	  */
	public void setFileId(int id)
	{
		fileId = id;
	}

	/** Sets the value of the tag associated with this tagging. If the parameter
	  is null, the tag is set to the empty string, "".
	  @param newTag the new value for the tag field
	  */
	public void setTag(String newTag)
	{
		if (newTag == null) {
			tag = "";
		} else {
			tag = newTag;
		}
	}

	/** Sets the value of the comment associated with this tagging. If the
	  parameter is null, the comment is set to the empty string, "".
	  @param newComment the new value for the comment field
	  */
	public void setComment(String newComment)
	{
		if (newComment == null) {
			comment = "";
		} else {
			comment = newComment;
		}
	}

	/**
	  @return a String representation of the FileTagging
	  */
	public String toString()
	{
		StringBuilder string = new StringBuilder("");
		string.append("[");
		string.append(tag);
		string.append("] ");
		string.append(comment);
		return string.toString();
	}

	//************************************************************
	// IMPLEMENTATION of Comparable<FileTagging>
	//************************************************************

	/** Compares this object with the specified object for order. The natural
	  ordering implemented by this class is consistent with equals(). Two
	  FileTagging objects are equal if all their fields are equal. If not
	  equal, their relationship is determined first by tag value, then by
	  comment, taggingId, fileId.
	  @param o the object to compare this instance against
	  @return -1, 0, 1 as this object is less than, equal to, or greater than
			the parameter
	  */
	public int compareTo(FileTagging o)
	{
		if (this.equals(o)) {
			return 0;
		} 

		if (tag.compareTo(o.tag) == 0) {

			if (comment.compareTo(o.comment) == 0) {

				if (((Integer)taggingId).compareTo(o.taggingId) == 0) {

					return ((Integer)fileId).compareTo(o.fileId);

				} else {
					return ((Integer)taggingId).compareTo(o.taggingId);
				}

			} else {
				return comment.compareTo(o.comment);
			}

		} else {
			return tag.compareTo(o.tag);
		}
	}

}
{'fraction_non_alphanumeric': 0.1508446347846776, 'fraction_numerical': 0.0017844396859386152, 'mean_word_length': 3.282730514518594, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1059802', 'n_tokens_mistral': 2821, 'n_tokens_neox': 2492, 'n_words': 914}