olg.csv.bean.annotations.processor
Class ParserProcessor

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

public final class ParserProcessor
extends Object

This class is responsible for processing the @Parser annotation.


Field Summary
private static ParserProcessor instance
          The Singleton instance.
private static org.slf4j.Logger LOGGER
          The class logger.
 
Constructor Summary
private ParserProcessor()
          Private constructor to ensure the existence of singleton.
 
Method Summary
private
<T> AbstractParser<T>
getCustomParser(Field field, Parser parserAnnotation, Class<T> fieldConcreteClass)
          Returns a parser identified from the parser annotation setted on a field as a custom parser.
private
<T> AbstractParser<Date>
getDateParser(Field field, Parser parserAnnotation, Class<T> fieldConcreteClass)
          Returns a date parser identified from the parser annotation setted on a field.
static ParserProcessor getInstance()
          The singleton instance.
<T> AbstractParser<T>
getParser(Field field, Class<T> fieldConcreteClass)
          Return the parser to use on a field.
 
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 ParserProcessor instance
The Singleton instance.

Constructor Detail

ParserProcessor

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

Method Detail

getInstance

public static ParserProcessor getInstance()
The singleton instance.

Returns:
the singleton instance

getParser

public <T> AbstractParser<T> getParser(Field field,
                                       Class<T> fieldConcreteClass)
                            throws AnnotationProcessorException
Return the parser to use on a field. If no parser annotation is setted on the field, try to identify a default parser from the concrete class.

Type Parameters:
T - the type the parser must return
Parameters:
field - the field
fieldConcreteClass - the concrete class from which instanciate the field values.
Returns:
the parser
Throws:
AnnotationProcessorException - if an error occurs during annotation reading or if no parser has been found.
See Also:
AbstractParser.identifyDefaultParser(Class)

getDateParser

private <T> AbstractParser<Date> getDateParser(Field field,
                                               Parser parserAnnotation,
                                               Class<T> fieldConcreteClass)
                                    throws AnnotationProcessorException
Returns a date parser identified from the parser annotation setted on a field.

Type Parameters:
T - the type the parser must return
Parameters:
field - the field.
parserAnnotation - the annotation setted on the field
fieldConcreteClass - the concrete class from which instanciate the field values.
Returns:
the date parser
Throws:
AnnotationProcessorException - if an error occurs

getCustomParser

private <T> AbstractParser<T> getCustomParser(Field field,
                                              Parser parserAnnotation,
                                              Class<T> fieldConcreteClass)
                                   throws AnnotationProcessorException
Returns a parser identified from the parser annotation setted on a field as a custom parser.

Type Parameters:
T - the type the parser must return
Parameters:
field - the field
parserAnnotation - the annotation setted on the field.
fieldConcreteClass - the concrete class from which instanciate the field values.
Returns:
the parser
Throws:
AnnotationProcessorException - if an error occurs


Copyright © 2014. All Rights Reserved.