package io.reflectoring.coderadar.core.analyzer.domain;

import javax.persistence.*;
import lombok.Data;

/** Represents a file in a VCS repository. */
@Entity
@Table(name = "file")
@SequenceGenerator(name = "file_sequence", sequenceName = "seq_file_id", allocationSize = 1)
@Data
public class File {

  @Id
  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "file_sequence")
  @Column(name = "id")
  private Long id;

  @Column(name = "filepath", nullable = false)
  private String filepath;

  @ManyToOne(cascade = CascadeType.ALL)
  @JoinColumn(name = "identity_id")
  private FileIdentity identity;

  /*
  @Override
  public String toString() {
    ReflectionToStringBuilder builder =
        new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
    return builder.build();
  }
  */

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

    File that = (File) o;

    if (!filepath.equals(that.filepath)) return false;
    return identity.equals(that.identity);
  }

  @Override
  public int hashCode() {
    int result = filepath.hashCode();
    result = 31 * result + identity.hashCode();
    return result;
  }
}

@@ -97,16 +97,60 @@
 ok.Data;
+%0Aimport org.neo4j.ogm.annotation.NodeEntity;
 %0A%0A/** Re
@@ -194,16 +194,20 @@
 */%0A@
+Node
 Entity%0A@
 Tabl
@@ -206,327 +206,51 @@
 ty%0A@
-Table(name = %22file%22)%0A@SequenceGenerator(name = %22file_sequence%22, sequenceName = %22seq_file_id%22, allocationSize = 1)%0A@Data%0Apublic class File %7B%0A%0A  @Id%0A  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = %22file_sequence%22)%0A  @Column(name = %22id%22)%0A  private Long id;%0A%0A  @Column(name = %22filepath%22, nullable = false)
+Data%0Apublic class File %7B%0A  private Long id;
 %0A  p
@@ -267,751 +267,12 @@
 ing 
-file
 path;
-%0A%0A  @ManyToOne(cascade = CascadeType.ALL)%0A  @JoinColumn(name = %22identity_id%22)%0A  private FileIdentity identity;%0A%0A  /*%0A  @Override%0A  public String toString() %7B%0A    ReflectionToStringBuilder builder =%0A        new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);%0A    return builder.build();%0A  %7D%0A  */%0A%0A  @Override%0A  public boolean equals(Object o) %7B%0A    if (this == o) return true;%0A    if (o == null %7C%7C getClass() != o.getClass()) return false;%0A%0A    File that = (File) o;%0A%0A    if (!filepath.equals(that.filepath)) return false;%0A    return identity.equals(that.identity);%0A  %7D%0A%0A  @Override%0A  public int hashCode() %7B%0A    int result = filepath.hashCode();%0A    result = 31 * result + identity.hashCode();%0A    return result;%0A  %7D
 %0A%7D%0A

Convert the entity File to Neo4j