Files
VisualSapfor/src/Common/Passes/All/UpdateProperty.java

29 lines
942 B
Java
Raw Normal View History

package Common.Passes.All;
import Common.Global;
import Common.GlobalProperties;
import Common.Passes.Pass_2021;
import java.lang.reflect.Field;
public class UpdateProperty extends Pass_2021<Object> {
//todo в дальнейшем, все настройки перевести в properties, и перенести сюда функционал UpdateSetting (?)
String name = "";
Field field = null;
Object oldValue = null;
Object newValue = null;
@Override
protected boolean canStart(Object... args) throws Exception {
name = (String) args[0];
newValue = args[1];
//--
field = GlobalProperties.class.getField(name);
oldValue = field.get(Global.properties);
//---
return !newValue.equals(oldValue);
}
@Override
protected void body() throws Exception {
field.set(Global.properties, newValue);
Global.properties.Update();
}
}