001/* 002 * ============================================================================ 003 * Copyright © 2002-2021 by Thomas Thrien. 004 * All Rights Reserved. 005 * ============================================================================ 006 * 007 * Licensed to the public under the agreements of the GNU Lesser General Public 008 * License, version 3.0 (the "License"). You may obtain a copy of the License at 009 * 010 * http://www.gnu.org/licenses/lgpl.html 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 014 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 015 * License for the specific language governing permissions and limitations 016 * under the License. 017 */ 018 019package org.tquadrat.foundation.config.spi.prefs; 020 021import static org.apiguardian.api.API.Status.STABLE; 022 023import org.apiguardian.api.API; 024import org.tquadrat.foundation.annotation.ClassVersion; 025import org.tquadrat.foundation.function.Getter; 026import org.tquadrat.foundation.function.Setter; 027import org.tquadrat.foundation.util.stringconverter.EnumStringConverter; 028 029/** 030 * The implementation of 031 * {@link org.tquadrat.foundation.config.spi.prefs.PreferenceAccessor} 032 * for classes that extends 033 * {@link Enum}. 034 * 035 * @param <T> The concrete data type that is handled by this preference 036 * accessor type implementation. 037 * 038 * @extauthor Thomas Thrien - thomas.thrien@tquadrat.org 039 * @version $Id: EnumAccessor.java 910 2021-05-06 21:38:06Z tquadrat $ 040 * @since 0.0.1 041 * 042 * @UMLGraph.link 043 */ 044@ClassVersion( sourceVersion = "$Id: EnumAccessor.java 910 2021-05-06 21:38:06Z tquadrat $" ) 045@API( status = STABLE, since = "0.0.1" ) 046public final class EnumAccessor<T extends Enum<T>> extends SimplePreferenceAccessor<T> 047{ 048 /*--------------*\ 049 ====** Constructors **===================================================== 050 \*--------------*/ 051 /** 052 * Creates a new {@code EnumAccessor} instance. 053 * 054 * @param propertyName The name of the property. 055 * @param propertyType The type of the property. 056 * @param getter The property getter. 057 * @param setter The property setter. 058 */ 059 public EnumAccessor( final String propertyName, final Class<T> propertyType, final Getter<T> getter, final Setter<T> setter ) 060 { 061 super( propertyName, getter, setter, new EnumStringConverter<>( propertyType ) ); 062 } // EnumAccessor() 063} 064// class EnumAccessor 065 066/* 067 * End of File 068 */