<commit_before>package org.dannil.httpdownloader.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.apache.commons.io.FilenameUtils;
import org.springframework.stereotype.Component;

@Component
@Entity
@Table(name = "downloads")
public class Download implements Serializable {

	private static final long serialVersionUID = -9127457928753578088L;

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

	@Column(name = "Title", length = 50, nullable = false)
	@NotNull
	private String title;

	@Column(name = "URL", length = 100, nullable = false)
	@NotNull
	private String url;

	@Column(name = "StartDate")
	private Date startDate;

	@Column(name = "EndDate")
	private Date endDate;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "UserID", referencedColumnName = "UserID")
	private User user;

	/**
	 * Default constructor
	 */
	public Download() {

	}

	/**
	 * Overloaded constructor
	 * 
	 * @param title
	 * 				the download's title
	 * @param url
	 * 				the download's URL (Uniform Resource Locator)
	 */
	public Download(final String title, final String url) {
		this();
		this.title = title;
		this.url = url;
	}

	/**
	 * Overloaded constructor
	 * 
	 * @param title
	 * 					the download's title
	 * @param url
	 * 					the download's URL (Uniform Resource Locator)
	 * @param startDate
	 * 					the date the download was started
	 */
	public Download(final String title, final String url, final Date startDate) {
		this(title, url);
		this.startDate = startDate;
	}

	/**
	 * Overloaded constructor
	 * 
	 * @param title
	 * 					the download's title
	 * @param url
	 * 					the download's URL (Uniform Resource Locator)
	 * @param startDate
	 * 					the date the download was started
	 * @param endDate
	 * 					the date the download was completed
	 * @param user
	 * 					the user which owns this download
	 */
	public Download(final String title, final String url, final Date startDate, final Date endDate, final User user) {
		this(title, url, startDate);
		this.endDate = endDate;
		this.user = user;
	}

	/**
	 * Copy constructor
	 * 
	 * @param download 
	 * 					the object to copy
	 */
	public Download(final Download download) {
		this(download.getTitle(), download.getUrl(), download.getStartDate(), download.getEndDate(), download.getUser());
		this.id = download.getId();
	}

	public final Long getId() {
		return this.id;
	}

	public final void setId(Long id) {
		this.id = id;
	}

	public final String getTitle() {
		return this.title;
	}<commit_msg>Added deep copy with null check<commit_after>package org.dannil.httpdownloader.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.apache.commons.io.FilenameUtils;
import org.springframework.stereotype.Component;

@Component
@Entity
@Table(name = "downloads")
public class Download implements Serializable {

	private static final long serialVersionUID = -9127457928753578088L;

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

	@Column(name = "Title", length = 50, nullable = false)
	@NotNull
	private String title;

	@Column(name = "URL", length = 100, nullable = false)
	@NotNull
	private String url;

	@Column(name = "StartDate")
	private Date startDate;

	@Column(name = "EndDate")
	private Date endDate;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "UserID", referencedColumnName = "UserID")
	private User user;

	/**
	 * Default constructor
	 */
	public Download() {

	}

	/**
	 * Overloaded constructor
	 * 
	 * @param title
	 * 				the download's title
	 * @param url
	 * 				the download's URL (Uniform Resource Locator)
	 */
	public Download(final String title, final String url) {
		this();
		this.title = title;
		this.url = url;
	}

	/**
	 * Overloaded constructor
	 * 
	 * @param title
	 * 					the download's title
	 * @param url
	 * 					the download's URL (Uniform Resource Locator)
	 * @param startDate
	 * 					the date the download was started
	 */
	public Download(final String title, final String url, final Date startDate) {
		this(title, url);
		this.startDate = startDate;
	}

	/**
	 * Overloaded constructor
	 * 
	 * @param title
	 * 					the download's title
	 * @param url
	 * 					the download's URL (Uniform Resource Locator)
	 * @param startDate
	 * 					the date the download was started
	 * @param endDate
	 * 					the date the download was completed
	 * @param user
	 * 					the user which owns this download
	 */
	public Download(final String title, final String url, final Date startDate, final Date endDate, final User user) {
		this(title, url, startDate);
		this.endDate = endDate;

		if (user != null) {
			this.user = new User(user);
		}
	}

	/**
	 * Copy constructor
	 * 
	 * @param download 
	 * 					the object to copy
	 */
	public Download(final Download download) {
		this(download.getTitle(), download.getUrl(), download.getStartDate(), download.getEndDate(), download.getUser());
		this.id = download.getId();
	}

	public final Long getId() {
		return this.id;
	}

	public final void setId(Long id) {
		this.id = id;
	}

	public final String getTitle() {
		return this.title;
	}
{'fraction_non_alphanumeric': 0.1069735951252539, 'fraction_numerical': 0.008124576844955992, 'mean_word_length': 3.715881883479649, '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': 56, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2650758', 'n_tokens_mistral': 2021, 'n_tokens_neox': 1789, 'n_words': 529}