@Test public void testCloneWithUnsupportedClass() { RuleModel model = new RuleModel(); model.addLhsItem( new TestFactPattern() ); RuleModelCloneVisitor visitor = new RuleModelCloneVisitor(); thrown.expect( RuntimeException.class ); thrown.expectMessage( TestFactPattern.class.getSimpleName() ); visitor.visitRuleModel( model ); }
public RuleModel visitRuleModel(RuleModel model) { RuleModel clone = new RuleModel(); clone.modelVersion = model.modelVersion; clone.name = model.name; clone.parentName = model.parentName; clone.setNegated(model.isNegated()); if (model.attributes != null) { clone.attributes = new RuleAttribute[model.attributes.length]; for (int i = 0; i < model.attributes.length; i++) { RuleAttribute attr = model.attributes[i]; clone.attributes[i] = (RuleAttribute) visit(attr); } } if (model.metadataList != null) { clone.metadataList = new RuleMetadata[model.metadataList.length]; for (int i = 0; i < model.metadataList.length; i++) { RuleMetadata md = model.metadataList[i]; clone.metadataList[i] = (RuleMetadata) visit(md); } } if (model.lhs != null) { clone.lhs = new IPattern[model.lhs.length]; for (int i = 0; i < model.lhs.length; i++) { IPattern pattern = model.lhs[i]; clone.lhs[i] = (IPattern) visit(pattern); } } if (model.rhs != null) { clone.rhs = new IAction[model.rhs.length]; for (int i = 0; i < model.rhs.length; i++) { IAction action = model.rhs[i]; clone.rhs[i] = (IAction) visit(action); } } return clone; }
RuleModelCloneVisitor { public RuleModel visitRuleModel(RuleModel model) { RuleModel clone = new RuleModel(); clone.modelVersion = model.modelVersion; clone.name = model.name; clone.parentName = model.parentName; clone.setNegated(model.isNegated()); if (model.attributes != null) { clone.attributes = new RuleAttribute[model.attributes.length]; for (int i = 0; i < model.attributes.length; i++) { RuleAttribute attr = model.attributes[i]; clone.attributes[i] = (RuleAttribute) visit(attr); } } if (model.metadataList != null) { clone.metadataList = new RuleMetadata[model.metadataList.length]; for (int i = 0; i < model.metadataList.length; i++) { RuleMetadata md = model.metadataList[i]; clone.metadataList[i] = (RuleMetadata) visit(md); } } if (model.lhs != null) { clone.lhs = new IPattern[model.lhs.length]; for (int i = 0; i < model.lhs.length; i++) { IPattern pattern = model.lhs[i]; clone.lhs[i] = (IPattern) visit(pattern); } } if (model.rhs != null) { clone.rhs = new IAction[model.rhs.length]; for (int i = 0; i < model.rhs.length; i++) { IAction action = model.rhs[i]; clone.rhs[i] = (IAction) visit(action); } } return clone; } }
RuleModelCloneVisitor { public RuleModel visitRuleModel(RuleModel model) { RuleModel clone = new RuleModel(); clone.modelVersion = model.modelVersion; clone.name = model.name; clone.parentName = model.parentName; clone.setNegated(model.isNegated()); if (model.attributes != null) { clone.attributes = new RuleAttribute[model.attributes.length]; for (int i = 0; i < model.attributes.length; i++) { RuleAttribute attr = model.attributes[i]; clone.attributes[i] = (RuleAttribute) visit(attr); } } if (model.metadataList != null) { clone.metadataList = new RuleMetadata[model.metadataList.length]; for (int i = 0; i < model.metadataList.length; i++) { RuleMetadata md = model.metadataList[i]; clone.metadataList[i] = (RuleMetadata) visit(md); } } if (model.lhs != null) { clone.lhs = new IPattern[model.lhs.length]; for (int i = 0; i < model.lhs.length; i++) { IPattern pattern = model.lhs[i]; clone.lhs[i] = (IPattern) visit(pattern); } } if (model.rhs != null) { clone.rhs = new IAction[model.rhs.length]; for (int i = 0; i < model.rhs.length; i++) { IAction action = model.rhs[i]; clone.rhs[i] = (IAction) visit(action); } } return clone; }  }
RuleModelCloneVisitor { public RuleModel visitRuleModel(RuleModel model) { RuleModel clone = new RuleModel(); clone.modelVersion = model.modelVersion; clone.name = model.name; clone.parentName = model.parentName; clone.setNegated(model.isNegated()); if (model.attributes != null) { clone.attributes = new RuleAttribute[model.attributes.length]; for (int i = 0; i < model.attributes.length; i++) { RuleAttribute attr = model.attributes[i]; clone.attributes[i] = (RuleAttribute) visit(attr); } } if (model.metadataList != null) { clone.metadataList = new RuleMetadata[model.metadataList.length]; for (int i = 0; i < model.metadataList.length; i++) { RuleMetadata md = model.metadataList[i]; clone.metadataList[i] = (RuleMetadata) visit(md); } } if (model.lhs != null) { clone.lhs = new IPattern[model.lhs.length]; for (int i = 0; i < model.lhs.length; i++) { IPattern pattern = model.lhs[i]; clone.lhs[i] = (IPattern) visit(pattern); } } if (model.rhs != null) { clone.rhs = new IAction[model.rhs.length]; for (int i = 0; i < model.rhs.length; i++) { IAction action = model.rhs[i]; clone.rhs[i] = (IAction) visit(action); } } return clone; }  RuleModel visitRuleModel(RuleModel model); }
RuleModelCloneVisitor { public RuleModel visitRuleModel(RuleModel model) { RuleModel clone = new RuleModel(); clone.modelVersion = model.modelVersion; clone.name = model.name; clone.parentName = model.parentName; clone.setNegated(model.isNegated()); if (model.attributes != null) { clone.attributes = new RuleAttribute[model.attributes.length]; for (int i = 0; i < model.attributes.length; i++) { RuleAttribute attr = model.attributes[i]; clone.attributes[i] = (RuleAttribute) visit(attr); } } if (model.metadataList != null) { clone.metadataList = new RuleMetadata[model.metadataList.length]; for (int i = 0; i < model.metadataList.length; i++) { RuleMetadata md = model.metadataList[i]; clone.metadataList[i] = (RuleMetadata) visit(md); } } if (model.lhs != null) { clone.lhs = new IPattern[model.lhs.length]; for (int i = 0; i < model.lhs.length; i++) { IPattern pattern = model.lhs[i]; clone.lhs[i] = (IPattern) visit(pattern); } } if (model.rhs != null) { clone.rhs = new IAction[model.rhs.length]; for (int i = 0; i < model.rhs.length; i++) { IAction action = model.rhs[i]; clone.rhs[i] = (IAction) visit(action); } } return clone; }  RuleModel visitRuleModel(RuleModel model);  }