001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Anahide Tchertchian 016 */ 017package org.nuxeo.runtime.model; 018 019import java.util.HashMap; 020import java.util.Map; 021 022/** 023 * Simple contribution registry, keeping up to date contributions in a map, and not handling merge. 024 * 025 * @since 5.6 026 */ 027public abstract class SimpleContributionRegistry<T> extends ContributionFragmentRegistry<T> { 028 029 protected Map<String, T> currentContribs = new HashMap<String, T>(); 030 031 @Override 032 public void contributionUpdated(String id, T contrib, T newOrigContrib) { 033 currentContribs.put(id, contrib); 034 } 035 036 @Override 037 public void contributionRemoved(String id, T origContrib) { 038 currentContribs.remove(id); 039 } 040 041 @Override 042 public boolean isSupportingMerge() { 043 return false; 044 } 045 046 @Override 047 public T clone(T orig) { 048 throw new UnsupportedOperationException(); 049 } 050 051 @Override 052 public void merge(T src, T dst) { 053 throw new UnsupportedOperationException(); 054 } 055 056 protected T getCurrentContribution(String id) { 057 return currentContribs.get(id); 058 } 059 060}