public static void setProperty ( Object object , String propertyName , String propertyValue ) { Method method = getWriteMethod ( object , propertyName ) ; if ( method == null ) { throw new UnexpectedLiquibaseException ( String . format ( "Property [%s] was not found for object type [%s]" , propertyName , object . getClass ( ) . getName ( ) ) ) ; } Class < ? > parameterType = method . getParameterTypes ( ) [ 0 ] ; Object finalValue = propertyValue ; if ( parameterType . equals ( Boolean . class ) || parameterType . equals ( boolean . class ) ) { finalValue = Boolean . valueOf ( propertyValue ) ; } else if ( parameterType . equals ( Integer . class ) ) { finalValue = Integer . valueOf ( propertyValue ) ; } else if ( parameterType . equals ( Long . class ) ) { finalValue = Long . valueOf ( propertyValue ) ; } else if ( parameterType . equals ( BigInteger . class ) ) { finalValue = new BigInteger ( propertyValue ) ; } else if ( parameterType . equals ( BigDecimal . class ) ) { finalValue = new BigDecimal ( propertyValue ) ; } else if ( parameterType . equals ( DatabaseFunction . class ) ) { finalValue = new DatabaseFunction ( propertyValue ) ; } else if ( parameterType . equals ( SequenceNextValueFunction . class ) ) { finalValue = new SequenceNextValueFunction ( propertyValue ) ; } else if ( parameterType . equals ( SequenceCurrentValueFunction . class ) ) { finalValue = new SequenceCurrentValueFunction ( propertyValue ) ; } else if ( Enum . class . isAssignableFrom ( parameterType ) ) { finalValue = Enum . valueOf ( ( Class < Enum > ) parameterType , propertyValue ) ; } try { method . invoke ( object , finalValue ) ; } catch ( IllegalAccessException | InvocationTargetException e ) { throw new UnexpectedLiquibaseException ( e ) ; } catch ( IllegalArgumentException e ) { throw new UnexpectedLiquibaseException ( "Cannot call " + method . toString ( ) + " with value of type " + finalValue . getClass ( ) . getName ( ) ) ; } }
Tries to guess the real data type of propertyValue by the given propertyName then sets the selected property of the given object to that value .