title: Java EnumMap; cannot cast the keys to their Enums
body: <p>I'm giving an EnumMap to a method where I try to access the value's as follows:</p>
  
  <pre><code>_playerActionTimeout = (Integer) config.get( Config.Table.PLAYER_TIMEOUT );
  </code></pre>
  
  <p>But this is telling me that I cannot cast Config.Table to Config.Table. The Config bit looks like this:</p>
  
  <pre><code>static public enum Table
  {
      PLAYER_TIMEOUT( "playerTimeout", Integer.class ),
      PLAYER_STARTCHIPS( "playerStartChips", Integer.class ),
      INITIAL_SMALLBLIND( "initialSmallBlind", Integer.class ),
      INITIAL_BIGBLIND( "initialBigBlind", Integer.class ),
      BLIND_INCREASE( "blindIncrease", SortedMap.class ),
      ROUND_STARTTIMEOUT( "roundStartTimeout", Integer.class );
      //
      private final String _xmlTag;
      private final Class _classType;
  
      Table( String xmlTag, Class classType )
      {
          _xmlTag = xmlTag;
          _classType = classType;
      }
  
      public final String getXmlTag()
      {
          return _xmlTag;
      }
  
      public final Class getParameterClass()
      {
          return _classType;
      }
  }
  </code></pre>
  
  <p>If i iterate over the EnumMap all the values and keys are present and trace out fine. But when i try to get a value using the Enum, it will be zero and the error occurs.  What am I doing wrong?</p>
  
  <p>As requested. Here is part of the class that creates the config:</p>
  
  <pre><code>private EnumMap&lt;Config.Table, Object&gt; _tableConfig;
  
  public void init()
  {
  if ( _tableConfig == null )
      {
          _tableConfig = new EnumMap&lt;Config.Table, Object&gt;( Config.Table.class );
      }
  }
  private void parseConfigFile( String definedZoneName ) throws Exception
  {
      //try
      {
          /** START of read config file **/
          IXMLElement config = this.loadConfig( "config.xml" );
          if ( config == null )
          {
              throw new Exception( "No config file was found! or XML zones configuration invalid : no zone found" );
          }
          IXMLElement zones = config.getFirstChildNamed( "Zones" );
          //So far so good
          for ( int zoneIndex = 0; zoneIndex &lt; zones.getChildrenCount(); ++zoneIndex )
          {
              IXMLElement xmlZone = zones.getChildAtIndex( zoneIndex );
              if ( xmlZone.getAttribute( "name" ).equalsIgnoreCase( definedZoneName ) )
              {
              //Table config
              {
                  IXMLElement tableConfig = xmlZone.getFirstChildNamed( "TableConfig" );
                  for ( int tableElIndex = 0; tableElIndex &lt; tableConfig.getChildrenCount(); ++tableElIndex )
                  {
                      IXMLElement zoneElement = tableConfig.getChildAtIndex( tableElIndex );
  
                      for ( Config.Table configTable : Config.Table.values() )
                      {
                          if ( zoneElement.getName().equals( configTable.getXmlTag() ) )
                          {
                              String value = zoneElement.getContent();
                              Class parameterClass = configTable.getParameterClass();
                              if ( parameterClass.equals( Integer.class ) )
                              {
                                  _tableConfig.put( configTable, Integer.parseInt( value ) );
                              }
                              else if ( parameterClass.equals( SortedMap.class ) )
                              {
                                  SortedMap&lt;Integer, Config.Blinds&gt; increaseBlinds = new TreeMap&lt;Integer, Config.Blinds&gt;();
                                  //Loop through all &lt;increase&gt; elements
                                  for ( int increaseElIndex = 0; increaseElIndex &lt; zoneElement.getChildrenCount(); ++increaseElIndex )
                                  {
                                      IXMLElement increaseElement = zoneElement.getChildAtIndex( increaseElIndex );
  
                                      String sTime = increaseElement.getFirstChildNamed( "time" ).getContent();
                                      String sSmallBlind = increaseElement.getFirstChildNamed( "smallBlind" ).getContent();
                                      String sBigBlind = increaseElement.getFirstChildNamed( "bigBlind" ).getContent();
  
                                      Integer time = Integer.parseInt( sTime );
                                      Integer smallBlind = Integer.parseInt( sSmallBlind );
                                      Integer bigBlind = Integer.parseInt( sBigBlind );
  
                                      Config.Blinds blinds = new Config.Blinds( smallBlind, bigBlind );
  
                                      increaseBlinds.put( time, blinds );
                                  }
  
                                  _tableConfig.put( configTable, increaseBlinds );
                              }
                              else //if ( parameterClass.equals( String.class ) )
                              {
                                  _tableConfig.put( configTable, value );
                              }
                              break;
                          }
                      }
                  }
              }
          }
      }
      Stack&lt;String&gt; missingFields = new Stack&lt;String&gt;();
  
      for ( Config.Zone configZone : Config.Zone.values() )
      {
          if ( !_zoneConfig.containsKey( configZone ) )
          {
              missingFields.add( configZone.getXmlTag() );
          }
      }
  
      if ( missingFields.size() &gt; 0 )
      {
          throw new Exception( "We were not able to read these Zone settings from the config.xml : " + missingFields.toString() + ". Please check your setup." );
      }
  
      missingFields.clear();
      for ( Config.Table configTable : Config.Table.values() )
      {
          if ( !_tableConfig.containsKey( configTable ) )
          {
              missingFields.add( configTable.getXmlTag() );
          }
      }
  
      if ( missingFields.size() &gt; 0 )
      {
          throw new Exception( "We were not able to read these Table settings from the config.xml : " + missingFields.toString() + ". Please check your setup." );
      }
  }
  }
  </code></pre>