From db6282eec6d75cb87b878bb0134f7116a3451e93 Mon Sep 17 00:00:00 2001 From: neviyn Date: Sun, 4 Apr 2021 15:05:37 +0100 Subject: [PATCH] Fixed "Getters of lazy classes cannot be final" --- .../uk/co/neviyn/projectplanner/Entities.kt | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/uk/co/neviyn/projectplanner/Entities.kt b/src/main/kotlin/uk/co/neviyn/projectplanner/Entities.kt index 1e602a1..7d0a57d 100644 --- a/src/main/kotlin/uk/co/neviyn/projectplanner/Entities.kt +++ b/src/main/kotlin/uk/co/neviyn/projectplanner/Entities.kt @@ -16,10 +16,10 @@ import javax.persistence.OneToMany @Entity open class User( - var username: String = "INVALID", - var email: String = "INVALID", + open var username: String = "INVALID", + open var email: String = "INVALID", @JsonIgnore - var password: String = "INVALID", + open var password: String = "INVALID", @ManyToMany(cascade = [CascadeType.ALL]) @JsonIgnore @JoinTable( @@ -27,22 +27,22 @@ open class User( joinColumns = [JoinColumn(name = "user_id", referencedColumnName = "id")], inverseJoinColumns = [JoinColumn(name = "project_id", referencedColumnName = "id")] ) - var projects: MutableSet = mutableSetOf(), - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null + open var projects: MutableSet = mutableSetOf(), + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) open var id: Long? = null ) @Entity -class Project( - var title: String = "INVALID", +open class Project( + open var title: String = "INVALID", @ManyToMany(mappedBy = "projects") @JsonIgnore - var members: MutableSet = mutableSetOf(), + open var members: MutableSet = mutableSetOf(), @OneToMany(mappedBy = "project") @JsonIgnore - var events: MutableSet = mutableSetOf(), - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null + open var events: MutableSet = mutableSetOf(), + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) open var id: Long? = null ) { - fun addMember(member: User){ + fun addMember(member: User) { members.add(member) member.projects.add(this) } @@ -54,46 +54,46 @@ class Project( } @Entity -class Event( - var title: String = "INVALID", - var description: String = "INVALID", +open class Event( + open var title: String = "INVALID", + open var description: String = "INVALID", @Column(name = "start_time") - var start: Instant = Instant.MIN, + open var start: Instant = Instant.MIN, @Column(name = "end_time") - var end: Instant = Instant.MIN, + open var end: Instant = Instant.MIN, @ManyToOne @JoinColumn(name = "project_id") @JsonIgnore - var project: Project? = null, + open var project: Project? = null, @ManyToMany(mappedBy = "events") @JsonIgnore - var tags: MutableSet = mutableSetOf(), + open var tags: MutableSet = mutableSetOf(), @OneToMany(mappedBy = "event") - var comments: MutableList = mutableListOf(), - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null + open var comments: MutableList = mutableListOf(), + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) open var id: Long? = null ) @Entity -class Comment( +open class Comment( @ManyToOne @JoinColumn(name = "user_id") - var user: User? = null, + open var user: User? = null, @ManyToOne @JoinColumn(name = "event_id") @JsonIgnore - var event: Event? = null, + open var event: Event? = null, @ManyToMany(mappedBy = "comments") - var tags: MutableSet = mutableSetOf(), - var created: Instant = Instant.MIN, - var comment: String = "INVALID", - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null + open var tags: MutableSet = mutableSetOf(), + open var created: Instant = Instant.MIN, + open var comment: String = "INVALID", + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) open var id: Long? = null ) { fun toFlatComment(): FlatComment = FlatComment(created, comment, user!!.username) } @Entity -class Tag( - var tag: String = "INVALID", +open class Tag( + open var tag: String = "INVALID", @ManyToMany @JoinTable( name = "comment_tags", @@ -101,7 +101,7 @@ class Tag( inverseJoinColumns = [JoinColumn(name = "comment_id", referencedColumnName = "id")] ) @JsonIgnore - var comments: MutableSet = mutableSetOf(), + open var comments: MutableSet = mutableSetOf(), @ManyToMany @JoinTable( name = "event_tags", @@ -109,6 +109,6 @@ class Tag( inverseJoinColumns = [JoinColumn(name = "event_id", referencedColumnName = "id")] ) @JsonIgnore - var events: MutableSet = mutableSetOf(), - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null + open var events: MutableSet = mutableSetOf(), + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) open var id: Long? = null ) \ No newline at end of file