You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.3 KiB

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package moe.nekojimi.charactermaker.steps;
import java.lang.reflect.InvocationTargetException;
import moe.nekojimi.charactermaker.Main;
import org.apache.commons.beanutils.PropertyUtils;
public class ChangePropertyStep extends ChangeValueStep
{
private final String propName;
public ChangePropertyStep(int change, String name, String propName)
{
super(change, name);
this.propName = propName;
}
@Override
protected int read()
{
try
{
return (int) PropertyUtils.getSimpleProperty(Main.character, propName);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex)
{
// Logger.getLogger(ChangePropertyStep.class.getName()).log(Level.SEVERE, null, ex);
throw new RuntimeException(ex);
}
}
@Override
protected void write(int val)
{
try
{
PropertyUtils.setSimpleProperty(Main.character, propName, val);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex)
{
// Logger.getLogger(ChangePropertyStep.class.getName()).log(Level.SEVERE, null, ex);
throw new RuntimeException(ex);
}
}
}