src/main/java/org/fit/layout/impl/BaseParametrizedOperation.java
@Override
    public boolean setParam(String name, Object value)
    {
        String sname = "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
        Method m;
        try {
            if (value instanceof Integer)
            {
                m = getClass().getMethod(sname, int.class);
                m.invoke(this, value);
            }
            else if (value instanceof Double)
            {
                try {
                    m = getClass().getMethod(sname, float.class);
                    m.invoke(this, ((Double) value).floatValue());
                } catch (NoSuchMethodException e) {
                    //no float version found, try the int version
                    m = getClass().getMethod(sname, int.class);
                    m.invoke(this, ((Double) value).intValue());
                }
            }
            else if (value instanceof Float)
            {
                try {
                    m = getClass().getMethod(sname, float.class);
                    m.invoke(this, value);
                } catch (NoSuchMethodException e) {
                    //no float version found, try the int version
                    m = getClass().getMethod(sname, int.class);
                    m.invoke(this, ((Double) value).intValue());
                }
            }
            else if (value instanceof Boolean)
            {
                m = getClass().getMethod(sname, boolean.class);
                m.invoke(this, value);
            }
            else
            {
                m = getClass().getMethod(sname, String.class);
                m.invoke(this, value.toString());
            }
            return true;
            
        } catch (NoSuchMethodException e) {
            log.warn("Setting unknown parameter: " + e.getMessage());
            return false;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            return false;
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            return false;
        } catch (InvocationTargetException e) {
            e.printStackTrace();
            return false;
        }
    }
@Override
    public boolean setParam(String name, Object value)
    {
        String sname = "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
        Method m;
        try {
            if (value instanceof Integer)
            {
                m = getClass().getMethod(sname, int.class);
                m.invoke(this, value);
            }
            else if (value instanceof Double)
            {
                try {
                    m = getClass().getMethod(sname, float.class);
                    m.invoke(this, ((Double) value).floatValue());
                } catch (NoSuchMethodException e) {
                    //no float version found, try the int version
                    m = getClass().getMethod(sname, int.class);
                    m.invoke(this, ((Double) value).intValue());
                }
            }
            else if (value instanceof Float)
            {
                try {
                    m = getClass().getMethod(sname, float.class);
                    m.invoke(this, value);
                } catch (NoSuchMethodException e) {
                    //no float version found, try the int version
                    m = getClass().getMethod(sname, int.class);
                    m.invoke(this, ((Double) value).intValue());
                }
            }
            else if (value instanceof Boolean)
            {
                m = getClass().getMethod(sname, boolean.class);
                m.invoke(this, value);
            }
            else
            {
                m = getClass().getMethod(sname, String.class);
                m.invoke(this, value.toString());
            }
            return true;
            
        } catch (NoSuchMethodException e) {
            log.warn("Setting unknown parameter: " + e.getMessage());
            return false;
        } catch (IllegalAccessException e) {
            e.printStackTrace();
            return false;
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            return false;
        } catch (InvocationTargetException e) {
            e.printStackTrace();
            return false;
        }
    }
@ Override public boolean setParam ( String name , Object value ) { String sname = "set" + name . substring ( 0 , 1 ) . toUpperCase ( ) + name . substring ( 1 ) ; Method m ; try { if ( value instanceof Integer ) { m = getClass ( ) . getMethod ( sname , int . class ) ; m . invoke ( this , value ) ; } else if ( value instanceof Double ) { try { m = getClass ( ) . getMethod ( sname , float . class ) ; m . invoke ( this , ( ( Double ) value ) . floatValue ( ) ) ; } catch ( NoSuchMethodException e ) { //no float version found, try the int version m = getClass ( ) . getMethod ( sname , int . class ) ; m . invoke ( this , ( ( Double ) value ) . intValue ( ) ) ; } } else if ( value instanceof Float ) { try { m = getClass ( ) . getMethod ( sname , float . class ) ; m . invoke ( this , value ) ; } catch ( NoSuchMethodException e ) { //no float version found, try the int version m = getClass ( ) . getMethod ( sname , int . class ) ; m . invoke ( this , ( ( Double ) value ) . intValue ( ) ) ; } } else if ( value instanceof Boolean ) { m = getClass ( ) . getMethod ( sname , boolean . class ) ; m . invoke ( this , value ) ; } else { m = getClass ( ) . getMethod ( sname , String . class ) ; m . invoke ( this , value . toString ( ) ) ; } return true ; } catch ( NoSuchMethodException e ) { log . warn ( "Setting unknown parameter: " + e . getMessage ( ) ) ; return false ; } catch ( IllegalAccessException e ) { e . printStackTrace ( ) ; return false ; } catch ( IllegalArgumentException e ) { e . printStackTrace ( ) ; return false ; } catch ( InvocationTargetException e ) { e . printStackTrace ( ) ; return false ; } }
Sets the parameter using the appropriate setter method (if present).
Sets the parameter using the appropriate setter method ( if present ) .