Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

ConvertUtils problem solved!

I got the solution to my ConvertUtils problem from the hibernate-devel mailing list. Thanks to Juozas Baliuka! Here's my new convert method:

public Object convert(Class type, Object value) {
    if (log.isDebugEnabled()) {
        log.debug("entering 'convert' method");
    }

    // for a null value, return null
    if (value == null) {
        return null;
    } else if (value.getClass().isAssignableFrom(type)) {
        return value;
    } else if (ArrayList.class.isAssignableFrom(type)
                   && (value instanceof Collection)) {
        return new ArrayList((Collection) value); // List, Set, Collection  -> ArrayList
    } else if (type.isAssignableFrom(Collection.class)
                   && (value instanceof Collection)) {
        try {
            //most of collections implement this constructor
            Constructor constructor =
                type.getConstructor(new Class[] { Collection.class });

            return constructor.newInstance(new Object[] { value });
        } catch (Exception e) {
            log.error(e);
        }
    }

    throw new ConversionException("Could not convert "
                                  + value.getClass().getName() + " to "
                                  + type.getName() + "!");
}

Posted in Java at Jan 13 2003, 09:15:09 AM MST Add a Comment