public static ConversionMethod toConversionMethod(Method aMethod){
  JMapConversion conversion=aMethod.getAnnotation(JMapConversion.class);
  String name=aMethod.getName();
  String[] from=trim(conversion.from());
  String[] to=trim(conversion.to());
  Type type=conversion.type();
  boolean avoidSet=conversion.avoidSet();
  ParameterNumber number=null;
  String body=null;
switch (type) {
case STATIC:
switch (aMethod.getParameterTypes().length) {
case 1:
      number=ONE;
    break;
case 2:
  number=TWO;
break;
default :
throw new ConversionParameterException("is allowed to use from one to two parameters");
}
body=CONTENT_ALREADY_DEFINED;
break;
case DYNAMIC:
if (aMethod.getParameterTypes().length != 0) throw new DynamicConversionParameterException("is not allowed parameters usage in a dynamic method");
try {
body=(String)aMethod.invoke(null,new Object[]{});
}
 catch (Exception e) {
throw new DynamicConversionMethodException("the method don't respects the conventions");
}
if (!body.contains(source) && body.contains(destination)) throw new DynamicConversionBodyException("the use of the destination isn't permitted without the use of the source");
number=body.contains(source) ? body.contains(destination) ? TWO : ONE : ZERO;
break;
}
return new ConversionMethod(name,from,to,type,number,body,avoidSet);
}

public static ConversionMethod toConversionMethod ( Method aMethod ) { JMapConversion conversion = aMethod . getAnnotation ( JMapConversion . class ) ; String name = aMethod . getName ( ) ; String [ ] from = trim ( conversion . from ( ) ) ; String [ ] to = trim ( conversion . to ( ) ) ; Type type = conversion . type ( ) ; boolean avoidSet = conversion . avoidSet ( ) ; ParameterNumber number = null ; String body = null ; switch ( type ) { case STATIC : switch ( aMethod . getParameterTypes ( ) . length ) { case 1 : number = ONE ; break ; case 2 : number = TWO ; break ; default : throw new ConversionParameterException ( "is allowed to use from one to two parameters" ) ; } body = CONTENT_ALREADY_DEFINED ; break ; case DYNAMIC : if ( aMethod . getParameterTypes ( ) . length != 0 ) throw new DynamicConversionParameterException ( "is not allowed parameters usage in a dynamic method" ) ; try { body = ( String ) aMethod . invoke ( null , new Object [ ] { } ) ; } catch ( Exception e ) { throw new DynamicConversionMethodException ( "the method don't respects the conventions" ) ; } if ( ! body . contains ( source ) && body . contains ( destination ) ) throw new DynamicConversionBodyException ( "the use of the destination isn't permitted without the use of the source" ) ; number = body . contains ( source ) ? body . contains ( destination ) ? TWO : ONE : ZERO ; break ; } return new ConversionMethod ( name , from , to , type , number , body , avoidSet ) ; }
this method transforms a method given in input , into a conversionmethod .
