org.xwiki.properties.BeanManager Maven / Gradle / Ivy
/*
* 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;
import java.util.Map;
import org.xwiki.component.annotation.Role;
/**
* Component used to populate or parse a java bean.
*
* - {@link #populate(Object, Map)} ignore properties names case
* - {@link #populate(Object, Map)} validate the bean based JSR 303
* - if the bean implements {@link RawProperties}, the remaining property (the one non populated using setters of
* public fields) are given to it as custom non converted properties
*
*
* @version $Id: fd09b9b3b92d6eacabb0bc093f92a4a638a688dd $
* @since 2.0M2
*/
@Role
public interface BeanManager
{
/**
* Convert provided values and inject them in the provided java bean.
*
* @param bean the java bean to populate
* @param values the values to convert and inject in the java bean
* @throws PropertyException error append during the populate
*/
void populate(Object bean, Map values) throws PropertyException;
/**
* Parse provided java bean and return a descriptor with all its public properties.
*
* @param beanClass the java bean class to parse.
* @return the descriptor of the bean class.
*/
BeanDescriptor getBeanDescriptor(Class> beanClass);
}