All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gov.sandia.cognition.framework.AbstractCognitiveModelFactory Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
/*
 * File:                AbstractCognitiveModelFactory.java
 * Authors:             Justin Basilico and Kevin R. Dixon
 * Company:             Sandia National Laboratories
 * Project:             Cognitive Framework Lite
 *
 * Copyright March 1, 2006, Sandia Corporation.  Under the terms of Contract
 * DE-AC04-94AL85000, there is a non-exclusive license for use of this work by
 * or on behalf of the U.S. Government. Export of this program may require a
 * license from the United States Government. See CopyrightHistory.txt for
 * complete details.
 *
 *
 */

package gov.sandia.cognition.framework;

import java.util.ArrayList;
import java.util.Collection;

/**
 * The AbstractCognitiveModelFactory class defines common functionality
 * among CognitiveModelFactory implementations. Specifically, it allows
 * CognitiveModuleFactories to be added to the model factory.
 *
 * @author Justin Basilico
 * @author Kevin R. Dixon
 * @author Zachary Benz
 * @since 1.0
 */
public abstract class AbstractCognitiveModelFactory
    extends java.lang.Object
    implements CognitiveModelFactory
{
    /** The list of CognitiveModuleFactories to use for the model. */
    private ArrayList moduleFactories = null;
    
    /**
     * Creates a new instance of AbstractCognitiveModelFactory.
     */
    public AbstractCognitiveModelFactory()
    {
        this(new ArrayList());
    }
    
    /**
     * Creates a new instance of {@code AbstractCognitiveModelFactory}.
     * 
     * @param   moduleFactories The initial set of module factories.
     */
    public AbstractCognitiveModelFactory(
        final Collection moduleFactories)
    {
        super();
        
        this.setModuleFactories(
            new ArrayList(moduleFactories));
    }
    
    /**
     * Adds a CognitiveModuleFactory to be used by this factory when creating
     * a new CognitiveModel. Specifically, the module factories will be given
     * to the new model to instantiate CognitiveModules from.
     *
     * @param factory The CognitiveModuleFactory to add
     */
    public void addModuleFactory(
        CognitiveModuleFactory factory)
    {
        if ( factory == null )
        {
            // Error: Bad factory.
            throw new NullPointerException("The factory cannot be null.");
        }
        
        this.getModuleFactories().add(factory);
    }
    
    /**
     * Gets the CognitiveModuleFactories that are used to create a model.
     *
     * @return The Collection of CognitiveModuleFactories used to create
     *         a model.
     */
    public ArrayList getModuleFactories()
    {
        return this.moduleFactories;
    }
    
    /**
     * Sets the list of module factories to use.
     *
     * @param moduleFactories The new list of module factories
     */
    public void setModuleFactories(
        ArrayList moduleFactories)
    {
        if ( moduleFactories == null )
        {
            // Error: Bad module factories.
            throw new NullPointerException(
                "The module factories cannot be null.");
        }
        
        this.moduleFactories = moduleFactories;
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy