Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba6871b
commit 6576a1f
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
artemis/artemis-graph/src/main/java/org/eclipse/jnosql/artemis/graph/DefaultEntityTree.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |