}
populateValueRequest.getFieldManager().setFieldValue(instance, populateValueRequest.getProperty().getName(), mvel);
}
if (SimpleRule.class.isAssignableFrom(valueType)) {
//see if there's an existing rule
SimpleRule rule;
try {
rule = (SimpleRule) populateValueRequest.getFieldManager().getFieldValue(instance, populateValueRequest.getProperty().getName());
} catch (FieldNotAvailableException e) {
throw new IllegalArgumentException(e);
}
if (mvel == null) {
//cause the rule to be deleted
dirty = populateValueRequest.getFieldManager().getFieldValue(instance, populateValueRequest.getProperty().getName()) != null;
populateValueRequest.getFieldManager().setFieldValue(instance, populateValueRequest.getProperty().getName(), null);
} else if (rule != null) {
dirty = !rule.getMatchRule().equals(mvel);
rule.setMatchRule(mvel);
} else {
//create a new instance, persist and set
dirty = true;
rule = (SimpleRule) valueType.newInstance();
rule.setMatchRule(mvel);
populateValueRequest.getPersistenceManager().getDynamicEntityDao().persist(rule);
populateValueRequest.getFieldManager().setFieldValue(instance, populateValueRequest.getProperty().getName(), rule);
}
}
}