本文整理匯總了Java中org.manifold.compiler.middle.Schematic.addConstraint方法的典型用法代碼示例。如果您正苦於以下問題:Java Schematic.addConstraint方法的具體用法?Java Schematic.addConstraint怎麽用?Java Schematic.addConstraint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.manifold.compiler.middle.Schematic
的用法示例。
在下文中一共展示了Schematic.addConstraint方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deserializeConstraints
import org.manifold.compiler.middle.Schematic; //導入方法依賴的package包/類
/**
* <pre>
* constraints: {
* con_one: {
* type: constraint_type
* attributes: { ... }
* },
* ...
* }
* </pre>
*/
private void deserializeConstraints(Schematic sch, JsonObject in)
throws UndeclaredIdentifierException, UndeclaredAttributeException,
InvalidAttributeException, MultipleAssignmentException,
TypeMismatchException {
if (in == null) {
// TODO warning?
return;
}
for (Entry<String, JsonElement> entry : in.entrySet()) {
JsonObject obj = entry.getValue().getAsJsonObject();
ConstraintType conType = sch.getConstraintType(obj.get(GlobalConsts.TYPE)
.getAsString());
Map<String, Value> attributeMap = getValueAttributes(sch, conType
.getAttributes(), obj);
ConstraintValue conVal = new ConstraintValue(conType,
attributeMap);
compTable.put(entry.getKey(), conVal);
sch.addConstraint(entry.getKey(), conVal);
}
}
示例2: testAddConstraint_AlreadyDeclared_ThrowsException
import org.manifold.compiler.middle.Schematic; //導入方法依賴的package包/類
@Test(expected = MultipleAssignmentException.class)
public void testAddConstraint_AlreadyDeclared_ThrowsException()
throws SchematicException {
Schematic sch = new Schematic("test");
// create a test constraint type
ConstraintType cxtType = new ConstraintType(attributes);
String cxtName = "cxt1";
Map<String, Value> attrs = new HashMap<>();
try {
ConstraintValue cxt1 = new ConstraintValue(cxtType, attrs);
sch.addConstraint(cxtName, cxt1);
} catch (MultipleAssignmentException e) {
fail("exception thrown too early");
}
ConstraintValue cxt2 = new ConstraintValue(cxtType, attrs);
sch.addConstraint(cxtName, cxt2);
}
示例3: testGetConstraint
import org.manifold.compiler.middle.Schematic; //導入方法依賴的package包/類
@Test
public void testGetConstraint() throws SchematicException {
Schematic sch = new Schematic("test");
// create a test constraint type
ConstraintType cxtType = new ConstraintType(attributes);
String cxtName = "cxt1";
Map<String, Value> attrs = new HashMap<>();
ConstraintValue cxt1 = new ConstraintValue(cxtType, attrs);
sch.addConstraint(cxtName, cxt1);
ConstraintValue actual = sch.getConstraint(cxtName);
assertEquals(cxt1, 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: 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);
}