當前位置: 首頁>>代碼示例>>Java>>正文


Java StringTypeValue類代碼示例

本文整理匯總了Java中org.manifold.compiler.StringTypeValue的典型用法代碼示例。如果您正苦於以下問題:Java StringTypeValue類的具體用法?Java StringTypeValue怎麽用?Java StringTypeValue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StringTypeValue類屬於org.manifold.compiler包,在下文中一共展示了StringTypeValue類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testAddSubExpressionGraph_correctGraphAdded

import org.manifold.compiler.StringTypeValue; //導入依賴的package包/類
@Test
public void testAddSubExpressionGraph_correctGraphAdded() throws Exception {
  // init main graph
  ExpressionGraph mainGraph = new ExpressionGraph();

  // input/output
  VariableIdentifier mainInput = new VariableIdentifier(ImmutableList.of("mainInput"));
  VariableIdentifier mainOutput = new VariableIdentifier(ImmutableList.of("mainOutput"));
  mainGraph.addVertex(mainInput);
  mainGraph.addVertex(mainOutput);

  ExpressionVertex mainInputVertex = mainGraph.getVariableVertex(mainInput);
  ExpressionVertex mainOutputVertex = mainGraph.getVariableVertex(mainOutput);

  // dummy vertex to remove
  ExpressionVertex dummyVertex = new ConstantValueVertex(mainGraph,
      new StringValue(StringTypeValue.getInstance(), "yo"));
  ExpressionEdge inputEdge = new ExpressionEdge(mainInputVertex, dummyVertex);
  ExpressionEdge outputEdge = new ExpressionEdge(dummyVertex, mainOutputVertex);
  mainGraph.addVertex(dummyVertex);
  mainGraph.addEdge(inputEdge);
  mainGraph.addEdge(outputEdge);

  // init subgraph
  ExpressionGraph subGraph = new ExpressionGraph();

  // input/output
  VariableIdentifier subInput = new VariableIdentifier(ImmutableList.of("subInput"));
  subGraph.addVertex(subInput);
  ExpressionVertex subInputEdgeVertex = subGraph.getVariableVertex(subInput);
  ExpressionEdge subGraphInputEdge = new ExpressionEdge(null, subInputEdgeVertex);
  subGraph.addEdge(subGraphInputEdge);

  VariableIdentifier dummyReturn = new VariableIdentifier(ImmutableList.of("returnValue"));
  subGraph.addVertex(dummyReturn);
  ExpressionVertex dummyReturnVertex = subGraph.getVariableVertex(dummyReturn);
  ExpressionEdge returnEdge = new ExpressionEdge(dummyReturnVertex, null);
  subGraph.addEdge(returnEdge);

  TupleValueVertex subInputVertex = new TupleValueVertex(subGraph,
          new MappedArray<>(ImmutableMap.of("a", subGraphInputEdge)));
  TupleValueVertex subOutputVertex = new TupleValueVertex(subGraph,
          new MappedArray<>(ImmutableMap.of("a", returnEdge)));

  subGraph.addVertex(subInputVertex);
  subGraph.addVertex(subOutputVertex);

  // intermediate nodes
  ExpressionVertex intermediate1 = new ConstantValueVertex(subGraph, BooleanValue.getInstance(true));
  ExpressionVertex intermediate2 = new ConstantValueVertex(subGraph, BooleanValue.getInstance(false));
  subGraph.addVertex(intermediate1);
  subGraph.addVertex(intermediate2);

  subGraph.addEdge(new ExpressionEdge(subInputVertex, intermediate1));
  subGraph.addEdge(new ExpressionEdge(subInputVertex, intermediate2));
  subGraph.addEdge(new ExpressionEdge(intermediate1, subOutputVertex));
  subGraph.addEdge(new ExpressionEdge(intermediate2, subOutputVertex));

  mainGraph.writeDOTFile(new File("build/mainGraph.txt"));
  subGraph.writeDOTFile(new File("build/subGraph.txt"));

  Map<VariableReferenceVertex, VariableReferenceVertex> dontRename = new HashMap<>();
  mainGraph.addFunctionExpressionGraph(subGraph, inputEdge, subInputVertex, outputEdge, subOutputVertex, dontRename);
  mainGraph.writeDOTFile(new File("build/merged.txt"));
}
 
開發者ID:manifold-lang,項目名稱:manifold-frontend,代碼行數:66,代碼來源:TestExpressionGraph.java


注:本文中的org.manifold.compiler.StringTypeValue類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。