I have a problem with apache Configuration. Is it possible to add objects and not the string representation of them?
For example, I would like to save the whole 'SiteNode' and not the "toString()" variant:
public void persistSiteTree(Context context, Configuration config) {
List<SiteNode> nodes = Model.getSingleton().getSession().getNodesInContextFromSiteTree(context);
config.addProperty(CONFIG_PROPERTY_AUTHORISATION, nodes);
}
public void loadSiteTree(Context context, Configuration config) {
List<Object> nodes = new ArrayList<>();
nodes = config.getList(CONFIG_PROPERTY_AUTHORISATION, nodes);
if(nodes != null && !nodes.isEmpty()) {
// Load in sites tree
SiteNode node = (SiteNode) nodes.get(0); // Gives error as String cannot be cast to "SiteNode"
}
}
But when I call 'loadSiteTree' it gives me String cannot be case to SiteNode. Is it possible for Apache to save the object?