本文整理汇总了Java中org.manifold.compiler.middle.Schematic.addConstraintType方法的典型用法代码示例。如果您正苦于以下问题:Java Schematic.addConstraintType方法的具体用法?Java Schematic.addConstraintType怎么用?Java Schematic.addConstraintType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.manifold.compiler.middle.Schematic
的用法示例。
在下文中一共展示了Schematic.addConstraintType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAddConstraintType_AlreadyDefined_ThrowsException
import org.manifold.compiler.middle.Schematic; //导入方法依赖的package包/类
@Test(expected = MultipleDefinitionException.class)
public void testAddConstraintType_AlreadyDefined_ThrowsException()
throws SchematicException {
Schematic sch = new Schematic("test");
// add the first constraint type
String constraintTypeName = "TestConstraint";
try {
ConstraintType cv1 = new ConstraintType(attributes);
sch.addConstraintType(constraintTypeName, cv1);
} catch (MultipleDefinitionException e) {
fail("exception thrown too early");
}
// try to add another constraint type with the same name
ConstraintType cv2 = new ConstraintType(attributes);
sch.addConstraintType(constraintTypeName, cv2);
}
示例2: deserializeConstraintTypes
import org.manifold.compiler.middle.Schematic; //导入方法依赖的package包/类
private void deserializeConstraintTypes(Schematic sch, JsonObject in)
throws MultipleDefinitionException, UndeclaredIdentifierException {
if (in == null) {
// TODO warning?
return;
}
for (Entry<String, JsonElement> entry : in.entrySet()) {
Map<String, TypeValue> attributeMap = getTypeDefAttributes(sch,
entry.getValue().getAsJsonObject());
ConstraintType supertype = null;
if (entry.getValue().getAsJsonObject().has(SUPERTYPE)) {
String supertypeName = entry.getValue().getAsJsonObject()
.get(SUPERTYPE).getAsString();
supertype = sch.getConstraintType(supertypeName);
}
ConstraintType constraintType = null;
if (supertype == null) {
constraintType = new ConstraintType(attributeMap);
} else {
constraintType = new ConstraintType(attributeMap, supertype);
}
compTable.put(entry.getKey(), constraintType);
sch.addConstraintType(entry.getKey(), constraintType);
}
}
示例3: testGetConstraintType
import org.manifold.compiler.middle.Schematic; //导入方法依赖的package包/类
@Test
public void testGetConstraintType() throws SchematicException {
Schematic sch = new Schematic("test");
// add the first constraint type
String constraintTypeName = "TestConstraint";
ConstraintType cv1 = new ConstraintType(attributes);
sch.addConstraintType(constraintTypeName, cv1);
ConstraintType actual = sch.getConstraintType(constraintTypeName);
assertEquals(cv1, actual);
}
示例4: testGetConstraintName
import org.manifold.compiler.middle.Schematic; //导入方法依赖的package包/类
@Test
public void testGetConstraintName() throws SchematicException {
Schematic sch = new Schematic("test");
ConstraintType cxtType1 = new ConstraintType(attributes);
sch.addConstraintType("TestConstraint", cxtType1);
String cxtName = "constraint1";
Map<String, Value> attrs = new HashMap<>();
ConstraintValue cxt1 = new ConstraintValue(cxtType1, attrs);
sch.addConstraint(cxtName, cxt1);
String retrievedName = sch.getConstraintName(cxt1);
assertEquals(cxtName, retrievedName);
}
示例5: testGetConstraintName_Undeclared_ThrowsException
import org.manifold.compiler.middle.Schematic; //导入方法依赖的package包/类
@Test(expected = NoSuchElementException.class)
public void testGetConstraintName_Undeclared_ThrowsException()
throws SchematicException {
Schematic sch = new Schematic("test");
ConstraintType cxtType1 = new ConstraintType(attributes);
sch.addConstraintType("TestConstraint", cxtType1);
String cxtName = "constraint1";
Map<String, Value> attrs = new HashMap<>();
ConstraintValue cxt1 = new ConstraintValue(cxtType1, attrs);
//sch.addConstraint(cxtName, cxt1);
String retrievedName = sch.getConstraintName(cxt1);
}
示例6: setup
import org.manifold.compiler.middle.Schematic; //导入方法依赖的package包/类
@Before
public void setup() throws SchematicException {
testSchematic = new Schematic(TEST_SCHEMATIC_NAME);
// port type
PortTypeValue din = new PortTypeValue(
testSchematic.getUserDefinedType("Bool"), new HashMap<>());
PortTypeValue dout = new PortTypeValue(
testSchematic.getUserDefinedType("Bool"), new HashMap<>());
testSchematic.addPortType(DIGITAL_IN, din);
testSchematic.addPortType(DIGITAL_OUT, dout);
// node type
HashMap<String, PortTypeValue> dinPortMap = new HashMap<>();
dinPortMap.put(IN_PORT_NAME, din);
HashMap<String, PortTypeValue> doutPortMap = new HashMap<>();
doutPortMap.put(OUT_PORT_NAME, dout);
NodeTypeValue dinNodeType = new NodeTypeValue(new HashMap<>(), dinPortMap);
NodeTypeValue doutNodeType = new NodeTypeValue(new HashMap<>(),
doutPortMap);
testSchematic.addNodeType(IN_NODE_NAME, dinNodeType);
testSchematic.addNodeType(OUT_NODE_NAME, doutNodeType);
// node
Map<String, Map<String, Value>> inNodeAttr = new HashMap<>();
inNodeAttr.put(IN_PORT_NAME, new HashMap<>());
Map<String, Map<String, Value>> outNodeAttr = new HashMap<>();
outNodeAttr.put(OUT_PORT_NAME, new HashMap<>());
NodeValue inNode = new NodeValue(dinNodeType, new HashMap<>(), inNodeAttr);
testSchematic.addNode("nIN", inNode);
NodeValue outNode = new NodeValue(doutNodeType, new HashMap<>(),
outNodeAttr);
testSchematic.addNode("nOUT", outNode);
ConnectionValue con = new ConnectionValue(inNode
.getPort(IN_PORT_NAME), outNode.getPort(OUT_PORT_NAME),
new HashMap<>());
testSchematic.addConnection(CONNECTION_NAME, con);
// constraint
TypeValue stringType = testSchematic.getUserDefinedType("String");
ConstraintType constraintType = new ConstraintType(ImmutableMap.of(
"foo", stringType,
"din_reference", dinNodeType,
"port_reference", din));
testSchematic.addConstraintType(TEST_CONSTRAINT_TYPE_NAME, constraintType);
ConstraintValue constraintValue = new ConstraintValue(constraintType,
ImmutableMap.of(
"foo", new StringValue(stringType, "bar"),
"din_reference", inNode,
"port_reference", inNode.getPort(IN_PORT_NAME)));
testSchematic.addConstraint("c1", constraintValue);
}