public static ItemRule newInstance ( String type , String name , String valueType , String defaultValue , Boolean tokenize , Boolean mandatory , Boolean secret ) throws IllegalRuleException { ItemRule itemRule = new ItemRule ( ) ; ItemType itemType = ItemType . resolve ( type ) ; if ( type != null && itemType == null ) { throw new IllegalRuleException ( "No item type for '" + type + "'" ) ; } if ( itemType != null ) { itemRule . setType ( itemType ) ; } else { itemRule . setType ( ItemType . SINGLE ) ; //default } if ( ! StringUtils . isEmpty ( name ) ) { itemRule . setName ( name ) ; } else { itemRule . setAutoNamed ( true ) ; } if ( tokenize != null ) { itemRule . setTokenize ( tokenize ) ; } if ( valueType != null ) { ItemValueType itemValueType = ItemValueType . resolve ( valueType ) ; if ( itemValueType == null ) { throw new IllegalRuleException ( "No item value type for '" + valueType + "'" ) ; } itemRule . setValueType ( itemValueType ) ; } if ( defaultValue != null ) { itemRule . setDefaultValue ( defaultValue ) ; } if ( mandatory != null ) { itemRule . setMandatory ( mandatory ) ; } if ( secret != null ) { itemRule . setSecret ( secret ) ; } return itemRule ; }
Returns a new derived instance of ItemRule .