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

com.feilong.lib.digester3.binder.ObjectParamBuilder 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.3.0
Show newest version
package com.feilong.lib.digester3.binder;

import com.feilong.lib.digester3.ObjectParamRule;

/**
 * Builder chained when invoking {@link LinkedRuleBuilder#objectParam(Object)}.
 *
 * @param 
 *            The object type represented by this builder
 * @since 3.0
 */
public final class ObjectParamBuilder extends AbstractBackToLinkedRuleBuilder{

    private final T paramObj;

    private int     paramIndex = 0;

    private String  attributeName;

    ObjectParamBuilder(String keyPattern, String namespaceURI, RulesBinder mainBinder, LinkedRuleBuilder mainBuilder,
                    /* @Nullable */T paramObj){
        super(keyPattern, namespaceURI, mainBinder, mainBuilder);
        this.paramObj = paramObj;
    }

    /**
     * The zero-relative index of the parameter we are saving.
     *
     * @param paramIndex
     *            The zero-relative index of the parameter we are saving
     * @return this builder instance
     */
    public ObjectParamBuilder ofIndex(int paramIndex){
        if (paramIndex < 0){
            this.reportError("objectParam( %s ).ofIndex( int )", "negative index argument not allowed");
        }

        this.paramIndex = paramIndex;
        return this;
    }

    /**
     * The attribute which we are attempting to match.
     *
     * @param attributeName
     *            The attribute which we are attempting to match
     * @return this builder instance
     */
    public ObjectParamBuilder matchingAttribute( /* @Nullable */String attributeName){
        this.attributeName = attributeName;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected ObjectParamRule createRule(){
        return new ObjectParamRule(paramIndex, attributeName, paramObj);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy