Java—how can I dynamically reference an object's property?
<p>In javascript, I can do this:</p>

<pre><code>function MyObject(obj) {
    for (var property in obj) {
        this[property] = obj[property];
    }
}
</code></pre>

<p>Can I do anything close in Java?</p>

<pre><code>class MyObject {
    String myProperty;

    public MyObject(HashMap&lt;String, String&gt; props) {
        // for each key in props where the key is also the name of
        // a property in MyObject, can I assign the value to this.[key]?
    }
}
</code></pre>
