com.netflix.nfgraph.spec
Class NFGraphSpec

java.lang.Object
  extended by com.netflix.nfgraph.spec.NFGraphSpec
All Implemented Interfaces:
java.lang.Iterable<NFNodeSpec>

public class NFGraphSpec
extends java.lang.Object
implements java.lang.Iterable<NFNodeSpec>

An NFGraphSpec defines the schema for a graph. It contains a mapping of node type name to NFNodeSpecs.

The example code below will create two node types "a" and "b". An "a" node can be connected to "b" nodes via the properties "a-to-one-b" and/or "a-to-many-b". A "b" node can be connected to "a" nodes via the property "b-to-many-a".

 NFGraphSpec spec = new NFGraphSpec(
     new NFNodeSpec(
         "a",
         new NFPropertySpec("a-to-one-b",  "b", NFPropertySpec.SINGLE),
         new NFPropertySpec("a-to-many-b", "b", NFPropertySpec.MULTIPLE | NFPropertySpec.COMPACT)
     ),
     new NFNodeSpec(
         "b",
         new NFPropertySpec("b-to-many-a", "a", NFPropertySpec.MULTIPLE | NFPropertySpec.HASH)
     )
 );
 
 
 

See Also:
NFNodeSpec, NFPropertySpec

Constructor Summary
NFGraphSpec()
          Instantiate a graph specification with no NFNodeSpecs.
NFGraphSpec(NFNodeSpec... nodeTypes)
          Instantiate a graph specification with the given NFNodeSpec.
 
Method Summary
 void addNodeSpec(NFNodeSpec nodeSpec)
          Add a node type to this graph specification.
 NFNodeSpec getNodeSpec(java.lang.String nodeType)
           
 java.util.List<java.lang.String> getNodeTypes()
           
 java.util.Iterator<NFNodeSpec> iterator()
          Returns an Iterator over the NFNodeSpecs contained in this graph specification.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NFGraphSpec

public NFGraphSpec()
Instantiate a graph specification with no NFNodeSpecs.


NFGraphSpec

public NFGraphSpec(NFNodeSpec... nodeTypes)
Instantiate a graph specification with the given NFNodeSpec.

Method Detail

getNodeSpec

public NFNodeSpec getNodeSpec(java.lang.String nodeType)
Returns:
the NFNodeSpec for the specified node type.

addNodeSpec

public void addNodeSpec(NFNodeSpec nodeSpec)
Add a node type to this graph specification.


size

public int size()
Returns:
the number of node types defined by this graph specification.

getNodeTypes

public java.util.List<java.lang.String> getNodeTypes()
Returns:
a List containing the names of each of the node types.

iterator

public java.util.Iterator<NFNodeSpec> iterator()
Returns an Iterator over the NFNodeSpecs contained in this graph specification.

Specified by:
iterator in interface java.lang.Iterable<NFNodeSpec>