All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xwiki.properties.converter.Converter Maven / Gradle / Ivy

There is a newer version: 16.10.0-rc-1
Show newest version
/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.properties.converter;

import java.lang.reflect.Type;

import org.xwiki.component.annotation.Role;
import org.xwiki.properties.BeanManager;
import org.xwiki.properties.ConverterManager;

/**
 * General purpose data type converter that can be registered and used within the frameworks like
 * {@link ConverterManager} and {@link BeanManager} package to manage the conversion of objects from one type to
 * another.
 * 

* The type supported by the converted is indicated in its role. *

* For example: *

*

* *
 * @Component
 * public class IntegerConverter implements Converter<java.lang.Integer>
 * 
* *
*

* If a conversion cannot be performed successfully the converter is expected to throw a * {@link org.xwiki.properties.converter.ConversionException}. * * @param the type in which the provided value has to be converted * @version $Id: 70432c7f19580e385f58271945cf3df31155067a $ * @since 2.0M2 */ @Role public interface Converter { /** * Convert the specified input object into an output object of the specified type. * * @param the type in which the provided value has to be converted * @param targetType the type in which the provided value has to be converted * @param sourceValue the value to convert * @return the converted value * @throws org.xwiki.properties.converter.ConversionException if conversion cannot be performed successfully * @since 3.0M1 */ G convert(Type targetType, Object sourceValue); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy