class UserPropertyTransformer extends AbstractPropertyTransformer<User> {

    @Override
    @SuppressWarnings( { "unchecked", "rawtypes" } )
    public Object transform( Object o )
    {
        if ( !(o instanceof User) )
        {
            if ( o instanceof Collection )
            {
                Collection collection = (Collection) o;

                if ( collection.isEmpty() )
                {
                    return o;
                }

                Object next = collection.iterator().next();

                if ( !(next instanceof User) )
                {
                    return o;
                }

                Collection<UserDto> userDtoCollection = newCollectionInstance( collection.getClass() );
                collection.forEach( user -> userDtoCollection.add( buildUserDto( (User) user ) ) );

                return userDtoCollection;
            }

            return o;
        }

        return buildUserDto( (User) o );
    }

    public  UserPropertyTransformer();

}