Returns the name of the bean getter in the BeanFactory class given its name. - Java Reflection

Java examples for Reflection:Java Bean

Description

Returns the name of the bean getter in the BeanFactory class given its name.

Demo Code


//package com.java2s;

public class Main {


    /**//from  w w w  .j a va 2  s  .  c  o m
     * Returns the name of the bean getter in the BeanFactory class given its
     * name.
     * 
     * @param id
     *            Id of the bean as defined in the context file.
     * 
     * @return The name of the bean getter name in the BeanFactory class.
     */
    public static String getBeanGetterName(String id) {
        if (id == null) {
            throw new NullPointerException("Bean id cannot be null");
        }
        id = id.trim();
        if ("".equals(id)) {
            throw new IllegalArgumentException("Bean id cannot be empty");
        }
        final String id1 = id.substring(0, 1).toUpperCase()
                + id.substring(1);
        return "get" + id1;
    }
}

Related Tutorials