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

com.feilong.lib.digester3.binder.BeanPropertySetterBuilder Maven / Gradle / Ivy

Go to download

feilong is a suite of core and expanded libraries that include utility classes, http, excel,cvs, io classes, and much much more.

There is a newer version: 4.0.8
Show newest version
package com.feilong.lib.digester3.binder;

import com.feilong.lib.digester3.BeanPropertySetterRule;

/**
 * Builder chained when invoking {@link LinkedRuleBuilder#setBeanProperty()}.
 */
public final class BeanPropertySetterBuilder extends AbstractBackToLinkedRuleBuilder{

    private String propertyName;

    private String attribute;

    BeanPropertySetterBuilder(String keyPattern, String namespaceURI, RulesBinder mainBinder, LinkedRuleBuilder mainBuilder){
        super(keyPattern, namespaceURI, mainBinder, mainBuilder);
    }

    /**
     * Sets the name of property to set.
     *
     * @param propertyName
     *            The name of property to set
     * @return this builder instance
     */
    public BeanPropertySetterBuilder withName( /* @Nullable */String propertyName){
        this.propertyName = propertyName;
        return this;
    }

    /**
     * Sets the attribute name from which the property name has to be extracted.
     *
     * @param attribute
     *            The attribute name from which extracting the name of property to set
     * @return this builder instance
     */
    public BeanPropertySetterBuilder extractPropertyNameFromAttribute(String attribute){
        if (attribute == null){
            reportError("setBeanProperty().extractPropertyNameFromAttribute( String )", "Attribute name can not be null");
        }
        this.attribute = attribute;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected BeanPropertySetterRule createRule(){
        BeanPropertySetterRule rule = new BeanPropertySetterRule(propertyName);
        rule.setPropertyNameFromAttribute(attribute);
        return rule;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy