Added a base Model class which implements equals.

This commit is contained in:
Jonathan Bernard 2016-02-12 17:18:37 -06:00
parent a795397b3b
commit b4ce76063b
8 changed files with 22 additions and 34 deletions

View File

@ -1,10 +1,6 @@
package com.jdbernard.wdiwtlt.db.models; package com.jdbernard.wdiwtlt.db.models;
import javax.persistence.Entity; public class Album extends Model {
@Entity
public class Album {
public int id;
public String name; public String name;
public Integer trackTotal; public Integer trackTotal;
public Integer year; public Integer year;

View File

@ -1,10 +1,6 @@
package com.jdbernard.wdiwtlt.db.models; package com.jdbernard.wdiwtlt.db.models;
import javax.persistence.Entity; public class Artist extends Model {
@Entity
public class Artist {
public int id;
public String name; public String name;
public String toString() { return name; } public String toString() { return name; }

View File

@ -1,10 +1,6 @@
package com.jdbernard.wdiwtlt.db.models; package com.jdbernard.wdiwtlt.db.models;
import javax.persistence.Entity; public class Bookmark extends Model {
@Entity
public class Bookmark {
public int id;
public String name; public String name;
public int playlistId; public int playlistId;
public int mediaFileId; public int mediaFileId;

View File

@ -1,10 +1,6 @@
package com.jdbernard.wdiwtlt.db.models; package com.jdbernard.wdiwtlt.db.models;
import javax.persistence.Entity; public class Image extends Model {
@Entity
public class Image {
public int id;
public String url; public String url;
public String toString() { return url; } public String toString() { return url; }

View File

@ -2,14 +2,10 @@ package com.jdbernard.wdiwtlt.db.models;
import java.util.Date; import java.util.Date;
import javax.persistence.Entity; public class MediaFile extends Model {
@Entity
public class MediaFile {
public static final String TAG_INFO = "tag info"; public static final String TAG_INFO = "tag info";
public static final String FILE_LOCATION = "file location"; public static final String FILE_LOCATION = "file location";
public int id;
public String name; public String name;
public Integer trackNumber; public Integer trackNumber;
public int playCount = 0; public int playCount = 0;

View File

@ -0,0 +1,15 @@
package com.jdbernard.wdiwtlt.db.models;
import javax.persistence.Entity;
@Entity
public class Model {
public int id;
public boolean equals(Object thatObj) {
if (thatObj == null) return false;
if (!(thatObj instanceof Model)) return false;
Model that = (Model) thatObj;
return this.id == that.id; }
}

View File

@ -1,11 +1,8 @@
package com.jdbernard.wdiwtlt.db.models; package com.jdbernard.wdiwtlt.db.models;
import java.util.Date; import java.util.Date;
import javax.persistence.Entity;
@Entity public class Playlist extends Model {
public class Playlist {
public int id;
public boolean userCreated; public boolean userCreated;
public Date lastUsed; public Date lastUsed;
public String name; public String name;

View File

@ -1,10 +1,6 @@
package com.jdbernard.wdiwtlt.db.models; package com.jdbernard.wdiwtlt.db.models;
import javax.persistence.Entity; public class Tag extends Model {
@Entity
public class Tag {
public int id;
public String name; public String name;
public String toString() { return name; } public String toString() { return name; }