package fr.mgargadennec.blossom.core.common.dto;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

import java.util.Date;

public abstract class AbstractDTO {
  @JsonSerialize(using = ToStringSerializer.class)
  private Long id;

  private Date creationDate;
  private String creationUser;

  private Date modificationDate;
  private String modificationUser;

  public Long getId() {
    return id;
  }

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

  public Date getCreationDate() {
    return creationDate;
  }

  public void setCreationDate(Date creationDate) {
    this.creationDate = creationDate;
  }

  public String getCreationUser() {
    return creationUser;
  }

  public void setCreationUser(String creationUser) {
    this.creationUser = creationUser;
  }

  public Date getModificationDate() {
    return modificationDate;
  }

  public void setModificationDate(Date modificationDate) {
    this.modificationDate = modificationDate;
  }

  public String getModificationUser() {
    return modificationUser;
  }

  public void setModificationUser(String modificationUser) {
    this.modificationUser = modificationUser;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    AbstractDTO that = (AbstractDTO) o;

    return id != null ? id.equals(that.id) : that.id == null;
  }

  @Override
  public int hashCode() {
    return id != null ? id.hashCode() : 0;
  }
}

@@ -1217,24 +1217,26 @@
 nUser;%0A  %7D%0A%0A
+  
   @Override%0A
@@ -1426,54 +1426,66 @@
  id 
-!= null ? id.equals(that.id) : that.id == null
+ == null  %7C%7C that.id == null ? false :  id.equals(that.id)
 ;%0A  

Two objects with null ids are not equals