private void copyMethodParams(ExpressionMethod part, ExpressionMethod method) { Map<String, ExpressionFormLine> params = new HashMap<String, ExpressionFormLine>(); for (Map.Entry<String, ExpressionFormLine> entry : part.getParams().entrySet()) { params.put(entry.getKey(), new ExpressionFormLine(entry.getValue())); } method.setParams(params); }
private void copyMethodParams(ExpressionMethod part, ExpressionMethod method) { Map<String, ExpressionFormLine> params = new HashMap<String, ExpressionFormLine>(); for (Map.Entry<String, ExpressionFormLine> entry : part.getParams().entrySet()) { params.put(entry.getKey(), new ExpressionFormLine(entry.getValue())); } method.setParams(params); }
private ExpressionFormLine visitExpressionFormLine(ExpressionFormLine efl) { ExpressionFormLine clone = new ExpressionFormLine( efl ); clone.setBinding( efl.getBinding() ); return clone; }
private ExpressionFormLine visitExpressionFormLine(ExpressionFormLine efl) { ExpressionFormLine clone = new ExpressionFormLine( efl ); clone.setBinding( efl.getBinding() ); return clone; }
@Test public void testCopy() { ExpressionFormLine efl = new ExpressionFormLine(); FactPattern fp = new FactPattern(SuggestionCompletionEngine.TYPE_OBJECT); fp.setBoundName("$o"); efl.appendPart(new ExpressionVariable(fp)); ExpressionMethod em = new ExpressionMethod("aMethod", "aClass", "aType"); ExpressionFormLine param = new ExpressionFormLine(); param.appendPart(new ExpressionText("\"hello world\"")); em.putParam("hi", param); efl.appendPart(em); ExpressionCollectionIndex index = new ExpressionCollectionIndex("get", "aRetType", "aGeneric"); efl.appendPart(index); index = new ExpressionCollectionIndex("get2", "aRetType", "aGeneric"); efl.appendPart(index); System.out.println(efl.getText()); ExpressionFormLine copy = new ExpressionFormLine(efl); assertNotSame(efl, copy); assertEquals(efl.getText(), copy.getText()); for (ExpressionPart e1 = efl.getRootExpression(), e2 = copy.getRootExpression(); e1 != null; e1 = e1.getNext(), e2 = e2.getNext()) { assertNotSame(e1, e2); assertEquals(e1.getClass(), e2.getClass()); } }
@Test public void toStringText() { ExpressionFormLine efl = new ExpressionFormLine(); FactPattern fact = new FactPattern( "String" ); fact.setBoundName( "$v" ); efl.appendPart( new ExpressionVariable( fact ) ); efl.appendPart( new ExpressionMethod( "size", "int", SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER ) ); assertEquals( "$v.size()", efl.getText() ); efl.setBinding( "$s" ); assertEquals( "$s: $v.size()", efl.getText( true ) ); } }
fp0.addConstraint( sfc0p0 ); ExpressionFormLine efl0sfc0p0 = new ExpressionFormLine(); ExpressionField ef0sfc0p0 = new ExpressionField( "sfc0p0", "sfc0p0class", fp0.addConstraint( sfc1p0 ); ExpressionFormLine efl0sfc1p0 = new ExpressionFormLine(); ExpressionField ef0sfc1p0 = new ExpressionField( "sfc1p0", "sfc1p0class", fp1.addConstraint( sfc0p1 ); ExpressionFormLine efl0sfc0p1 = new ExpressionFormLine(); ExpressionField ef0sfc0p1 = new ExpressionField( "sfc0p1", "sfc0p1class", fp1.addConstraint( sfc1p1 ); ExpressionFormLine efl0sfc1p1 = new ExpressionFormLine(); ExpressionField ef0sfc1p1 = new ExpressionField( "sfc1p1", "sfc1p1class",
@Test public void testCompositeFactPatternWithFromWithDSL() { final RuleModel m = new RuleModel(); m.name = "model"; final DSLSentence sen = new DSLSentence(); sen.setDefinition( "A DSL phrase" ); m.addLhsItem( sen ); final FactPattern fp1 = new FactPattern( "Data" ); fp1.setBoundName( "$d" ); m.addLhsItem( fp1 ); final CompositeFactPattern cp = new CompositeFactPattern( CompositeFactPattern.COMPOSITE_TYPE_NOT ); final FactPattern fp2 = new FactPattern( "Person" ); final FromCompositeFactPattern ffp1 = new FromCompositeFactPattern(); ffp1.setExpression( new ExpressionFormLine( new ExpressionVariable( fp1 ) ) ); ffp1.setFactPattern( fp2 ); cp.addFactPattern( ffp1 ); m.addLhsItem( cp ); final String actual = BRDRLPersistence.getInstance().marshal( m ); final String expected = "rule \"model\"\n" + "dialect \"mvel\"\n" + "when\n" + "A DSL phrase\n" + ">$d : Data( )\n" + ">not ( Person( ) from $d\n" + ")\n" + "then\n" + "end\n"; assertEqualsIgnoreWhitespace( expected, actual ); }
ExpressionFormLine eflhs0 = new ExpressionFormLine(); eflhs0.setBinding( "$eflhs0" ); ExpressionText eflhs0p0 = new ExpressionText( "eflhs0p0" ); sfc0.setExpressionLeftSide( eflhs0 ); ExpressionFormLine efl0 = new ExpressionFormLine(); efl0.setBinding( "$efl0" ); ExpressionText efl0p0 = new ExpressionText( "efl0p0" );
ExpressionFormLine efl0 = new ExpressionFormLine(); efl0.setBinding( "$efl0" ); ExpressionText efl0p0 = new ExpressionText( "efl0p0" );
ExpressionFormLine efl0 = new ExpressionFormLine(); efl0.setBinding( "$efl0" ); ExpressionText efl0p0 = new ExpressionText( "efl0p0" );
ExpressionFormLine efl0 = new ExpressionFormLine(); efl0.setBinding( "$efl0" ); ExpressionText efl0p0 = new ExpressionText( "efl0p0" );
FromAccumulateCompositeFactPattern fp0 = new FromAccumulateCompositeFactPattern(); fp0.setActionCode( "fp0.actionCode" ); ExpressionFormLine efl0 = new ExpressionFormLine(); efl0.setBinding( "$efl0" ); ExpressionText efl0p0 = new ExpressionText( "efl0p0" );