projects
/
demoscenemusic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
a8592c3
)
Add javadoc.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Wed, 25 Apr 2012 14:35:59 +0000
(16:35 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Wed, 25 Apr 2012 14:35:59 +0000
(16:35 +0200)
13 files changed:
src/main/java/net/pterodactylus/demoscenemusic/data/Artist.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/Base.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultArtist.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultBase.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultParty.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultStyle.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrack.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/Group.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/Party.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/Style.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/demoscenemusic/data/Track.java
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/Artist.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/Artist.java
index
d9e6682
..
563a3bc
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/Artist.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/Artist.java
@@
-20,22
+20,58
@@
package net.pterodactylus.demoscenemusic.data;
import java.util.Collection;
/**
import java.util.Collection;
/**
- *
TODO
+ *
Data interface for artists.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Artist extends Base {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Artist extends Base {
+ /**
+ * Returns the name of this artist.
+ *
+ * @return The name of this artist
+ */
public String getName();
public String getName();
+ /**
+ * Sets the name of this artist.
+ *
+ * @param name
+ * The new name of this artist
+ * @return This artist
+ */
public Artist setName(String name);
public Artist setName(String name);
+ /**
+ * Returns the groups this artist belongs to.
+ *
+ * @return The groups this artist belongs to
+ */
public Collection<Group> getGroups();
public Collection<Group> getGroups();
+ /**
+ * Sets the groups this artist belongs to.
+ *
+ * @param groups
+ * The groups this artist belongs to
+ * @return This artist
+ */
public Artist setGroups(Collection<Group> groups);
public Artist setGroups(Collection<Group> groups);
+ /**
+ * Returns the tracks created by this artist.
+ *
+ * @return The tracks created by this artist
+ */
public Collection<Track> getTracks();
public Collection<Track> getTracks();
+ /**
+ * Sets the tracks created by this artist.
+ *
+ * @param tracks
+ * The tracks created by this artist
+ * @return This artist
+ */
public Artist setTracks(Collection<Track> tracks);
}
public Artist setTracks(Collection<Track> tracks);
}
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/Base.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/Base.java
index
921ca30
..
e187041
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/Base.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/Base.java
@@
-17,14
+17,18
@@
package net.pterodactylus.demoscenemusic.data;
package net.pterodactylus.demoscenemusic.data;
-
/**
/**
- *
TODO
+ *
Base class for all data interfaces and implementations.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Base {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Base {
+ /**
+ * Returns the ID of the data container.
+ *
+ * @return The ID of the data container
+ */
public String getId();
}
public String getId();
}
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java
index
b2a3337
..
f3252f0
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java
@@
-38,33
+38,64
@@
import net.pterodactylus.util.database.ValueField;
import net.pterodactylus.util.database.ValueFieldWhereClause;
/**
import net.pterodactylus.util.database.ValueFieldWhereClause;
/**
- *
TODO
+ *
Interface between the database and the application.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DataManager {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DataManager {
+ /** The artist object creator. */
@SuppressWarnings("synthetic-access")
private final ObjectCreator<Artist> artistCreator = new ArtistCreator();
@SuppressWarnings("synthetic-access")
private final ObjectCreator<Artist> artistCreator = new ArtistCreator();
+
+ /** The group object creator. */
@SuppressWarnings("synthetic-access")
private final ObjectCreator<Group> groupCreator = new GroupCreator();
@SuppressWarnings("synthetic-access")
private final ObjectCreator<Group> groupCreator = new GroupCreator();
+
+ /** The track object creator. */
@SuppressWarnings("synthetic-access")
private final ObjectCreator<Track> trackCreator = new TrackCreator();
@SuppressWarnings("synthetic-access")
private final ObjectCreator<Track> trackCreator = new TrackCreator();
+
+ /** The style object creator. */
@SuppressWarnings("synthetic-access")
private final ObjectCreator<Style> styleCreator = new StyleCreator();
@SuppressWarnings("synthetic-access")
private final ObjectCreator<Style> styleCreator = new StyleCreator();
+ /** The database. */
private final Database database;
private final Database database;
+ /**
+ * Creates a new data manager.
+ *
+ * @param database
+ * The database to operate on
+ */
public DataManager(Database database) {
this.database = database;
}
public DataManager(Database database) {
this.database = database;
}
+ /**
+ * Returns all artists.
+ *
+ * @return All artists
+ * @throws DatabaseException
+ * if a database error occurs
+ */
public Collection<Artist> getAllArtists() throws DatabaseException {
Query query = new Query(Type.SELECT, "ARTISTS");
query.addField(new Field("ARTISTS.*"));
return database.getMultiple(query, artistCreator);
}
public Collection<Artist> getAllArtists() throws DatabaseException {
Query query = new Query(Type.SELECT, "ARTISTS");
query.addField(new Field("ARTISTS.*"));
return database.getMultiple(query, artistCreator);
}
+ /**
+ * Returns the artist with the given ID.
+ *
+ * @param id
+ * The ID of the artist
+ * @return The artist with the given ID, or {@code null} if there is no
+ * artist with the given ID
+ * @throws DatabaseException
+ * if a database error occurs
+ */
public Artist getArtistById(String id) throws DatabaseException {
Query query = new Query(Type.SELECT, "ARTISTS");
query.addField(new Field("ARTISTS.*"));
public Artist getArtistById(String id) throws DatabaseException {
Query query = new Query(Type.SELECT, "ARTISTS");
query.addField(new Field("ARTISTS.*"));
@@
-72,6
+103,15
@@
public class DataManager {
return database.getSingle(query, artistCreator);
}
return database.getSingle(query, artistCreator);
}
+ /**
+ * Returns all artists that belong to the group with the given ID.
+ *
+ * @param groupId
+ * The ID of the group
+ * @return All artists belonging to the given group
+ * @throws DatabaseException
+ * if a database error occurs
+ */
public Collection<Artist> getArtistsByGroup(String groupId) throws DatabaseException {
Query query = new Query(Type.SELECT, "ARTISTS");
query.addField(new Field("ARTISTS.*"));
public Collection<Artist> getArtistsByGroup(String groupId) throws DatabaseException {
Query query = new Query(Type.SELECT, "ARTISTS");
query.addField(new Field("ARTISTS.*"));
@@
-80,6
+120,15
@@
public class DataManager {
return database.getMultiple(query, artistCreator);
}
return database.getMultiple(query, artistCreator);
}
+ /**
+ * Returns all artists involved in the track with the given ID.
+ *
+ * @param trackId
+ * The ID of the track
+ * @return All artists involved in the track, in preferred order
+ * @throws DatabaseException
+ * if a database error occurs
+ */
public List<Artist> getArtistsByTrack(String trackId) throws DatabaseException {
Query query = new Query(Type.SELECT, "ARTISTS");
query.addField(new Field("ARTISTS.*"));
public List<Artist> getArtistsByTrack(String trackId) throws DatabaseException {
Query query = new Query(Type.SELECT, "ARTISTS");
query.addField(new Field("ARTISTS.*"));
@@
-89,6
+138,16
@@
public class DataManager {
return database.getMultiple(query, artistCreator);
}
return database.getMultiple(query, artistCreator);
}
+ /**
+ * Returns the track with the given ID.
+ *
+ * @param id
+ * The ID of the track
+ * @return The track with the given ID, or {@code null} if there is no such
+ * track
+ * @throws DatabaseException
+ * if a database error occurs
+ */
public Track getTrackById(String id) throws DatabaseException {
Query query = new Query(Type.SELECT, "TRACKS");
query.addField(new Field("TRACKS.*"));
public Track getTrackById(String id) throws DatabaseException {
Query query = new Query(Type.SELECT, "TRACKS");
query.addField(new Field("TRACKS.*"));
@@
-96,6
+155,15
@@
public class DataManager {
return database.getSingle(query, trackCreator);
}
return database.getSingle(query, trackCreator);
}
+ /**
+ * Returns all tracks by the artist with the given ID.
+ *
+ * @param artistId
+ * The ID of the artist
+ * @return All tracks by the given artist
+ * @throws DatabaseException
+ * if a database error occurs
+ */
public Collection<Track> getTracksByArtist(String artistId) throws DatabaseException {
Query query = new Query(Type.SELECT, "TRACKS");
query.addField(new Field("TRACKS.*"));
public Collection<Track> getTracksByArtist(String artistId) throws DatabaseException {
Query query = new Query(Type.SELECT, "TRACKS");
query.addField(new Field("TRACKS.*"));
@@
-104,6
+172,15
@@
public class DataManager {
return database.getMultiple(query, trackCreator);
}
return database.getMultiple(query, trackCreator);
}
+ /**
+ * Returns all groups the artist with the given ID belongs to.
+ *
+ * @param artistId
+ * The ID of the artist
+ * @return All groups the artist belongs to
+ * @throws DatabaseException
+ * if a database error occurs
+ */
public Collection<Group> getGroupsByArtist(String artistId) throws DatabaseException {
Query query = new Query(Type.SELECT, "GROUPS");
query.addField(new Field("GROUPS.*"));
public Collection<Group> getGroupsByArtist(String artistId) throws DatabaseException {
Query query = new Query(Type.SELECT, "GROUPS");
query.addField(new Field("GROUPS.*"));
@@
-112,6
+189,15
@@
public class DataManager {
return database.getMultiple(query, groupCreator);
}
return database.getMultiple(query, groupCreator);
}
+ /**
+ * Returns all styles for the track with the given ID.
+ *
+ * @param trackId
+ * The ID of the track
+ * @return All styles for the given track
+ * @throws DatabaseException
+ * if a database error occurs
+ */
public Collection<Style> getStylesByTrack(String trackId) throws DatabaseException {
Query query = new Query(Type.SELECT, "STYLES");
query.addField(new Field("STYLES.*"));
public Collection<Style> getStylesByTrack(String trackId) throws DatabaseException {
Query query = new Query(Type.SELECT, "STYLES");
query.addField(new Field("STYLES.*"));
@@
-120,8
+206,16
@@
public class DataManager {
return database.getMultiple(query, styleCreator);
}
return database.getMultiple(query, styleCreator);
}
+ /**
+ * {@link Artist} implementation that retrieves some attributes (such as
+ * {@link #getGroups()}, and {@link #getTracks()}) from the
+ * {@link DataManager} on demand.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
private class LazyArtist extends DefaultArtist {
private class LazyArtist extends DefaultArtist {
+ /** Memoizer for the tracks by this artist. */
private final Memoizer<Void> tracksMemoizer = new Memoizer<Void>(new Callable<Void>() {
@Override
public Void call() throws DatabaseException {
private final Memoizer<Void> tracksMemoizer = new Memoizer<Void>(new Callable<Void>() {
@Override
public Void call() throws DatabaseException {
@@
-132,6
+226,7
@@
public class DataManager {
}
});
}
});
+ /** Memoizer for the groups of this artist. */
private final Memoizer<Void> groupsMemoizer = new Memoizer<Void>(new Callable<Void>() {
@Override
private final Memoizer<Void> groupsMemoizer = new Memoizer<Void>(new Callable<Void>() {
@Override
@@
-144,10
+239,20
@@
public class DataManager {
});
});
+ /**
+ * Creates a new lazy artist.
+ *
+ * @param id
+ * The ID of the artist
+ */
public LazyArtist(String id) {
super(id);
}
public LazyArtist(String id) {
super(id);
}
+ //
+ // DEFAULTARTIST METHODS
+ //
+
/**
* {@inheritDoc}
*/
/**
* {@inheritDoc}
*/
@@
-157,6
+262,9
@@
public class DataManager {
return super.getGroups();
}
return super.getGroups();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Collection<Track> getTracks() {
tracksMemoizer.get();
@Override
public Collection<Track> getTracks() {
tracksMemoizer.get();
@@
-165,6
+273,13
@@
public class DataManager {
}
}
+ /**
+ * {@link ObjectCreator} implementation that can create {@link Artist}
+ * objects. This specific class actually creates {@link LazyArtist}
+ * instances.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
private class ArtistCreator implements ObjectCreator<Artist> {
/**
private class ArtistCreator implements ObjectCreator<Artist> {
/**
@@
-177,8
+292,15
@@
public class DataManager {
}
}
+ /**
+ * {@link Group} implementation that retrieves some attributes (such as
+ * {@link #getArtists()}) from the {@link DataManager} on demand.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
private class LazyGroup extends DefaultGroup {
private class LazyGroup extends DefaultGroup {
+ /** Memoizer for the artist. */
private final Memoizer<Void> artistsMemoizer = new Memoizer<Void>(new Callable<Void>() {
@Override
private final Memoizer<Void> artistsMemoizer = new Memoizer<Void>(new Callable<Void>() {
@Override
@@
-191,10
+313,20
@@
public class DataManager {
});
});
+ /**
+ * Creates a new lazy group.
+ *
+ * @param id
+ * The ID of the group
+ */
public LazyGroup(String id) {
super(id);
}
public LazyGroup(String id) {
super(id);
}
+ //
+ // DEFAULTGROUP METHODS
+ //
+
/**
* {@inheritDoc}
*/
/**
* {@inheritDoc}
*/
@@
-206,6
+338,13
@@
public class DataManager {
}
}
+ /**
+ * {@link ObjectCreator} implementation that can create {@link Group}
+ * objects. This specific implementation creates {@link LazyGroup}
+ * instances.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
private class GroupCreator implements ObjectCreator<Group> {
/**
private class GroupCreator implements ObjectCreator<Group> {
/**
@@
-218,8
+357,16
@@
public class DataManager {
}
}
+ /**
+ * {@link Track} implementation that retrieves some attributes (such as
+ * {@link #getArtists()}, and {@link #getStyles()}) from the
+ * {@link DataManager} on demand.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
private class LazyTrack extends DefaultTrack {
private class LazyTrack extends DefaultTrack {
+ /** Memoizer for the artists. */
private final Memoizer<Void> artistsMemoizer = new Memoizer<Void>(new Callable<Void>() {
@Override
private final Memoizer<Void> artistsMemoizer = new Memoizer<Void>(new Callable<Void>() {
@Override
@@
-232,6
+379,7
@@
public class DataManager {
});
});
+ /** Memoizer for the styles. */
private final Memoizer<Void> stylesMemoizer = new Memoizer<Void>(new Callable<Void>() {
@Override
private final Memoizer<Void> stylesMemoizer = new Memoizer<Void>(new Callable<Void>() {
@Override
@@
-245,12
+393,19
@@
public class DataManager {
});
/**
});
/**
+ * Creates a new track.
+ *
* @param id
* @param id
+ * The ID of the track
*/
public LazyTrack(String id) {
super(id);
}
*/
public LazyTrack(String id) {
super(id);
}
+ //
+ // DEFAULTTRACK METHODS
+ //
+
/**
* {@inheritDoc}
*/
/**
* {@inheritDoc}
*/
@@
-271,6
+426,13
@@
public class DataManager {
}
}
+ /**
+ * {@link ObjectCreator} implementation that can create {@link Track}
+ * objects. This specific implementation creates {@link LazyTrack}
+ * instances.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
private class TrackCreator implements ObjectCreator<Track> {
/**
private class TrackCreator implements ObjectCreator<Track> {
/**
@@
-283,6
+445,12
@@
public class DataManager {
}
}
+ /**
+ * {@link ObjectCreator} implementation that can create {@link Style}
+ * objects.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
private class StyleCreator implements ObjectCreator<Style> {
/**
private class StyleCreator implements ObjectCreator<Style> {
/**
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultArtist.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultArtist.java
index
26a06bb
..
7f99a9c
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultArtist.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultArtist.java
@@
-20,21
+20,37
@@
package net.pterodactylus.demoscenemusic.data;
import java.util.Collection;
/**
import java.util.Collection;
/**
- *
TODO
+ *
Default implementation for an artist data container.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultArtist extends DefaultBase implements Artist {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultArtist extends DefaultBase implements Artist {
+ /**
+ * Creates a new artist data container.
+ *
+ * @param id
+ * The ID of the artist
+ */
public DefaultArtist(String id) {
super(id);
}
public DefaultArtist(String id) {
super(id);
}
+ //
+ // ARTIST METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public String getName() {
return getValue("name", String.class).get();
}
@Override
public String getName() {
return getValue("name", String.class).get();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Artist setName(String name) {
getValue("name", String.class).set(name);
@Override
public Artist setName(String name) {
getValue("name", String.class).set(name);
@@
-59,12
+75,18
@@
public class DefaultArtist extends DefaultBase implements Artist {
return this;
}
return this;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
@SuppressWarnings({ "unchecked" })
public Collection<Track> getTracks() {
return getValue("tracks", Collection.class).get();
}
@Override
@SuppressWarnings({ "unchecked" })
public Collection<Track> getTracks() {
return getValue("tracks", Collection.class).get();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Artist setTracks(Collection<Track> tracks) {
getValue("tracks", Collection.class).set(tracks);
@Override
public Artist setTracks(Collection<Track> tracks) {
getValue("tracks", Collection.class).set(tracks);
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultBase.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultBase.java
index
a75563b
..
345ebd2
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultBase.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultBase.java
@@
-22,29
+22,66
@@
import java.util.Map;
import java.util.Map.Entry;
/**
import java.util.Map.Entry;
/**
- * TODO
+ * Base implementation of a data container. It stores the ID of a container and
+ * can contain arbitrary attributes.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultBase implements Base {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultBase implements Base {
+ /** The ID of the data container. */
private final String id;
private final String id;
+ /** The attributes of the data container. */
private final Map<String, Value<?>> attributes = new HashMap<String, Value<?>>();
private final Map<String, Value<?>> attributes = new HashMap<String, Value<?>>();
+ /**
+ * Creates a new data container with the given ID.
+ *
+ * @param id
+ * The ID of the data container
+ */
protected DefaultBase(String id) {
this.id = id;
}
protected DefaultBase(String id) {
this.id = id;
}
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public String getId() {
return id;
}
@Override
public String getId() {
return id;
}
+ /**
+ * Returns whether the data container contains an attribute with the given
+ * name.
+ *
+ * @param name
+ * The name of the attribute to check for
+ * @return {@code true} if this data container contains an attribute with
+ * the given name, {@code false} otherwise
+ */
protected boolean hasValue(String name) {
return attributes.containsKey(name);
}
protected boolean hasValue(String name) {
return attributes.containsKey(name);
}
+ /**
+ * Returns the value of the attribute with the given name. If no value for
+ * the given attribute exists, one will be created, stored, and returned.
+ *
+ * @param <T>
+ * The type of the value to return
+ * @param name
+ * The name of the attribute to get
+ * @param clazz
+ * The class of the value
+ * @return The value of the attribute
+ */
@SuppressWarnings({ "unchecked" })
protected <T> Value<T> getValue(String name, Class<T> clazz) {
if (!attributes.containsKey(name)) {
@SuppressWarnings({ "unchecked" })
protected <T> Value<T> getValue(String name, Class<T> clazz) {
if (!attributes.containsKey(name)) {
@@
-53,6
+90,12
@@
public class DefaultBase implements Base {
return (Value<T>) attributes.get(name);
}
return (Value<T>) attributes.get(name);
}
+ /**
+ * Returns whether any of the attributes of this data container is dirty,
+ * i.e. it was modified after its initial inception.
+ *
+ * @return {@code true} if any attribute of this data container was modified
+ */
protected boolean isDirty() {
for (Value<?> value : attributes.values()) {
if (value.isDirty()) {
protected boolean isDirty() {
for (Value<?> value : attributes.values()) {
if (value.isDirty()) {
@@
-100,18
+143,46
@@
public class DefaultBase implements Base {
return stringBuilder.toString();
}
return stringBuilder.toString();
}
+ /**
+ * Container for an attribute value stored in a data container.
+ *
+ * @see DefaultBase#attributes
+ * @param <T>
+ * The type of the value
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
protected static class Value<T> {
protected static class Value<T> {
+ /** The original value. */
private T original;
private T original;
+ /** Whether the original value has been set. */
private boolean originalSet;
private boolean originalSet;
+ /** The current value. */
private T current;
private T current;
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the current value.
+ *
+ * @return The current value
+ */
public T get() {
return current;
}
public T get() {
return current;
}
+ /**
+ * Sets the current value. If no original value has yet been set, the
+ * given value is also stored as original value.
+ *
+ * @param value
+ * The value to set
+ * @return This value
+ */
public Value<T> set(T value) {
if (!originalSet) {
original = value;
public Value<T> set(T value) {
if (!originalSet) {
original = value;
@@
-121,10
+192,24
@@
public class DefaultBase implements Base {
return this;
}
return this;
}
+ /**
+ * Returns whether the value of this value does not equal its original
+ * value.
+ *
+ * @return {@code true} if the current value is not equal to the
+ * original value, {@code false} if it is equal to the original
+ * value
+ */
public boolean isDirty() {
return (original != null) ? !original.equals(current) : current != null;
}
public boolean isDirty() {
return (original != null) ? !original.equals(current) : current != null;
}
+ /**
+ * Commits the current value, i.e. sets the original value to the
+ * current value.
+ *
+ * @return This value
+ */
public Value<T> commit() {
original = current;
return this;
public Value<T> commit() {
original = current;
return this;
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java
index
aae28e3
..
437fadb
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java
@@
-20,16
+20,26
@@
package net.pterodactylus.demoscenemusic.data;
import java.util.Collection;
/**
import java.util.Collection;
/**
- *
TODO
+ *
Default implementation of a group data container.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultGroup extends DefaultBase implements Group {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultGroup extends DefaultBase implements Group {
+ /**
+ * Creates a new group data container.
+ *
+ * @param id
+ * The ID of the group
+ */
public DefaultGroup(String id) {
super(id);
}
public DefaultGroup(String id) {
super(id);
}
+ //
+ // GROUP METHODS
+ //
+
/**
* {@inheritDoc}
*/
/**
* {@inheritDoc}
*/
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultParty.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultParty.java
index
f30a42f
..
993d69a
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultParty.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultParty.java
@@
-18,21
+18,37
@@
package net.pterodactylus.demoscenemusic.data;
/**
package net.pterodactylus.demoscenemusic.data;
/**
- *
TODO
+ *
Default implementation of a party data container.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultParty extends DefaultBase implements Party {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultParty extends DefaultBase implements Party {
+ /**
+ * Creates a new party data container.
+ *
+ * @param id
+ * The ID of the party
+ */
public DefaultParty(String id) {
super(id);
}
public DefaultParty(String id) {
super(id);
}
+ //
+ // PARTY METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public String getName() {
return getValue("name", String.class).get();
}
@Override
public String getName() {
return getValue("name", String.class).get();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public DefaultParty setName(String name) {
getValue("name", String.class).set(name);
@Override
public DefaultParty setName(String name) {
getValue("name", String.class).set(name);
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultStyle.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultStyle.java
index
19995e2
..
1b6ae3c
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultStyle.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultStyle.java
@@
-18,21
+18,37
@@
package net.pterodactylus.demoscenemusic.data;
/**
package net.pterodactylus.demoscenemusic.data;
/**
- *
TODO
+ *
Default implementation of a style data container.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultStyle extends DefaultBase implements Style {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultStyle extends DefaultBase implements Style {
+ /**
+ * Creates a new style data container.
+ *
+ * @param id
+ * The ID of the style
+ */
public DefaultStyle(String id) {
super(id);
}
public DefaultStyle(String id) {
super(id);
}
+ //
+ // STYLE METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public String getName() {
return getValue("name", String.class).get();
}
@Override
public String getName() {
return getValue("name", String.class).get();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Style setName(String name) {
getValue("name", String.class).set(name);
@Override
public Style setName(String name) {
getValue("name", String.class).set(name);
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrack.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrack.java
index
de84cdb
..
b357517
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrack.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultTrack.java
@@
-21,45
+21,73
@@
import java.util.Collection;
import java.util.List;
/**
import java.util.List;
/**
- *
TODO
+ *
Default implementation of a track data container.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultTrack extends DefaultBase implements Track {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public class DefaultTrack extends DefaultBase implements Track {
+ /**
+ * Creates a new track data container.
+ *
+ * @param id
+ * The ID of the track
+ */
public DefaultTrack(String id) {
super(id);
}
public DefaultTrack(String id) {
super(id);
}
+ //
+ // TRACK METHODS
+ //
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public String getName() {
return getValue("name", String.class).get();
}
@Override
public String getName() {
return getValue("name", String.class).get();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Track setName(String name) {
getValue("name", String.class).set(name);
return this;
}
@Override
public Track setName(String name) {
getValue("name", String.class).set(name);
return this;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
@SuppressWarnings("unchecked")
public List<Artist> getArtists() {
return getValue("artists", List.class).get();
}
@Override
@SuppressWarnings("unchecked")
public List<Artist> getArtists() {
return getValue("artists", List.class).get();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Track setArtists(List<Artist> artists) {
getValue("artists", List.class).set(artists);
return this;
}
@Override
public Track setArtists(List<Artist> artists) {
getValue("artists", List.class).set(artists);
return this;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
@SuppressWarnings("unchecked")
public Collection<Style> getStyles() {
return getValue("styles", Collection.class).get();
}
@Override
@SuppressWarnings("unchecked")
public Collection<Style> getStyles() {
return getValue("styles", Collection.class).get();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Track setStyles(Collection<? extends Style> styles) {
getValue("styles", Collection.class).set(styles);
@Override
public Track setStyles(Collection<? extends Style> styles) {
getValue("styles", Collection.class).set(styles);
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/Group.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/Group.java
index
bba8866
..
054b303
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/Group.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/Group.java
@@
-20,22
+20,58
@@
package net.pterodactylus.demoscenemusic.data;
import java.util.Collection;
/**
import java.util.Collection;
/**
- *
TODO
+ *
Data interface for groups.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Group extends Base {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Group extends Base {
+ /**
+ * Returns the name of this group.
+ *
+ * @return The name of this group
+ */
public String getName();
public String getName();
+ /**
+ * Sets the name of this group.
+ *
+ * @param name
+ * The name of this group
+ * @return This group
+ */
public Group setName(String name);
public Group setName(String name);
+ /**
+ * Returns the URL of this group’s website.
+ *
+ * @return The URL of this group’s website
+ */
public String getUrl();
public String getUrl();
+ /**
+ * Sets the URL of this group’s website.
+ *
+ * @param url
+ * The URL of this group’s website
+ * @return This group
+ */
public Group setUrl(String url);
public Group setUrl(String url);
+ /**
+ * Returns all artists belonging to this group.
+ *
+ * @return All artists belonging to this group
+ */
public Collection<Artist> getArtists();
public Collection<Artist> getArtists();
+ /**
+ * Sets all artists belonging to this group.
+ *
+ * @param artists
+ * All artists belonging to this group
+ * @return This group
+ */
public Group setArtists(Collection<Artist> artists);
}
public Group setArtists(Collection<Artist> artists);
}
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/Party.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/Party.java
index
4e2e93b
..
8ce4bcc
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/Party.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/Party.java
@@
-17,16
+17,27
@@
package net.pterodactylus.demoscenemusic.data;
package net.pterodactylus.demoscenemusic.data;
-
/**
/**
- *
TODO
+ *
Data interface for parties.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Party extends Base {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Party extends Base {
+ /**
+ * Returns the name of this party.
+ *
+ * @return The name of this party
+ */
public String getName();
public String getName();
+ /**
+ * Sets the name of this party.
+ *
+ * @param name
+ * The name of this party
+ * @return This party
+ */
public Party setName(String name);
}
public Party setName(String name);
}
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/Style.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/Style.java
index
6f572eb
..
3a2926d
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/Style.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/Style.java
@@
-18,14
+18,26
@@
package net.pterodactylus.demoscenemusic.data;
/**
package net.pterodactylus.demoscenemusic.data;
/**
- *
TODO
+ *
Data interface for styles.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Style extends Base {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Style extends Base {
+ /**
+ * Returns the name of this style.
+ *
+ * @return The name of this style
+ */
public String getName();
public String getName();
+ /**
+ * Sets the name of this style.
+ *
+ * @param name
+ * The name of this style
+ * @return This style
+ */
public Style setName(String name);
}
public Style setName(String name);
}
diff --git
a/src/main/java/net/pterodactylus/demoscenemusic/data/Track.java
b/src/main/java/net/pterodactylus/demoscenemusic/data/Track.java
index
ace6bd3
..
204cb77
100644
(file)
--- a/
src/main/java/net/pterodactylus/demoscenemusic/data/Track.java
+++ b/
src/main/java/net/pterodactylus/demoscenemusic/data/Track.java
@@
-21,22
+21,58
@@
import java.util.Collection;
import java.util.List;
/**
import java.util.List;
/**
- *
TODO
+ *
Data interface for tracks.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Track extends Base {
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
public interface Track extends Base {
+ /**
+ * Returns the name of this track.
+ *
+ * @return The name of this track
+ */
public String getName();
public String getName();
+ /**
+ * Sets the name of this track.
+ *
+ * @param name
+ * The name of this track
+ * @return This track
+ */
public Track setName(String name);
public Track setName(String name);
+ /**
+ * Returns all artists involved in this track.
+ *
+ * @return All involved artists in preferred order
+ */
public List<Artist> getArtists();
public List<Artist> getArtists();
+ /**
+ * Sets all artists involved in this track.
+ *
+ * @param artists
+ * All involved artists in preferred order
+ * @return This track
+ */
public Track setArtists(List<Artist> artists);
public Track setArtists(List<Artist> artists);
+ /**
+ * Returns all styles of this track.
+ *
+ * @return All styles of this track
+ */
public Collection<Style> getStyles();
public Collection<Style> getStyles();
+ /**
+ * Sets all styles of this track.
+ *
+ * @param styles
+ * All styles of this track
+ * @return This track
+ */
public Track setStyles(Collection<? extends Style> styles);
}
public Track setStyles(Collection<? extends Style> styles);
}