This repository has been archived by the owner on Nov 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- keys and tags have their own classes now
- Loading branch information
Showing
12 changed files
with
1,121 additions
and
941 deletions.
There are no files selected for viewing
417 changes: 211 additions & 206 deletions
417
...n/java/org/broadinstitute/hellbender/tools/coveragemodel/CoverageModelEMComputeBlock.java
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -13,32 +13,32 @@ | |
* | ||
* @author Mehrtash Babadi <[email protected]> | ||
*/ | ||
abstract class CacheNode { | ||
public abstract class CacheNode { | ||
/** | ||
* A string identifier for the cache node | ||
* A key for identifying this cache node | ||
*/ | ||
private final String key; | ||
private final NodeKey key; | ||
|
||
/** | ||
* The collection of string identifiers of the immediate parents of this node (can be empty) | ||
* The collection of lookup keys for parents of this node (can be empty) | ||
*/ | ||
private final Collection<String> parents; | ||
private final Collection<NodeKey> parents; | ||
|
||
/** | ||
* The collection of string identifiers of the tags associated to this node (can be empty) | ||
* The collection of tags associated to this node (can be empty) | ||
*/ | ||
private final Collection<String> tags; | ||
private final Collection<NodeTag> tags; | ||
|
||
/** | ||
* Public constructor | ||
* | ||
* @param key string identifier of the cache node | ||
* @param key lookup key of the cache node | ||
* @param tags the tags associated to this cache node | ||
* @param parents immediate parents of this cache node | ||
* @param parents lookup keys of the parents of this cache node | ||
*/ | ||
CacheNode(@Nonnull final String key, | ||
@Nonnull final Collection<String> tags, | ||
@Nonnull final Collection<String> parents) { | ||
CacheNode(@Nonnull final NodeKey key, | ||
@Nonnull final Collection<NodeTag> tags, | ||
@Nonnull final Collection<NodeKey> parents) { | ||
this.key = Utils.nonNull(key, "The key of a cache node can not be null"); | ||
this.tags = Collections.unmodifiableCollection(Utils.nonNull(tags, "The tag collection of a cache node can not be null")); | ||
this.parents = Collections.unmodifiableCollection(Utils.nonNull(parents, "The immediate parents of a cache node can not be null")); | ||
|
@@ -47,10 +47,10 @@ abstract class CacheNode { | |
/** | ||
* Get the value stored in the node | ||
* | ||
* @param parents parent values (as a map from their string identifiers to their values) | ||
* @param parents parent values (as a map from their keys to their values) | ||
* @return a {@link Duplicable}; possibly by reference | ||
*/ | ||
abstract Duplicable get(@Nonnull final Map<String, Duplicable> parents); | ||
abstract Duplicable get(@Nonnull final Map<NodeKey, Duplicable> parents); | ||
|
||
/** | ||
* Set the value of the node | ||
|
@@ -95,27 +95,27 @@ abstract class CacheNode { | |
* Get the string identifier of the node | ||
* @return a non-null {@link String} | ||
*/ | ||
final String getKey() { | ||
final NodeKey getKey() { | ||
return key; | ||
} | ||
|
||
/** | ||
* Get the collection of string identifier of the parents of this node (can be empty) | ||
* Get the collection of keys of the parents of this node (can be empty) | ||
*/ | ||
final Collection<String> getParents() { | ||
final Collection<NodeKey> getParents() { | ||
return Collections.unmodifiableCollection(parents); | ||
} | ||
|
||
/** | ||
* Get the collection of string identifier of the tags associated to this node (can be empty) | ||
* Get the collection of tags associated to this node (can be empty) | ||
*/ | ||
final Collection<String> getTags() { | ||
final Collection<NodeTag> getTags() { | ||
return Collections.unmodifiableCollection(tags); | ||
} | ||
|
||
@Override | ||
public final String toString() { | ||
return key; | ||
return key.toString(); | ||
} | ||
|
||
/** | ||
|
@@ -136,4 +136,66 @@ public final boolean equals(Object other) { | |
public final int hashCode() { | ||
return key.hashCode(); | ||
} | ||
|
||
/** | ||
* This class represents a node key. It is a wrapper around a String. | ||
*/ | ||
public static class NodeKey { | ||
private final String key; | ||
|
||
public NodeKey(final String key) { | ||
this.key = Utils.nonNull(key, "Node key must be non-null"); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return key; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
NodeKey nodeKey = (NodeKey) o; | ||
|
||
return key.equals(nodeKey.key); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return key.hashCode(); | ||
} | ||
} | ||
|
||
/** | ||
* This class represents a node tag. It is a wrapper around a String. | ||
*/ | ||
public static class NodeTag { | ||
private final String tag; | ||
|
||
public NodeTag(final String tag) { | ||
this.tag = Utils.nonNull(tag, "Node tag must be non-null"); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return tag; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
NodeTag nodeTag = (NodeTag) o; | ||
|
||
return tag.equals(nodeTag.tag); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return tag.hashCode(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.