title: Getting public fields (and their respective values) of an Instance in Scala/Java
body: <p><a href="http://php.net/manual/en/function.get-object-vars.php" rel="noreferrer">PHP introduces a method that allows you to pick out all public values of an instance.</a> Is there any way to do this in Scala? That is to fetch all values of all public fields of an instantiated class (not object).</p>
  
  <p>Let's us assume I have this class</p>
  
  <pre><code>class TestElement( datatype: Datatype, var subject: String, var day: Int, var time: Int )
    extends DataElement( datatype: Datatype ) {    
     def to( group: Group ) = group.add( this );
  }
  
  var element = new TestElement( datatype, "subject", 1, 1 );
  </code></pre>
  
  <p>What I need from the method in question, is to get a Map or two Collections of values.</p>
  
  <pre><code>var element.method                                       // the function I need
  ret: ( ("subject", "subject"), ("day", 1), ("time", 1) ) // its output
  </code></pre>