/** * Construct a new {@code ModelMap} containing the supplied attribute * under the supplied name. * @see #addAttribute(String, Object) */ public ConcurrentModel(String attributeName, Object attributeValue) { addAttribute(attributeName, attributeValue); }
/** * Construct a new {@code ModelMap} containing the supplied attribute. * Uses attribute name generation to generate the key for the supplied model * object. * @see #addAttribute(Object) */ public ConcurrentModel(Object attributeValue) { addAttribute(attributeValue); }
/** * Copy all attributes in the supplied {@code Collection} into this * {@code Map}, using attribute name generation for each element. * @see #addAttribute(Object) */ public ConcurrentModel addAllAttributes(@Nullable Collection<?> attributeValues) { if (attributeValues != null) { for (Object attributeValue : attributeValues) { addAttribute(attributeValue); } } return this; }
/** * Construct a new {@code ModelMap} containing the supplied attribute. * Uses attribute name generation to generate the key for the supplied model * object. * @see #addAttribute(Object) */ public ConcurrentModel(Object attributeValue) { addAttribute(attributeValue); }
/** * Construct a new {@code ModelMap} containing the supplied attribute * under the supplied name. * @see #addAttribute(String, Object) */ public ConcurrentModel(String attributeName, Object attributeValue) { addAttribute(attributeName, attributeValue); }
/** * Copy all attributes in the supplied {@code Collection} into this * {@code Map}, using attribute name generation for each element. * @see #addAttribute(Object) */ public ConcurrentModel addAllAttributes(@Nullable Collection<?> attributeValues) { if (attributeValues != null) { for (Object attributeValue : attributeValues) { addAttribute(attributeValue); } } return this; }
/** * Add the supplied attribute to this {@code Map} using a * {@link org.springframework.core.Conventions#getVariableName generated name}. * <p><i>Note: Empty {@link Collection Collections} are not added to * the model when using this method because we cannot correctly determine * the true convention name. View code should check for {@code null} rather * than for empty collections as is already done by JSTL tags.</i> * @param attributeValue the model attribute value (never {@code null}) */ public ConcurrentModel addAttribute(Object attributeValue) { Assert.notNull(attributeValue, "Model attribute value must not be null"); if (attributeValue instanceof Collection && ((Collection<?>) attributeValue).isEmpty()) { return this; } return addAttribute(Conventions.getVariableName(attributeValue), attributeValue); }
/** * Add the supplied attribute to this {@code Map} using a * {@link org.springframework.core.Conventions#getVariableName generated name}. * <p><i>Note: Empty {@link Collection Collections} are not added to * the model when using this method because we cannot correctly determine * the true convention name. View code should check for {@code null} rather * than for empty collections as is already done by JSTL tags.</i> * @param attributeValue the model attribute value (never {@code null}) */ public ConcurrentModel addAttribute(Object attributeValue) { Assert.notNull(attributeValue, "Model attribute value must not be null"); if (attributeValue instanceof Collection && ((Collection<?>) attributeValue).isEmpty()) { return this; } return addAttribute(Conventions.getVariableName(attributeValue), attributeValue); }
returnValue = new ConcurrentModel().addAttribute("name", "Joe").addAttribute("ignore", null); testHandle("/account", returnType, returnValue, "account: {id=123, name=Joe}", resolver);
/** * Construct a new {@code ModelMap} containing the supplied attribute. * Uses attribute name generation to generate the key for the supplied model * object. * @see #addAttribute(Object) */ public ConcurrentModel(Object attributeValue) { addAttribute(attributeValue); }
/** * Construct a new {@code ModelMap} containing the supplied attribute * under the supplied name. * @see #addAttribute(String, Object) */ public ConcurrentModel(String attributeName, Object attributeValue) { addAttribute(attributeName, attributeValue); }
/** * Copy all attributes in the supplied {@code Collection} into this * {@code Map}, using attribute name generation for each element. * @see #addAttribute(Object) */ public ConcurrentModel addAllAttributes(@Nullable Collection<?> attributeValues) { if (attributeValues != null) { for (Object attributeValue : attributeValues) { addAttribute(attributeValue); } } return this; }
/** * Add the supplied attribute to this {@code Map} using a * {@link org.springframework.core.Conventions#getVariableName generated name}. * <p><i>Note: Empty {@link Collection Collections} are not added to * the model when using this method because we cannot correctly determine * the true convention name. View code should check for {@code null} rather * than for empty collections as is already done by JSTL tags.</i> * @param attributeValue the model attribute value (never {@code null}) */ public ConcurrentModel addAttribute(Object attributeValue) { Assert.notNull(attributeValue, "Model attribute value must not be null"); if (attributeValue instanceof Collection && ((Collection<?>) attributeValue).isEmpty()) { return this; } return addAttribute(Conventions.getVariableName(attributeValue), attributeValue); }