olg.csv.bean.annotations.processor
Class FormatterProcessor

Package class diagram package FormatterProcessor
java.lang.Object
  extended by olg.csv.bean.annotations.processor.FormatterProcessor

public final class FormatterProcessor
extends Object

This class is responsible for processing the @Formatter annotation.


Field Summary
private static FormatterProcessor instance
          Singleton instance.
private static org.slf4j.Logger LOGGER
          The class logger.
 
Constructor Summary
private FormatterProcessor()
          Private constructor to ensure the existence of singleton.
 
Method Summary
private
<T> Formatter<T>
getCustomFormatter(Field field, Formatter formatterAnnotation, Class<T> fieldConcreteClass)
          Returns a formatter identified from the formatter annotation setted on a field as a custom formatter.
private
<T> Formatter<Date>
getDateFormatter(Field field, Formatter formatterAnnotation, Class<T> fieldConcreteClass)
          Returns a date formatter identified from the formatter annotation setted on a field.
<T> Formatter<T>
getFormatter(Field field, Class<T> fieldConcreteClass)
          Return the formatter to use on a field.
static FormatterProcessor getInstance()
          The singleton instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final org.slf4j.Logger LOGGER
The class logger.


instance

private static FormatterProcessor instance
Singleton instance.

Constructor Detail

FormatterProcessor

private FormatterProcessor()
Private constructor to ensure the existence of singleton.

Method Detail

getInstance

public static FormatterProcessor getInstance()
The singleton instance.

Returns:
the singleton instance

getFormatter

public <T> Formatter<T> getFormatter(Field field,
                                     Class<T> fieldConcreteClass)
                          throws AnnotationProcessorException
Return the formatter to use on a field. If no formatter annotation is setted on the field, a default formatter is returned (use the toString method of the concrete class)

Type Parameters:
T - the type the formatter deals with.
Parameters:
field - the field to format
fieldConcreteClass - the concrete class
Returns:
the formatter
Throws:
AnnotationProcessorException - if an error occurs

getDateFormatter

private <T> Formatter<Date> getDateFormatter(Field field,
                                             Formatter formatterAnnotation,
                                             Class<T> fieldConcreteClass)
                                  throws AnnotationProcessorException
Returns a date formatter identified from the formatter annotation setted on a field.

Type Parameters:
T - the type the formatte deals with.
Parameters:
field - the field
formatterAnnotation - the annotation setted on the field.
fieldConcreteClass - the concrete class the formatter deals with.
Returns:
the Date formatter
Throws:
AnnotationProcessorException - if an error occurs

getCustomFormatter

private <T> Formatter<T> getCustomFormatter(Field field,
                                            Formatter formatterAnnotation,
                                            Class<T> fieldConcreteClass)
                                 throws AnnotationProcessorException
Returns a formatter identified from the formatter annotation setted on a field as a custom formatter.

Type Parameters:
T - the type the formatter deals with.
Parameters:
field - the field.
formatterAnnotation - the annotatin setted on the field.
fieldConcreteClass - the concrete class the formatter deals with.
Returns:
the custom formatter
Throws:
AnnotationProcessorException - if an error occurs


Copyright © 2014. All Rights Reserved.