Better way to instantiate child classes with shared interface/baseclass
<p>I'm new to Java so this is likely pretty easy. I have a series of subclasses that share most variables/methods with an interface, but each child class has a few additional methods unique to their type which is why I designed the code this way.</p>

<p>However, when I retrieve data from a database (the data is stored in the same format for every subclass I have) I'd like to be able to create an instance of a base class or something that I can easily either cast to the subclass I need or have some sort of factory to give me a child class instance.</p>

<p>This is the code I have now, it just checks what type the data is for and then creates a new instance of the subclass but it feels so repetitive to me.</p>

<p>Anything better?</p>

<pre><code>                if( rs.getString("action_type").equals("block-break") || rs.getString("action_type").equals("block-place") ){
                actions.add( new BlockAction(
                        rs.getString("action_time"),
                        rs.getString("action_type"),
                        rs.getString("world"),
                        rs.getString("player"),
                        rs.getInt("x"),
                        rs.getInt("y"),
                        rs.getInt("z"),
                        rs.getString("data")
                    ) );
            }

            if( rs.getString("action_type").equals("entity-kill") ){
                actions.add( new EntityKillAction(
                        rs.getString("action_time"),
                        rs.getString("action_type"),
                        rs.getString("world"),
                        rs.getString("player"),
                        rs.getInt("x"),
                        rs.getInt("y"),
                        rs.getInt("z"),
                        rs.getString("data")
                    ) );
            }
</code></pre>
