001/* 002 * Copyright 2014 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.ametys.cms.content.references; 018 019import java.util.HashMap; 020import java.util.List; 021import java.util.Map; 022 023/** 024 * Outgoing references. 025 * <p> 026 * They are simply a {@link Map} where keys are the reference types (String) and 027 * values are the reference values (List) with some convenient methods. 028 * </p> 029 */ 030public class OutgoingReferences extends HashMap<String, List<String>> 031{ 032 /** 033 * Merge outgoing references with the current ones 034 * @param others The new references 035 */ 036 public void merge(OutgoingReferences others) 037 { 038 if (others != null) 039 { 040 for (String type : others.keySet()) 041 { 042 if (this.containsKey(type)) 043 { 044 this.get(type).addAll(others.get(type)); 045 } 046 else 047 { 048 this.put(type, others.get(type)); 049 } 050 } 051 } 052 } 053}