Add object creator for groups.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 14:10:12 +0000 (16:10 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 14:10:12 +0000 (16:10 +0200)
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java

index 08fddf4..38ababe 100644 (file)
 
 package net.pterodactylus.demoscenemusic.data;
 
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import net.pterodactylus.util.database.ObjectCreator;
+
 /**
  * TODO
  *
@@ -24,6 +29,8 @@ package net.pterodactylus.demoscenemusic.data;
  */
 public class DefaultGroup extends DefaultBase implements Group {
 
+       public static final ObjectCreator<Group> CREATOR = new GroupCreator();
+
        public DefaultGroup(String id) {
                super(id);
        }
@@ -58,4 +65,16 @@ public class DefaultGroup extends DefaultBase implements Group {
                return this;
        }
 
+       private static class GroupCreator implements ObjectCreator<Group> {
+
+               /**
+                * {@inheritDoc}
+                */
+               @Override
+               public Group createObject(ResultSet resultSet) throws SQLException {
+                       return new DefaultGroup(resultSet.getString("GROUPS.ID")).name(resultSet.getString("GROUPS.NAME")).url(resultSet.getString("GROUPS.URL"));
+               }
+
+       }
+
 }