Skip to content

Commit

Permalink
creates default entity tree
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviojava committed Nov 26, 2019
1 parent ba6871b commit 6576a1f
Showing 1 changed file with 52 additions and 0 deletions.
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2019 Otávio Santana and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
*
* You may elect to redistribute this code under either of these licenses.
*
* Contributors:
*
* Otavio Santana
*/
package org.eclipse.jnosql.artemis.graph;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* The default implementation of {@link EntityTree}
*/
final class DefaultEntityTree implements EntityTree {

private final Object data;

private final List<EntityTree> children = new ArrayList<>();

DefaultEntityTree(Object data) {
this.data = data;
}

void add(EntityTree tree) {
this.children.add(tree);
}

@Override
public <T> T getData() {
return (T) data;
}

@Override
public List<EntityTree> getChildren() {
return Collections.unmodifiableList(children);
}

@Override
public boolean isLeaf() {
return children.isEmpty();
}
}

0 comments on commit 6576a1f

Please sign in to comment.