-
-
Notifications
You must be signed in to change notification settings - Fork 26.1k
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
Showing
4 changed files
with
118 additions
and
99 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,61 +1,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true" | ||
realizations="true" associations="true" dependencies="false" nesting-relationships="true"> | ||
<interface id="1" language="java" name="com.iluwatar.Node" project="null-object" | ||
file="/null-object/src/main/java/com/iluwatar/Node.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="535" y="139"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</interface> | ||
<class id="2" language="java" name="com.iluwatar.NodeImpl" project="null-object" | ||
file="/null-object/src/main/java/com/iluwatar/NodeImpl.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="857" y="348"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<class id="3" language="java" name="com.iluwatar.NullNode" project="null-object" | ||
file="/null-object/src/main/java/com/iluwatar/NullNode.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="535" y="408"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<association id="4"> | ||
<end type="SOURCE" refId="2" navigable="false"> | ||
<attribute id="5" name="left"/> | ||
<multiplicity id="6" minimum="0" maximum="1"/> | ||
</end> | ||
<end type="TARGET" refId="1" navigable="true"/> | ||
<display labels="true" multiplicity="true"/> | ||
</association> | ||
<association id="7"> | ||
<end type="SOURCE" refId="2" navigable="false"> | ||
<attribute id="8" name="right"/> | ||
<multiplicity id="9" minimum="0" maximum="1"/> | ||
</end> | ||
<end type="TARGET" refId="1" navigable="true"/> | ||
<display labels="true" multiplicity="true"/> | ||
</association> | ||
<realization id="10"> | ||
<end type="SOURCE" refId="2"/> | ||
<end type="TARGET" refId="1"/> | ||
</realization> | ||
<realization id="11"> | ||
<end type="SOURCE" refId="3"/> | ||
<end type="TARGET" refId="1"/> | ||
</realization> | ||
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</classifier-display> | ||
<association-display labels="true" multiplicity="true"/> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true" | ||
realizations="true" associations="true" dependencies="false" nesting-relationships="true"> | ||
<class id="1" language="java" name="com.iluwatar.NullNode" project="null-object" | ||
file="/null-object/src/main/java/com/iluwatar/NullNode.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="123" y="427"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<interface id="2" language="java" name="com.iluwatar.Node" project="null-object" | ||
file="/null-object/src/main/java/com/iluwatar/Node.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="123" y="164"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</interface> | ||
<class id="3" language="java" name="com.iluwatar.NodeImpl" project="null-object" | ||
file="/null-object/src/main/java/com/iluwatar/NodeImpl.java" binary="false" corner="BOTTOM_RIGHT"> | ||
<position height="-1" width="-1" x="399" y="164"/> | ||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</display> | ||
</class> | ||
<association id="4"> | ||
<end type="SOURCE" refId="1" navigable="false"> | ||
<attribute id="5" name="instance"/> | ||
<multiplicity id="6" minimum="0" maximum="1"/> | ||
</end> | ||
<end type="TARGET" refId="1" navigable="true"/> | ||
<display labels="true" multiplicity="true"/> | ||
</association> | ||
<realization id="7"> | ||
<end type="SOURCE" refId="1"/> | ||
<end type="TARGET" refId="2"/> | ||
</realization> | ||
<association id="8"> | ||
<end type="SOURCE" refId="3" navigable="false"> | ||
<attribute id="9" name="right"/> | ||
<multiplicity id="10" minimum="0" maximum="1"/> | ||
</end> | ||
<end type="TARGET" refId="2" navigable="true"/> | ||
<display labels="true" multiplicity="true"/> | ||
</association> | ||
<realization id="11"> | ||
<end type="SOURCE" refId="3"/> | ||
<end type="TARGET" refId="2"/> | ||
</realization> | ||
<association id="12"> | ||
<end type="SOURCE" refId="3" navigable="false"> | ||
<attribute id="13" name="left"/> | ||
<multiplicity id="14" minimum="0" maximum="1"/> | ||
</end> | ||
<end type="TARGET" refId="2" navigable="true"/> | ||
<display labels="true" multiplicity="true"/> | ||
</association> | ||
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" | ||
sort-features="false" accessors="true" visibility="true"> | ||
<attributes public="true" package="true" protected="true" private="true" static="true"/> | ||
<operations public="true" package="true" protected="true" private="true" static="true"/> | ||
</classifier-display> | ||
<association-display labels="true" multiplicity="true"/> | ||
</class-diagram> |
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
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 |
---|---|---|
@@ -1,33 +1,44 @@ | ||
package com.iluwatar; | ||
|
||
/** | ||
* | ||
* Null Object implementation for binary tree node. | ||
* | ||
*/ | ||
public class NullNode implements Node { | ||
|
||
@Override | ||
public int getTreeSize() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public Node getLeft() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Node getRight() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void walk() { | ||
} | ||
} | ||
package com.iluwatar; | ||
|
||
/** | ||
* | ||
* Null Object implementation for binary tree node. | ||
* | ||
* Implemented as Singleton, since all the NullNodes are the same. | ||
* | ||
*/ | ||
public class NullNode implements Node { | ||
|
||
private static NullNode instance = new NullNode(); | ||
|
||
private NullNode() { | ||
} | ||
|
||
public static NullNode getInstance() { | ||
return instance; | ||
} | ||
|
||
@Override | ||
public int getTreeSize() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public Node getLeft() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Node getRight() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void walk() { | ||
} | ||
} |