当前位置: 首页>>代码示例>>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;未经允许,请勿转载。