public class Nodeshierachy {
// Add child nodes
private static void addChildren(List<Account> accs, Map<Id,HierarchyNode> nodes, Set<Id> parent_acc_ids) {
for (Account acc : accs) {
HierarchyNode ref_node = nodes.get(acc.ParentId);
HierarchyNode new_node = new HierarchyNode(acc, ref_node);
nodes.put(acc.id, new_node);
if (ref_node != null) {
ref_node.children.add(new_node);
}
if (parent_acc_ids != null) {
parent_acc_ids.add(acc.id);
}
}
}
1 Answer
The problem comes from your HierarchyNode
class. Not the one you put in your question.
You just have to set the constructor public like this:
public HierarchyNode(Account account, HierarchyNode node){
ctrl
andk
at the same time on your keyboard).