私はJavaMVCパターンを学習しようとしていますが、次の方法を理解できません。
protected void setModelProperty(String propertyName, Object newValue) {
for (AbstractModel model: registeredModels) {
try {
Method method = model.getClass().
getMethod("set"+propertyName, new Class[] {
newValue.getClass()
}
);
method.invoke(model, newValue);
} catch (Exception ex) {
// Handle exception
}
}
}
私は理解していません:
Method method = model.getClass().
getMethod("set"+propertyName, new Class[] {
newValue.getClass()
}
);
したがって、getMethodでは、プロパティに従って(setSomething)メソッド名を取得します。次の「thing」は、まったく理解できないこの派手な式で表現されるnewValueとしてのプロパティ値です。
new Class[]
<---つまり、クラスの配列ですか?next { newValue.getClass() }
<---- OK、メソッドを呼び出してクラス名を角かっこで囲みますが、セミコロンはどうですか?私にはわからない特別な構造があるに違いありません。クラスのように見えますが、セミコロンがない場合は別の構造に違いありません...人々はこれが何であるかを説明してくれます...