<%@ import val generator: org.fusesource.ide.generator.Generator %>
/*******************************************************************************
 * Copyright (c) 2013 Red Hat, Inc.
 * Distributed under license by Red Hat, Inc. All rights reserved.
 * This program is made available under the terms of the
 * Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Red Hat, Inc. - initial API and implementation
 ******************************************************************************/

/**
 * NOTE - this file is auto-generated using Scalate. 
 * 
 * DO NOT EDIT!
 */
package org.fusesource.ide.camel.model.generated;

import org.fusesource.ide.camel.model.AbstractNode;
import org.fusesource.ide.camel.model.Endpoint;
import org.fusesource.ide.camel.model.RouteContainer;

import org.apache.camel.model.*;

/**
 * Provides a factory method to create the Eclipse model for a given Camel node
 */
public class NodeFactory {
	
    public static AbstractNode createNode(ProcessorDefinition processor, RouteContainer parent) {
      if (processor instanceof ToDefinition) {
        return Endpoint.newInstance((ToDefinition) processor, parent);
      }
#for (n <- nodeDefinitions)
      else if (processor instanceof ${n.name}) {
        return new ${n.definitionName}((${n.name}) processor, parent);
      }
#end
      else {
        throw new IllegalArgumentException("Camel node not supported: " + processor);
      }
    }
    
}
