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

gov.sandia.cognition.learning.function.kernel.DefaultKernelsContainer Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
/*
 * File:                DefaultKernelsContainer.java
 * Authors:             Justin Basilico
 * Company:             Sandia National Laboratories
 * Project:             Cognitive Foundry
 *
 * Copyright September 18, 2007, 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.learning.function.kernel;

import gov.sandia.cognition.annotation.CodeReview;
import gov.sandia.cognition.util.AbstractCloneableSerializable;
import gov.sandia.cognition.util.ObjectUtil;
import java.util.ArrayList;
import java.util.Collection;

/**
 * The {@code DefaultKernelsContainer} class implements a container of kernels.
 *
 * @author Justin Basilico
 * @since  2.0
 * @param  Input class to the Kernel 
 */
@CodeReview(
    reviewer="Kevin R. Dixon",
    date="2009-07-08",
    changesNeeded=false,
    comments={
        "Made clone call super.clone.",
        "Looks fine otherwise."
    }
)
public class DefaultKernelsContainer
    extends AbstractCloneableSerializable
{

    /** The collection of kernels in the container. */
    protected Collection> kernels;

    /**
     * Creates a new instance of DefaultKernelsContainer.
     */
    public DefaultKernelsContainer()
    {
        this( new ArrayList>() );
    }

    /**
     * Creates a new instance of DefaultKernelsContainer.
     *
     * @param  kernels A collection of kernels.
     */
    public DefaultKernelsContainer(
        final Collection> kernels )
    {
        super();

        this.setKernels( kernels );
    }

    /**
     * Creates a new copy of the DefaultKernelsConainer.
     *
     * @param  other The DefaultKernelsContainer to copy.
     */
    public DefaultKernelsContainer(
        final DefaultKernelsContainer other )
    {
        super();

        ArrayList> localKernels =
            new ArrayList>(
            other.getKernels().size() );

        for (Kernel kernel : other.getKernels())
        {
            localKernels.add( kernel );
        }

        this.setKernels( localKernels );
    }

    @Override
    public DefaultKernelsContainer clone()
    {
        @SuppressWarnings("unchecked")
        DefaultKernelsContainer clone =
            (DefaultKernelsContainer) super.clone();
        clone.setKernels(
            ObjectUtil.cloneSmartElementsAsArrayList( this.getKernels() ) );
        return clone;
    }

    /**
     * Gets the collection of kernels.
     *
     * @return The collection of kernels.
     */
    public Collection> getKernels()
    {
        return this.kernels;
    }

    /**
     * Sets the collection of kernels.
     *
     * @param  kernels The collection of kernels.
     */
    public void setKernels(
        Collection> kernels )
    {
        this.kernels = kernels;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy