public void setValue ( Change change , Object value ) { if ( ( value instanceof String ) && ( ! "string" . equals ( dataType ) ) ) { try { switch ( dataType ) { case "bigInteger" : value = new BigInteger ( ( String ) value ) ; break ; case "databaseFunction" : value = new DatabaseFunction ( ( String ) value ) ; break ; default : throw new UnexpectedLiquibaseException ( "Unknown data type: " + dataType ) ; } } catch ( Exception e ) { throw new UnexpectedLiquibaseException ( "Cannot convert string value '" + value + "' to " + dataType + ": " + e . getMessage ( ) ) ; } } try { for ( PropertyDescriptor descriptor : PropertyUtils . getInstance ( ) . getDescriptors ( change . getClass ( ) ) ) { if ( descriptor . getDisplayName ( ) . equals ( this . parameterName ) ) { Method writeMethod = descriptor . getWriteMethod ( ) ; if ( writeMethod == null ) { throw new UnexpectedLiquibaseException ( "Could not find writeMethod for " + this . parameterName ) ; } Class < ? > expectedWriteType = writeMethod . getParameterTypes ( ) [ 0 ] ; if ( ( value != null ) && ! expectedWriteType . isAssignableFrom ( value . getClass ( ) ) ) { if ( expectedWriteType . equals ( String . class ) ) { value = value . toString ( ) ; } else { throw new UnexpectedLiquibaseException ( "Could not convert " + value . getClass ( ) . getName ( ) + " to " + expectedWriteType . getName ( ) ) ; } } writeMethod . invoke ( change , value ) ; } } } catch ( Exception e ) { throw new UnexpectedLiquibaseException ( "Error setting " + this . parameterName + " to " + value , e ) ; } }
Sets the value of this parameter on the given change .