diff options
Diffstat (limited to 'subsonic-android/src/net/sourceforge/subsonic/androidapp/domain')
13 files changed, 945 insertions, 0 deletions
diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Artist.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Artist.java new file mode 100644 index 00000000..fce7b628 --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Artist.java @@ -0,0 +1,60 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2009 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +import java.io.Serializable; + +/** + * @author Sindre Mehus + */ +public class Artist implements Serializable { + + private String id; + private String name; + private String index; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getIndex() { + return index; + } + + public void setIndex(String index) { + this.index = index; + } + + @Override + public String toString() { + return name; + } +}
\ No newline at end of file diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Indexes.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Indexes.java new file mode 100644 index 00000000..f16861be --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Indexes.java @@ -0,0 +1,50 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2009 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +import java.util.List; +import java.io.Serializable; + +/** + * @author Sindre Mehus + */ +public class Indexes implements Serializable { + + private final long lastModified; + private final List<Artist> shortcuts; + private final List<Artist> artists; + + public Indexes(long lastModified, List<Artist> shortcuts, List<Artist> artists) { + this.lastModified = lastModified; + this.shortcuts = shortcuts; + this.artists = artists; + } + + public long getLastModified() { + return lastModified; + } + + public List<Artist> getShortcuts() { + return shortcuts; + } + + public List<Artist> getArtists() { + return artists; + } +}
\ No newline at end of file diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/JukeboxStatus.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/JukeboxStatus.java new file mode 100644 index 00000000..53a901ad --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/JukeboxStatus.java @@ -0,0 +1,63 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2009 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +/** + * @author Sindre Mehus + * @version $Id$ + */ +public class JukeboxStatus { + + private Integer positionSeconds; + private Integer currentPlayingIndex; + private Float gain; + private boolean playing; + + public Integer getPositionSeconds() { + return positionSeconds; + } + + public void setPositionSeconds(Integer positionSeconds) { + this.positionSeconds = positionSeconds; + } + + public Integer getCurrentPlayingIndex() { + return currentPlayingIndex; + } + + public void setCurrentIndex(Integer currentPlayingIndex) { + this.currentPlayingIndex = currentPlayingIndex; + } + + public boolean isPlaying() { + return playing; + } + + public void setPlaying(boolean playing) { + this.playing = playing; + } + + public Float getGain() { + return gain; + } + + public void setGain(float gain) { + this.gain = gain; + } +} diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Lyrics.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Lyrics.java new file mode 100644 index 00000000..c1a4c7c0 --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Lyrics.java @@ -0,0 +1,55 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2010 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +/** + * Song lyrics. + * + * @author Sindre Mehus + */ +public class Lyrics { + + private String artist; + private String title; + private String text; + + public String getArtist() { + return artist; + } + + public void setArtist(String artist) { + this.artist = artist; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } +} diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/MusicDirectory.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/MusicDirectory.java new file mode 100644 index 00000000..4d4d265b --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/MusicDirectory.java @@ -0,0 +1,259 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2009 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +import java.util.ArrayList; +import java.util.List; +import java.io.Serializable; + +/** + * @author Sindre Mehus + */ +public class MusicDirectory { + + private String name; + private final List<Entry> children = new ArrayList<Entry>(); + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public void addChild(Entry child) { + children.add(child); + } + + public List<Entry> getChildren() { + return getChildren(true, true); + } + + public List<Entry> getChildren(boolean includeDirs, boolean includeFiles) { + if (includeDirs && includeFiles) { + return children; + } + + List<Entry> result = new ArrayList<Entry>(children.size()); + for (Entry child : children) { + if (child.isDirectory() && includeDirs || !child.isDirectory() && includeFiles) { + result.add(child); + } + } + return result; + } + + public static class Entry implements Serializable { + private String id; + private String parent; + private boolean directory; + private String title; + private String album; + private String artist; + private Integer track; + private Integer year; + private String genre; + private String contentType; + private String suffix; + private String transcodedContentType; + private String transcodedSuffix; + private String coverArt; + private Long size; + private Integer duration; + private Integer bitRate; + private String path; + private boolean video; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getParent() { + return parent; + } + + public void setParent(String parent) { + this.parent = parent; + } + + public boolean isDirectory() { + return directory; + } + + public void setDirectory(boolean directory) { + this.directory = directory; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAlbum() { + return album; + } + + public void setAlbum(String album) { + this.album = album; + } + + public String getArtist() { + return artist; + } + + public void setArtist(String artist) { + this.artist = artist; + } + + public Integer getTrack() { + return track; + } + + public void setTrack(Integer track) { + this.track = track; + } + + public Integer getYear() { + return year; + } + + public void setYear(Integer year) { + this.year = year; + } + + public String getGenre() { + return genre; + } + + public void setGenre(String genre) { + this.genre = genre; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public String getSuffix() { + return suffix; + } + + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + public String getTranscodedContentType() { + return transcodedContentType; + } + + public void setTranscodedContentType(String transcodedContentType) { + this.transcodedContentType = transcodedContentType; + } + + public String getTranscodedSuffix() { + return transcodedSuffix; + } + + public void setTranscodedSuffix(String transcodedSuffix) { + this.transcodedSuffix = transcodedSuffix; + } + + public Long getSize() { + return size; + } + + public void setSize(Long size) { + this.size = size; + } + + public Integer getDuration() { + return duration; + } + + public void setDuration(Integer duration) { + this.duration = duration; + } + + public Integer getBitRate() { + return bitRate; + } + + public void setBitRate(Integer bitRate) { + this.bitRate = bitRate; + } + + public String getCoverArt() { + return coverArt; + } + + public void setCoverArt(String coverArt) { + this.coverArt = coverArt; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public boolean isVideo() { + return video; + } + + public void setVideo(boolean video) { + this.video = video; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + Entry entry = (Entry) o; + return id.equals(entry.id); + } + + @Override + public int hashCode() { + return id.hashCode(); + } + + @Override + public String toString() { + return title; + } + } +}
\ No newline at end of file diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/MusicFolder.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/MusicFolder.java new file mode 100644 index 00000000..595f2b5e --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/MusicFolder.java @@ -0,0 +1,46 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2009 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +import java.io.Serializable; + +/** + * Represents a top level directory in which music or other media is stored. + * + * @author Sindre Mehus + * @version $Id$ + */ +public class MusicFolder implements Serializable { + + private final String id; + private final String name; + + public MusicFolder(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } +} diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/PlayerState.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/PlayerState.java new file mode 100644 index 00000000..0e13159b --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/PlayerState.java @@ -0,0 +1,34 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2009 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +/** + * @author Sindre Mehus + * @version $Id$ + */ +public enum PlayerState { + IDLE, + DOWNLOADING, + PREPARING, + PREPARED, + STARTED, + STOPPED, + PAUSED, + COMPLETED +} diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Playlist.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Playlist.java new file mode 100644 index 00000000..8bb29f76 --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Playlist.java @@ -0,0 +1,56 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2009 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +import java.io.Serializable; + +/** + * @author Sindre Mehus + */ +public class Playlist implements Serializable { + + private String id; + private String name; + + public Playlist(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +}
\ No newline at end of file diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/RepeatMode.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/RepeatMode.java new file mode 100644 index 00000000..be2ad061 --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/RepeatMode.java @@ -0,0 +1,28 @@ +package net.sourceforge.subsonic.androidapp.domain; + +/** + * @author Sindre Mehus + * @version $Id$ + */ +public enum RepeatMode { + OFF { + @Override + public RepeatMode next() { + return ALL; + } + }, + ALL { + @Override + public RepeatMode next() { + return SINGLE; + } + }, + SINGLE { + @Override + public RepeatMode next() { + return OFF; + } + }; + + public abstract RepeatMode next(); +} diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/SearchCritera.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/SearchCritera.java new file mode 100644 index 00000000..8f944b1a --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/SearchCritera.java @@ -0,0 +1,55 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2009 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +/** + * The criteria for a music search. + * + * @author Sindre Mehus + */ +public class SearchCritera { + + private final String query; + private final int artistCount; + private final int albumCount; + private final int songCount; + + public SearchCritera(String query, int artistCount, int albumCount, int songCount) { + this.query = query; + this.artistCount = artistCount; + this.albumCount = albumCount; + this.songCount = songCount; + } + + public String getQuery() { + return query; + } + + public int getArtistCount() { + return artistCount; + } + + public int getAlbumCount() { + return albumCount; + } + + public int getSongCount() { + return songCount; + } +}
\ No newline at end of file diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/SearchResult.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/SearchResult.java new file mode 100644 index 00000000..54c91628 --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/SearchResult.java @@ -0,0 +1,51 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2009 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +import java.util.List; + +/** + * The result of a search. Contains matching artists, albums and songs. + * + * @author Sindre Mehus + */ +public class SearchResult { + + private final List<Artist> artists; + private final List<MusicDirectory.Entry> albums; + private final List<MusicDirectory.Entry> songs; + + public SearchResult(List<Artist> artists, List<MusicDirectory.Entry> albums, List<MusicDirectory.Entry> songs) { + this.artists = artists; + this.albums = albums; + this.songs = songs; + } + + public List<Artist> getArtists() { + return artists; + } + + public List<MusicDirectory.Entry> getAlbums() { + return albums; + } + + public List<MusicDirectory.Entry> getSongs() { + return songs; + } +}
\ No newline at end of file diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/ServerInfo.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/ServerInfo.java new file mode 100644 index 00000000..9212c585 --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/ServerInfo.java @@ -0,0 +1,46 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2010 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +/** + * Information about the Subsonic server. + * + * @author Sindre Mehus + */ +public class ServerInfo { + + private boolean isLicenseValid; + private Version restVersion; + + public boolean isLicenseValid() { + return isLicenseValid; + } + + public void setLicenseValid(boolean licenseValid) { + isLicenseValid = licenseValid; + } + + public Version getRestVersion() { + return restVersion; + } + + public void setRestVersion(Version restVersion) { + this.restVersion = restVersion; + } +} diff --git a/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Version.java b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Version.java new file mode 100644 index 00000000..bd1643b5 --- /dev/null +++ b/subsonic-android/src/net/sourceforge/subsonic/androidapp/domain/Version.java @@ -0,0 +1,142 @@ +/* + This file is part of Subsonic. + + Subsonic is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Subsonic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Subsonic. If not, see <http://www.gnu.org/licenses/>. + + Copyright 2009 (C) Sindre Mehus + */ +package net.sourceforge.subsonic.androidapp.domain; + +/** + * Represents the version number of the Subsonic Android app. + * + * @author Sindre Mehus + * @version $Revision: 1.3 $ $Date: 2006/01/20 21:25:16 $ + */ +public class Version implements Comparable<Version> { + private int major; + private int minor; + private int beta; + private int bugfix; + + /** + * Creates a new version instance by parsing the given string. + * @param version A string of the format "1.27", "1.27.2" or "1.27.beta3". + */ + public Version(String version) { + String[] s = version.split("\\."); + major = Integer.valueOf(s[0]); + minor = Integer.valueOf(s[1]); + + if (s.length > 2) { + if (s[2].contains("beta")) { + beta = Integer.valueOf(s[2].replace("beta", "")); + } else { + bugfix = Integer.valueOf(s[2]); + } + } + } + + public int getMajor() { + return major; + } + + public int getMinor() { + return minor; + } + + /** + * Return whether this object is equal to another. + * @param o Object to compare to. + * @return Whether this object is equals to another. + */ + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + final Version version = (Version) o; + + if (beta != version.beta) return false; + if (bugfix != version.bugfix) return false; + if (major != version.major) return false; + return minor == version.minor; + } + + /** + * Returns a hash code for this object. + * @return A hash code for this object. + */ + public int hashCode() { + int result; + result = major; + result = 29 * result + minor; + result = 29 * result + beta; + result = 29 * result + bugfix; + return result; + } + + /** + * Returns a string representation of the form "1.27", "1.27.2" or "1.27.beta3". + * @return A string representation of the form "1.27", "1.27.2" or "1.27.beta3". + */ + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append(major).append('.').append(minor); + if (beta != 0) { + buf.append(".beta").append(beta); + } else if (bugfix != 0) { + buf.append('.').append(bugfix); + } + + return buf.toString(); + } + + /** + * Compares this object with the specified object for order. + * @param version The object to compare to. + * @return A negative integer, zero, or a positive integer as this object is less than, equal to, or + * greater than the specified object. + */ + @Override + public int compareTo(Version version) { + if (major < version.major) { + return -1; + } else if (major > version.major) { + return 1; + } + + if (minor < version.minor) { + return -1; + } else if (minor > version.minor) { + return 1; + } + + if (bugfix < version.bugfix) { + return -1; + } else if (bugfix > version.bugfix) { + return 1; + } + + int thisBeta = beta == 0 ? Integer.MAX_VALUE : beta; + int otherBeta = version.beta == 0 ? Integer.MAX_VALUE : version.beta; + + if (thisBeta < otherBeta) { + return -1; + } else if (thisBeta > otherBeta) { + return 1; + } + + return 0; + } +}
\ No newline at end of file |