001/**
002 * AbstractSimpleAccumulator.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;
020
021import net.sf.jaccumulator.primitives.Primitive;
022import net.sf.jaccumulator.primitives.Variant;
023import net.sf.jupperware.association.AssociativeList;
024
025/**
026 * Common behavior for a simple Accumulator with an independent,
027 * <i>non-replaceable</i> {@link #getTarget() target} Primitive
028 * 
029 * @param <ACCUMULATOR>
030 *        this {@link Accumulator} type
031 * 
032 * @since JAccumulator 4.0
033 * @author Nicole Tedesco (<a
034 *         href="mailto:nicole@tedesco.name">nicole@tedesco.name</a>)
035 */
036public abstract class AbstractStickyTarget<ACCUMULATOR extends Accumulator<ACCUMULATOR>>
037    extends
038        AbstractAccumulator<ACCUMULATOR>
039{
040    private static final long serialVersionUID = 4083711971805433248L;
041
042    private final Primitive<?> _theTarget;
043
044    public AbstractStickyTarget()
045    {
046        this(new Variant());
047    }
048
049    public AbstractStickyTarget( final Accumulator<?> anAccumulator )
050    {
051        super(anAccumulator);
052        this._theTarget = anAccumulator.getTarget();
053    }
054
055    public AbstractStickyTarget( final Primitive<?> aTarget )
056    {
057        super();
058        this._theTarget = aTarget;
059    }
060
061    public AbstractStickyTarget(
062        final Primitive<?> aTarget,
063        final AssociativeList<Accumulator<?>,Accumulator<?>> members )
064    {
065        super(members);
066        this._theTarget = aTarget;
067    }
068
069    @Override
070    public final Primitive<?> getTarget()
071    {
072        return this._theTarget;
073    }
074
075    @Override
076    public final boolean isTargetReplaceable()
077    {
078        return false;
079    }
080
081    @Override
082    public final ACCUMULATOR shareTarget( final Primitive<?> aTarget )
083        throws UnsupportedOperationException,
084            NullPointerException,
085            IllegalStateException,
086            IllegalArgumentException
087    {
088        throw new UnsupportedOperationException();
089    }
090
091    @Override
092    public final ACCUMULATOR shareTargetWith( final Accumulator<?> anAccumulator )
093        throws UnsupportedOperationException,
094            NullPointerException,
095            IllegalStateException,
096            IllegalArgumentException
097    {
098        throw new UnsupportedOperationException();
099    }
100}