Builder: PlaylistTrack
~ PlaylistTrack object rewrite for builder implementation
@@ -2,42 +2,71 @@ package com.wrapper.spotify.objects;
import java.util.Date;
-public class PlaylistTrack {
+public class PlaylistTrack extends AbstractModelObject {
+ private final Date addedAt;
+ private final User addedBy;
+ private final boolean isLocal;
+ private final Track track;
- private Date addedAt;
- private User addedBy;
- private boolean isLocal;
- private Track track;
+ private PlaylistTrack(final PlaylistTrack.Builder builder) {
+ super(builder);
- public Date getAddedAt() {
- return addedAt;
+ this.addedAt = builder.addedAt;
+ this.addedBy = builder.addedBy;
+ this.isLocal = builder.isLocal;
+ this.track = builder.track;
}
- public void setAddedAt(Date addedAt) {
- this.addedAt = addedAt;
+ public Date getAddedAt() {
+ return addedAt;
}
public User getAddedBy() {
return addedBy;
}
- public void setAddedBy(User addedBy) {
- this.addedBy = addedBy;
- }
-
public boolean getIsLocal() {
return isLocal;
}
- public void setIsLocal(boolean isLocal) {
- this.isLocal = isLocal;
- }
-
public Track getTrack() {
return track;
}
- public void setTrack(Track track) {
+ @Override
+ public Builder builder() {
+ return new Builder();
+ }
+
+ public static final class Builder extends AbstractModelObject.Builder<PlaylistTrack.Builder> {
+ private Date addedAt;
+ private User addedBy;
+ private boolean isLocal;
+ private Track track;
+
+ public Builder setAddedAt(Date addedAt) {
+ this.addedAt = addedAt;
+ return this;
+ }
+
+ public Builder setAddedBy(User addedBy) {
+ this.addedBy = addedBy;
+ return this;
+ }
+
+ public Builder setIsLocal(boolean isLocal) {
+ this.isLocal = isLocal;
+ return this;
+ }
+
+ public Builder setTrack(Track track) {
this.track = track;
+ return this;
+ }
+
+ @Override
+ public PlaylistTrack build() {
+ return new PlaylistTrack(this);
+ }
}
}
