-1
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);
        }
    }
}
2
  • It seems that people are still correcting the formatting of the code in your questions. Code doesn't appear nicely in a question or answer unless you format it as a 'code sample'. On stackexchange sites, a 'code' sample is marked by having at least 4 spaces on each line. The easy way to do this is, when writing a question (or an answer), selecting a section of code and then pressing the button that looks like an open and close curly bracket pair (or pressing ctrl and k at the same time on your keyboard).
    – Derek F
    Commented Jan 25, 2017 at 16:58
  • On a related note, code is almost always unreadable in comments. If you are prompted to provide additional code in a question or an answer, editing your question (or answer) is the way to go.
    – Derek F
    Commented Jan 25, 2017 at 16:59

1 Answer 1

1

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){

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .