@Test public void testGetNonExistent() { assertEquals(null, server.get(GraphName.of("/foo"))); assertEquals(null, server.get(GraphName.of("/foo/bar"))); }
@SuppressWarnings("unchecked") public Object get(GraphName name) { Preconditions.checkArgument(name.isGlobal()); Stack<String> parts = getGraphNameParts(name); Object possibleSubtree = tree; while (!parts.empty() && possibleSubtree != null) { if (!(possibleSubtree instanceof Map)) { return null; } possibleSubtree = ((Map<String, Object>) possibleSubtree).get(parts.pop()); } return possibleSubtree; }
ParameterServer { @SuppressWarnings("unchecked") public Object get(GraphName name) { Preconditions.checkArgument(name.isGlobal()); Stack<String> parts = getGraphNameParts(name); Object possibleSubtree = tree; while (!parts.empty() && possibleSubtree != null) { if (!(possibleSubtree instanceof Map)) { return null; } possibleSubtree = ((Map<String, Object>) possibleSubtree).get(parts.pop()); } return possibleSubtree; } }
ParameterServer { @SuppressWarnings("unchecked") public Object get(GraphName name) { Preconditions.checkArgument(name.isGlobal()); Stack<String> parts = getGraphNameParts(name); Object possibleSubtree = tree; while (!parts.empty() && possibleSubtree != null) { if (!(possibleSubtree instanceof Map)) { return null; } possibleSubtree = ((Map<String, Object>) possibleSubtree).get(parts.pop()); } return possibleSubtree; } ParameterServer(); }
ParameterServer { @SuppressWarnings("unchecked") public Object get(GraphName name) { Preconditions.checkArgument(name.isGlobal()); Stack<String> parts = getGraphNameParts(name); Object possibleSubtree = tree; while (!parts.empty() && possibleSubtree != null) { if (!(possibleSubtree instanceof Map)) { return null; } possibleSubtree = ((Map<String, Object>) possibleSubtree).get(parts.pop()); } return possibleSubtree; } ParameterServer(); void subscribe(GraphName name, NodeIdentifier nodeIdentifier); @SuppressWarnings("unchecked") Object get(GraphName name); void set(final GraphName name, final boolean value); void set(final GraphName name, final int value); void set(final GraphName name, final double value); void set(final GraphName name, final String value); void set(final GraphName name, final List<?> value); void set(final GraphName name, final Map<?, ?> value); @SuppressWarnings("unchecked") void delete(GraphName name); Object search(GraphName namespace, GraphName name); @SuppressWarnings("unchecked") boolean has(GraphName name); Collection<GraphName> getNames(); }
ParameterServer { @SuppressWarnings("unchecked") public Object get(GraphName name) { Preconditions.checkArgument(name.isGlobal()); Stack<String> parts = getGraphNameParts(name); Object possibleSubtree = tree; while (!parts.empty() && possibleSubtree != null) { if (!(possibleSubtree instanceof Map)) { return null; } possibleSubtree = ((Map<String, Object>) possibleSubtree).get(parts.pop()); } return possibleSubtree; } ParameterServer(); void subscribe(GraphName name, NodeIdentifier nodeIdentifier); @SuppressWarnings("unchecked") Object get(GraphName name); void set(final GraphName name, final boolean value); void set(final GraphName name, final int value); void set(final GraphName name, final double value); void set(final GraphName name, final String value); void set(final GraphName name, final List<?> value); void set(final GraphName name, final Map<?, ?> value); @SuppressWarnings("unchecked") void delete(GraphName name); Object search(GraphName namespace, GraphName name); @SuppressWarnings("unchecked") boolean has(GraphName name); Collection<GraphName> getNames();  }