converters.VoteToStringConverter.java Source code

Java tutorial

Introduction

Here is the source code for converters.VoteToStringConverter.java

Source

/* VotationToStringConverter.java
*
* Copyright (C) 2013 Universidad de Sevilla
* 
* The use of this project is hereby constrained to the conditions of the 
* TDG Licence, a copy of which you may download from 
* http://www.tdg-seville.info/License.html
* 
*/

package converters;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import domain.Vote;

@Component
@Transactional
public class VoteToStringConverter implements Converter<Vote, String> {

    @Override
    public String convert(Vote vote) {
        Assert.notNull(vote);

        String result;

        result = String.valueOf(vote.getId());

        return result;
    }

}