title: Java initialising classes with populators in their constructor
body: <p>I have a repository of classes in a package, in their constructor, they populate a component of the server.</p>
  
  <p>For example:</p>
  
  <p>The master class:</p>
  
  <pre><code>public abstract class MessageDecoder&lt;T&gt; {
  
      public MessageDecoder(boolean logicType, Integer...opcodes) {
          for (int opcode : opcodes) {
              GameConstants.RELEASE.register(logicType, opcode, this);
          }
      }
  
      /**
       * Get the encoded message to send to the client.
       * 
       * @param the {@link GamePacket} ready to be read.
       * @return a constructed message ready to be handled.
       */
      public abstract T decode(GamePacket packet);
  
  }
  </code></pre>
  
  <p>And the repoistory classes look like:</p>
  
  <pre><code>public final class PlayerWalkPathMessageDecoder extends MessageDecoder&lt;PlayerWalkPathMessage&gt; {
  
      public PlayerWalkPathMessageDecoder() {
          super(true, 8, 58);
      }
  
      @Override 
      public PlayerWalkPathMessage decode(GamePacket packet) {
  
          return null;
      }
  
  }
  </code></pre>
  
  <p>In the master class you can see how the method </p>
  
  <pre><code>register(logicType, opcode, this); 
  </code></pre>
  
  <p>is being used to register the class to a </p>
  
  <pre><code>map &lt; Integer, MessageDecoder&lt; ? &gt; &gt;
  </code></pre>
  
  <p>But during runtime, the map will not be populated because the repository classes have not been constructed yet.</p>
  
  <p>This warrents me using an empty iterator to get the classes to be constructed:</p>
  
  <pre><code>Iterate.classes("bin/com/web/net/decoders", clazz -&gt; {
  
  
  });
  </code></pre>
  
  <p>Is there a better way to construct the classes located in a repository package?</p>