001// Copyright 2004, 2005 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.hivemind.impl;
016
017import java.util.ArrayList;
018import java.util.Collections;
019import java.util.List;
020
021import org.apache.hivemind.internal.Contribution;
022import org.apache.hivemind.internal.Module;
023
024/**
025 * Implements the {@link org.apache.hivemind.internal.Contribution} interface, a wrapper
026 * around objects that can provide values that plug into an extension point.
027 * 
028 * @author Howard Lewis Ship
029 */
030public final class ContributionImpl implements Contribution
031{
032    private Module _contributingModule;
033
034    private List _elements;
035
036    public Module getContributingModule()
037    {
038        return _contributingModule;
039    }
040
041    public void setContributingModule(Module module)
042    {
043        _contributingModule = module;
044    }
045
046    public void addElements(List elements)
047    {
048        if (_elements == null)
049            _elements = new ArrayList(elements);
050        else
051            _elements.addAll(elements);
052    }
053
054    public List getElements()
055    {
056        if (_elements == null)
057            return Collections.EMPTY_LIST;
058
059        return _elements;
060    }
061}