<commit_before>package models.base;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;

@MappedSuperclass
public abstract class BaseModel{

	@Id
	@GeneratedValue
	public Long id;
	
	@Column(name = "created_at")
	public Date createdAt;
	@Column(name = "updated_at")
	public Date updatedAt;
		
	@PrePersist
	protected void createdAt() {
		this.createdAt = this.updatedAt = new Date();
	}

	@PreUpdate
	protected void updatedAt() {
		this.updatedAt = new Date();
	}
	
	public abstract void create();
		
	public abstract void update();
	
	public abstract void delete();
		
	public boolean equals(Object obj){
		BaseModel baseModel = (BaseModel) obj;
		if(baseModel.id == null){
			return false;
		}
		if(baseModel.id.equals(this.id)) {
			return true; 
		} else {
			return false;
		}
	}
	
}<commit_msg>- Add JavaDoc to BaseModel - Improve and simplify equals() method<commit_after>package models.base;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;

/**
 * Provides a base model with standard attributes like ID, creation/modification date for all persistence models.
 */
@MappedSuperclass
public abstract class BaseModel {
    /**
     * Model ID.
     */
	@Id
	@GeneratedValue
	public Long id;

    /**
     * Date of the creation time of this model.
     */
	@Column(name = "created_at")
	public Date createdAt;

    /**
     * Date of the last modification of this model.
     */
	@Column(name = "updated_at")
	public Date updatedAt;

    /**
     * Sets created and updated time on creation.
     */
	@PrePersist
	protected void createdAt() {
		this.createdAt = this.updatedAt = new Date();
	}

    /**
     * Sets last update time.
     */
	@PreUpdate
	protected void updatedAt() {
		this.updatedAt = new Date();
	}

    /**
     * Creates this model.
     */
	public abstract void create();

    /**
     * Updates this model.
     */
	public abstract void update();

    /**
     * Deletes this model.
     */
	public abstract void delete();

    /**
     * Returns true, if given Object obj is equal to this model.
     *
     * @param obj Object instance to check equality
     * @return True, of given Object obj is equal this
     */
    @Override
	public boolean equals(Object obj) {
		return obj.getClass() != BaseModel.class
                && ((BaseModel)obj).id != null
                && ((BaseModel)obj).id.equals(this.id);
	}
}

{'fraction_non_alphanumeric': 0.10895795246800731, 'fraction_numerical': 0.0, 'mean_word_length': 3.0714285714285716, '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': '1758371', 'n_tokens_mistral': 851, 'n_tokens_neox': 814, 'n_words': 244}