Android Open Source - RoboBinding-album-sample Album






From Project

Back to project page RoboBinding-album-sample.

License

The source code is released under:

Apache License

If you think the Android project RoboBinding-album-sample listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.robobinding.albumsample.model;
// w  w w . ja va 2  s  .  com
/**
 * @since 1.0
 * @author Cheng Wei
 * @author Robert Taylor
 * 
 */
public class Album {
  public static final int NO_ID = -1;

  private long id;
  private String title;
  private String artist;
  private boolean classical;
  private String composer;

  private Album(Builder builder) {
    validate(builder);
    this.id = builder.id;
    this.title = builder.title;
    this.artist = builder.artist;
    this.classical = builder.classical;
    if (builder.isClassical()) {
      this.composer = builder.composer;
    }
  }

  private void validate(Builder builder) {
  }

  public long getId() {
    return id;
  }

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

  public String getTitle() {
    return title;
  }

  public String getArtist() {
    return artist;
  }

  public boolean isClassical() {
    return classical;
  }

  public String getComposer() {
    return composer;
  }

  @Override
  public int hashCode() {
    return System.identityHashCode(id);
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    Album other = (Album) obj;
    if (id != other.id)
      return false;
    return true;
  }

  public boolean isNew() {
    return isNew(id);
  }

  public Builder createBuilder() {
    Builder builder = new Builder();
    builder.setTitle(title);
    builder.setArtist(artist);
    builder.setClassical(classical);
    builder.setComposer(composer);
    builder.setId(id);
    return builder;
  }

  public static boolean isNew(long albumId) {
    return albumId == NO_ID;
  }

  public static class Builder {
    private long id = NO_ID;
    private String title;
    private String artist;
    private boolean classical;
    private String composer;

    public long getId() {
      return id;
    }

    public Builder setId(long id) {
      this.id = id;
      return this;
    }

    public String getTitle() {
      return title;
    }

    public Builder setTitle(String title) {
      this.title = title;
      return this;
    }

    public String getArtist() {
      return artist;
    }

    public Builder setArtist(String artist) {
      this.artist = artist;
      return this;
    }

    public boolean isClassical() {
      return classical;
    }

    public Builder setClassical(boolean classical) {
      this.classical = classical;
      return this;
    }

    public String getComposer() {
      return composer;
    }

    public Builder setComposer(String composer) {
      this.composer = composer;
      return this;
    }

    public boolean isNew() {
      return Album.isNew(id);
    }

    public Album create() {
      return new Album(this);
    }
  }

}




Java Source Code List

org.robobinding.albumsample.activity.AbstractActivity.java
org.robobinding.albumsample.activity.AlbumApp.java
org.robobinding.albumsample.activity.CreateEditAlbumActivity.java
org.robobinding.albumsample.activity.DeleteAlbumDialog.java
org.robobinding.albumsample.activity.HomeActivity.java
org.robobinding.albumsample.activity.TestData.java
org.robobinding.albumsample.activity.ViewAlbumActivity.java
org.robobinding.albumsample.activity.ViewAlbumsActivity.java
org.robobinding.albumsample.model.Album.java
org.robobinding.albumsample.presentationmodel.AlbumItemPresentationModel.java
org.robobinding.albumsample.presentationmodel.CreateEditAlbumPresentationModel.java
org.robobinding.albumsample.presentationmodel.CreateEditAlbumView.java
org.robobinding.albumsample.presentationmodel.DeleteAlbumPresentationModel.java
org.robobinding.albumsample.presentationmodel.DeleteAlbumView.java
org.robobinding.albumsample.presentationmodel.HomePresentationModel.java
org.robobinding.albumsample.presentationmodel.HomeView.java
org.robobinding.albumsample.presentationmodel.ViewAlbumPresentationModel.java
org.robobinding.albumsample.presentationmodel.ViewAlbumView.java
org.robobinding.albumsample.presentationmodel.ViewAlbumsPresentationModel.java
org.robobinding.albumsample.presentationmodel.ViewAlbumsView.java
org.robobinding.albumsample.store.AlbumStore.java
org.robobinding.albumsample.store.MemoryAlbumStore.java
org.robobinding.albumsampletest.AbstractAlbumsTest.java
org.robobinding.albumsampletest.AbstractSampleAppTest.java
org.robobinding.albumsampletest.AlbumTestData.java
org.robobinding.albumsampletest.CreateEditAlbumActivityTest.java
org.robobinding.albumsampletest.DeleteAlbumActivityTest.java
org.robobinding.albumsampletest.ViewAlbumActivityTest.java
org.robobinding.albumsampletest.ViewAlbumsActivityTest.java