001/* 002 * ============================================================================ 003 * Copyright © 2002-2021 by Thomas Thrien. 004 * All Rights Reserved. 005 * ============================================================================ 006 * Licensed to the public under the agreements of the GNU Lesser General Public 007 * License, version 3.0 (the "License"). You may obtain a copy of the License at 008 * 009 * http://www.gnu.org/licenses/lgpl.html 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 014 * License for the specific language governing permissions and limitations 015 * under the License. 016 */ 017 018package org.tquadrat.foundation.config.ap.impl.codebuilders; 019 020import static javax.lang.model.element.Modifier.PRIVATE; 021import static org.apiguardian.api.API.Status.STABLE; 022import static org.tquadrat.foundation.config.ap.impl.CodeBuilder.StandardField.STD_FIELD_ResourceLocale; 023 024import java.util.Locale; 025 026import org.apiguardian.api.API; 027import org.tquadrat.foundation.annotation.ClassVersion; 028 029/** 030 * <p>{@summary The 031 * {@linkplain org.tquadrat.foundation.config.ap.impl.CodeBuilder code builder implementation} 032 * for the generation of the code that let the configuration bean 033 * implement the interface 034 * {@link org.tquadrat.foundation.config.I18nSupport}.}</p> 035 * 036 * @version $Id: I18nSupportBuilder.java 1001 2022-01-29 16:42:15Z tquadrat $ 037 * @extauthor Thomas Thrien - thomas.thrien@tquadrat.org 038 * @UMLGraph.link 039 * @since 0.1.0 040 */ 041@ClassVersion( sourceVersion = "$Id: I18nSupportBuilder.java 1001 2022-01-29 16:42:15Z tquadrat $" ) 042@API( status = STABLE, since = "0.1.0" ) 043public final class I18nSupportBuilder extends CodeBuilderBase 044{ 045 /*--------------*\ 046 ====** Constructors **===================================================== 047 \*--------------*/ 048 /** 049 * Creates a new instance of {@code I18nSupportBuilder}. 050 * 051 * @param context The code generator context. 052 */ 053 public I18nSupportBuilder( final CodeGeneratorContext context ) 054 { 055 super( context ); 056 } // I18nSupportBuilder() 057 058 /*---------*\ 059 ====** Methods **========================================================== 060 \*---------*/ 061 /** 062 * {@inheritDoc} 063 */ 064 @Override 065 public final void build() 066 { 067 /* 068 * Create the field that tracks the locale for the current resource 069 * bundle. 070 */ 071 final var resourceBundleLocaleField = getComposer().fieldBuilder( Locale.class, STD_FIELD_ResourceLocale.toString(), PRIVATE ) 072 .addJavadoc( """ 073 The 074 {@link Locale} 075 for the currently loaded 076 {@link ResourceBundle}. 077 078 @see #getResourceBundle() 079 """ ) 080 .initializer( "$1L", "null" ) 081 .build(); 082 addField( STD_FIELD_ResourceLocale, resourceBundleLocaleField ); 083 } // build() 084} 085// class I18nSupportBuilder 086 087/* 088 * End of File 089 */