public void register ( final FieldDefinition definition ) { //ensure that we can't register a mandatory definition if there are already optional ones boolean hasOptionalField = false ; for ( final FieldDefinition fieldDefinition : fields . values ( ) ) { if ( fieldDefinition . isOptional ( ) ) { hasOptionalField = true ; break ; } } if ( ! definition . isOptional ( ) && hasOptionalField ) { throw new IllegalArgumentException ( "Can't register mandatory definition after a optional definition." ) ; } fields . put ( definition . getFieldName ( ) , definition ) ; }
Registers a certain FieldDefinition .