com.feilong.lib.digester3.binder.ObjectParamBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of feilong Show documentation
Show all versions of feilong Show documentation
feilong is a suite of core and expanded libraries that include utility classes, http, excel,cvs, io classes, and much much more.
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);
}
}