001/**
002 * PrimitiveReplicator.java
003 * 
004 * Copyright (c) 2004-2012, Nicole C. Tedesco. All rights reserved.
005 * 
006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007 * use this file except in compliance with the License. You may obtain a copy of
008 * the License at:
009 * 
010 * http://www.apache.org/licenses/LICENSE-2.0
011 * 
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015 * License for the specific language governing permissions and limitations under
016 * the License.
017 */
018
019package net.sf.jaccumulator.primitives;
020
021import net.sf.jaccumulator.Replicator;
022import net.sf.jaccumulator.reals.RealReplicator;
023import net.sf.jaccumulator.scalars.ScalarReplicator;
024
025/**
026 * A {@link Replicator replicator} for {@link Primitive primitives}
027 * 
028 * @param <PRIMITIVE>
029 *        the factory product
030 * @since JAccumulator 4.0
031 * @author Nicole Tedesco (<a
032 *         href="mailto:Nicole@NicoleTedesco.com">Nicole@NicoleTedesco.com</a>)
033 */
034public interface PrimitiveReplicator<PRIMITIVE extends PrimitiveReplicator<PRIMITIVE>>
035    extends
036        RealReplicator<PRIMITIVE>,
037        ScalarReplicator<PRIMITIVE>
038{
039    /**
040     * Using this primitive as a factory, produce a new primitive of the same
041     * type but initialized with the value specified
042     * 
043     * @param aValue
044     *        a new value
045     * @return a copy (clone) of this primitive initialized using the specified
046     *         value
047     */
048    public PRIMITIVE copyUsingPrimitive( final SealedPrimitive<?> aValue );
049
050    /**
051     * Using this primitive as a factory, produce a new primitive of the same
052     * type but initialized with the value specified
053     * 
054     * @param aValue
055     *        a new value
056     * @return a copy (clone) of this primitive initialized using the specified
057     *         value
058     */
059    public PRIMITIVE copyUsingText( final CharSequence aValue );
060
061    /**
062     * If this object is already {@link Primitive primitive} then simply call
063     * its {@link #copy()} function, otherwise convert it to a new Primitive
064     * instance
065     * 
066     * @return a new Primitive
067     */
068    public Primitive<?> toPrimitive();
069}