001/* 002 * Copyright 2002-2012 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.context.support; 018 019import org.springframework.context.MessageSource; 020import org.springframework.ui.context.Theme; 021import org.springframework.util.Assert; 022 023/** 024 * Default {@link Theme} implementation, wrapping a name and an 025 * underlying {@link org.springframework.context.MessageSource}. 026 * 027 * @author Juergen Hoeller 028 * @since 17.06.2003 029 */ 030public class SimpleTheme implements Theme { 031 032 private final String name; 033 034 private final MessageSource messageSource; 035 036 037 /** 038 * Create a SimpleTheme. 039 * @param name the name of the theme 040 * @param messageSource the MessageSource that resolves theme messages 041 */ 042 public SimpleTheme(String name, MessageSource messageSource) { 043 Assert.notNull(name, "Name must not be null"); 044 Assert.notNull(messageSource, "MessageSource must not be null"); 045 this.name = name; 046 this.messageSource = messageSource; 047 } 048 049 050 @Override 051 public final String getName() { 052 return this.name; 053 } 054 055 @Override 056 public final MessageSource getMessageSource() { 057 return this.messageSource; 058 } 059 060}