public String getValidator( Named<?> named )
{
if (named instanceof Parameter)
{
Parameter param = (Parameter) named;
TypeRef type = param.type();
if (type.isBuiltin())
return String.format( "Validator_%s.get( %d )",
type.type(), type.dim() );
Named<?> n = type.getNamed( type.intf() );
if (n.isBuiltin())
{
Builtin b = (Builtin) n;
String cn = b.className();
int i = cn.indexOf( '<' );
if (i >= 0)
cn = cn.substring( 0, i );
return String.format( "Validator_custom.get( %s.class, %d, %s )",
cn, type.dim(), b.allowSubclass() );
}
// Allow subclassing for etch defined structs and externs.
if (n.isStruct() || n.isExcept())
return String.format( "Validator_custom.get( %s.class, %d, true )",
n.efqname( this ), type.dim() );
// Don't allow subclassing for externs or etch defined enums.
if (!(n.isExtern() || n.isEnumx()))
Assertion.check( n.isExtern() || n.isEnumx(),
"n.isExtern() || n.isEnumx(): "+n );
return String.format( "Validator_custom.get( %s.class, %d, false )",
n.efqname( this ), type.dim() );
}
if (named instanceof Thrown)
{
Thrown thrown = (Thrown) named;