001/* 002 * Copyright 2002-2017 the original author or authors. 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 * https://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.springframework.ui; 018 019import java.util.Collection; 020import java.util.Map; 021 022import org.springframework.lang.Nullable; 023 024/** 025 * Subclass of {@link ModelMap} that implements the {@link Model} interface. 026 * Java 5 specific like the {@code Model} interface itself. 027 * 028 * <p>This is an implementation class exposed to handler methods by Spring MVC, typically via 029 * a declaration of the {@link org.springframework.ui.Model} interface. There is no need to 030 * build it within user code; a plain {@link org.springframework.ui.ModelMap} or even a just 031 * a regular {@link Map} with String keys will be good enough to return a user model. 032 * 033 * @author Juergen Hoeller 034 * @since 2.5.1 035 */ 036@SuppressWarnings("serial") 037public class ExtendedModelMap extends ModelMap implements Model { 038 039 @Override 040 public ExtendedModelMap addAttribute(String attributeName, @Nullable Object attributeValue) { 041 super.addAttribute(attributeName, attributeValue); 042 return this; 043 } 044 045 @Override 046 public ExtendedModelMap addAttribute(Object attributeValue) { 047 super.addAttribute(attributeValue); 048 return this; 049 } 050 051 @Override 052 public ExtendedModelMap addAllAttributes(@Nullable Collection<?> attributeValues) { 053 super.addAllAttributes(attributeValues); 054 return this; 055 } 056 057 @Override 058 public ExtendedModelMap addAllAttributes(@Nullable Map<String, ?> attributes) { 059 super.addAllAttributes(attributes); 060 return this; 061 } 062 063 @Override 064 public ExtendedModelMap mergeAttributes(@Nullable Map<String, ?> attributes) { 065 super.mergeAttributes(attributes); 066 return this; 067 } 068 069 @Override 070 public Map<String, Object> asMap() { 071 return this; 072 } 073 074}