Loads all methods with a {@link Format} annotation, creates an individual {@link Formatter} instance and stores
them to the {@link #formats} map.
188665
private Map<Class<?>, Formatter> findFormatMethods()
    {
        final Map<Class<?>, Formatter> formats = new HashMap<Class<?>, Formatter>();
        for (Method method : this.getClass().getMethods())
        {
            Format formatAnnotation = method.getAnnotation(Format.class);
            if (formatAnnotation != null)
            {
                Class<?>[] parameterTypes = method.getParameterTypes();
                if (parameterTypes.length == 0)
                {
                    throw new InvalidFormatMethodException(getClass(), method, "Format methods must take at least 1 parameter!");
                }
                formats.put(parameterTypes[0], createFormatter(method, parameterTypes, formatAnnotation.value()));
            }
        }
        return formats;
    }
885175
@SuppressWarnings({"rawtypes", "unchecked"})
	private static void loadAnnotationHandlers(HandlerLibrary lib, Trees trees) throws IOException {
		//No, that seemingly superfluous reference to JavacAnnotationHandler's classloader is not in fact superfluous!
		for (JavacAnnotationHandler handler : SpiLoadUtil.findServices(JavacAnnotationHandler.class, JavacAnnotationHandler.class.getClassLoader())) {
			handler.setTrees(trees);
			Class<? extends Annotation> annotationClass = handler.getAnnotationHandledByThisHandler();
			AnnotationHandlerContainer<?> container = new AnnotationHandlerContainer(handler, annotationClass);
			String annotationClassName = container.annotationClass.getName().replace("$", ".");
			List<AnnotationHandlerContainer<?>> list = lib.annotationHandlers.get(annotationClassName);
			if (list == null) lib.annotationHandlers.put(annotationClassName, list = new ArrayList<AnnotationHandlerContainer<?>>(1));
			list.add(container);
			lib.typeLibrary.addType(container.annotationClass.getName());
		}
	}
182076
public static Format getFormat(String className) {
		assert className != null;
		if (className.isEmpty()) {
			return null;
		}

		ThreadLocal<Format> tlsFormatter = classFormatters.get(className);
		if (tlsFormatter == null) {
			try {
				// append formatter class name to cache only if exists and is of right type
				Classes.forName(className);
				tlsFormatter = new ThreadLocal<Format>();
				classFormatters.put(className, tlsFormatter);
			} catch (NoSuchBeingException e) {
				log.error("Formatter class |%s| not found.", className);
				return null;
			} catch (ClassCastException e) {
				log.error("Invalid formatter class |%s|. It should inherit from |%s|.", className, Format.class);
				return null;
			}
		}

		Format formatter = tlsFormatter.get();
		if (formatter == null) {
			formatter = createFormatter(className);
			if (formatter == null) {
				// formatter can be invalid only if miss proper constructor and this is for sure a flaw in logic
				throw new BugError("Invalid formatter class |%s|. Proper constructor not found.", className);
			}
			tlsFormatter.set(formatter);
		}
		return formatter;
	}
80579
public void setFormatter(final FormatterCallback<T> formatterCallback) {
        this.formatterCallback = formatterCallback;
        if (isAttached()) {
            setFormatter(getElement());
            refresh();
        }
    }
343605
function setFormat(format) {
            if (format === null || format === undefined) {
                throw new Error("Format is not defined " + this.clazz.$name);
            }

            if (this.format !== format) {
                this.format = format;
                this.$getSuper("setValue").call(this, this.$format(this.date));
            }

            return this;
        }
574128
private List<Map<Class<? extends Annotation>, ParameterInfo<?>>> createParametersInfos(Method method) {
    if (method.getParameterTypes().length <= 2) {
      return Collections.emptyList();
    }

    List<Map<Class<? extends Annotation>, ParameterInfo<?>>> result = new ArrayList<>();
    Type[] parameterTypes = method.getGenericParameterTypes();
    Annotation[][] parameterAnnotations = method.getParameterAnnotations();

    for (int i = 2; i < parameterAnnotations.length; i++) {
      Annotation[] annotations = parameterAnnotations[i];
      Map<Class<? extends Annotation>, ParameterInfo<?>> paramAnnotations = new IdentityHashMap<>();

      for (Annotation annotation : annotations) {
        Class<? extends Annotation> annotationType = annotation.annotationType();
        ParameterInfo<?> parameterInfo;

        if (PathParam.class.isAssignableFrom(annotationType)) {
          parameterInfo = ParameterInfo.create(annotation,
                                               ParamConvertUtils.createPathParamConverter(parameterTypes[i]));
        } else if (QueryParam.class.isAssignableFrom(annotationType)) {
          parameterInfo = ParameterInfo.create(annotation,
                                               ParamConvertUtils.createQueryParamConverter(parameterTypes[i]));
        } else if (HeaderParam.class.isAssignableFrom(annotationType)) {
          parameterInfo = ParameterInfo.create(annotation,
                                               ParamConvertUtils.createHeaderParamConverter(parameterTypes[i]));
        } else {
          parameterInfo = ParameterInfo.create(annotation, null);
        }

        paramAnnotations.put(annotationType, parameterInfo);
      }

      // Must have either @PathParam, @QueryParam or @HeaderParam, but not two or more.
      int presence = 0;
      for (Class<? extends Annotation> annotationClass : paramAnnotations.keySet()) {
        if (SUPPORTED_PARAM_ANNOTATIONS.contains(annotationClass)) {
          presence++;
        }
      }
      if (presence != 1) {
        throw new IllegalArgumentException(
          String.format("Must have exactly one annotation from %s for parameter %d in method %s",
                        SUPPORTED_PARAM_ANNOTATIONS, i, method));
      }

      result.add(Collections.unmodifiableMap(paramAnnotations));
    }

    return Collections.unmodifiableList(result);
  }
1169361
public Set<Method> getMethodsWithAnyParamAnnotated(Class<? extends Annotation> annotation) {
        return getMethodsFromDescriptors(store.get(index(MethodParameterScanner.class), annotation.getName()), loaders());

    }
101484
private StepFormatter.Formatting<?, ?> getFormatting( Annotation[] annotations, Set<Class<?>> visitedTypes,
            Annotation originalAnnotation, String parameterName ) {
        List<StepFormatter.Formatting<?, ?>> foundFormatting = Lists.newArrayList();
        Table tableAnnotation = null;
        for( Annotation annotation : annotations ) {
            try {
                if( annotation instanceof Format ) {
                    Format arg = (Format) annotation;
                    foundFormatting.add( new StepFormatter.ArgumentFormatting( ReflectionUtil.newInstance( arg.value() ), arg.args() ) );
                } else if( annotation instanceof Table ) {
                    tableAnnotation = (Table) annotation;
                } else if( annotation instanceof AnnotationFormat ) {
                    AnnotationFormat arg = (AnnotationFormat) annotation;
                    foundFormatting.add( new StepFormatter.ArgumentFormatting(
                        new StepFormatter.AnnotationBasedFormatter( arg.value().newInstance(), originalAnnotation ) ) );
                } else {
                    Class<? extends Annotation> annotationType = annotation.annotationType();
                    if( !visitedTypes.contains( annotationType ) ) {
                        visitedTypes.add( annotationType );
                        StepFormatter.Formatting<?, ?> formatting = getFormatting( annotationType.getAnnotations(), visitedTypes,
                            annotation, parameterName );
                        if( formatting != null ) {
                            foundFormatting.add( formatting );
                        }
                    }
                }
            } catch( Exception e ) {
                throw Throwables.propagate( e );
            }
        }

        if( foundFormatting.size() > 1 ) {
            Formatting<?, ?> innerFormatting = Iterables.getLast( foundFormatting );
            foundFormatting.remove( innerFormatting );

            ChainedFormatting<?> chainedFormatting = new StepFormatter.ChainedFormatting<Object>( (ObjectFormatter<Object>) innerFormatting );
            for( StepFormatter.Formatting<?, ?> formatting : Lists.reverse( foundFormatting ) ) {
                chainedFormatting.addFormatting( (StepFormatter.Formatting<?, String>) formatting );
            }

            foundFormatting.clear();
            foundFormatting.add( chainedFormatting );
        }

        if( tableAnnotation != null ) {
            ObjectFormatter<?> objectFormatter = foundFormatting.isEmpty()
                    ? DefaultFormatter.INSTANCE
                    : foundFormatting.get( 0 );
            return getTableFormatting( annotations, parameterName, tableAnnotation, objectFormatter );
        }

        if( foundFormatting.isEmpty() ) {
            return null;
        }

        return foundFormatting.get( 0 );
    }
1210845
public static Map<Integer, List<AnnotationInstance>> createParameterAnnotationMap(final MethodInfo method) {
        final Map<Integer, List<AnnotationInstance>> result = new HashMap<>();
        for (AnnotationInstance ai : method.annotations()) {
            final AnnotationTarget at = ai.target();
            if (at.kind() == AnnotationTarget.Kind.METHOD_PARAMETER) {
                final MethodParameterInfo mp = at.asMethodParameter();
                final int pos = (int) mp.position();
                List<AnnotationInstance> list = result.get(pos);
                if (list == null) {
                    list = new ArrayList<>();
                    result.put(pos, list);
                }
                list.add(ai);
            }
        }
        return result;
    }
1360220
private void storeMethod(Method method, Map<Key, Array> methodsMap) {
	Key methodName = KeyImpl.init(method.getName());

	Array methodArgs;
	synchronized (methodsMap) {
	    methodArgs = methodsMap.get(methodName);
	    if (methodArgs == null) {
		methodArgs = new ArrayImpl();
		methodsMap.put(methodName, methodArgs);
	    }
	}

	storeArgs(method, methodArgs);
	// Modifier.isStatic(method.getModifiers());
    }
1213837
public void loadStructures(Set<Method> dynamicMethodsToWrite) {
		
	   	for (Field configuredField : getListOfFields(configuredClass)) {
		
	   		String targetFieldName = configReader.retrieveTargetFieldName(configuredField);
			
			if(targetFieldName == THE_FIELD_IS_NOT_CONFIGURED) continue;
				
			boolean isNestedMapping = isNestedMapping(targetFieldName);
			
			Field targetField = null;
			NestedMappingInfo nestedMappingInfo = null;
			
			if(isNestedMapping)
				try{	
					nestedMappingInfo = loadNestedMappingInformation(xml, targetClass, targetFieldName, sourceClass, destinationClass, configuredField);
				    targetField = nestedMappingInfo.getLastNestedField();
				}catch(InvalidNestedMappingException e){
				    // catch and rethrown the exception with more information
				    Error.invalidNestedMapping(configuredClass, configuredField, targetClass, e.getMessage(), e.getMessages().get(InvalidNestedMappingException.FIELD));}
			else
				targetField = retrieveField(targetClass,targetFieldName);
			
			
			MappedField configuredMappedField = new MappedField(configuredField);
			
			MappedField targetMappedField     = isNestedMapping ?nestedMappingInfo.getLastNestedMappedField()
					                                            :new MappedField(targetField);

			MappedField destinationMappedField = isDestConfigured?configuredMappedField:targetMappedField;
			MappedField sourceMappedField = isDestConfigured?targetMappedField:configuredMappedField;

			Field destinationField = isDestConfigured?configuredField:targetField;
			Field sourceField      = isDestConfigured?targetField:configuredField;
			
			//load and check the get/set custom methods of destination and source fields
			if(isNestedMapping)	configReader.loadAccessors(nestedMappingInfo.getLastNestedClass(),configuredMappedField, targetMappedField);
			else				configReader.loadAccessors(configuredMappedField, targetMappedField);
			
			boolean isUndefined = false;
			
			try{
				isUndefined = operationAnalyzer.isUndefined(destinationField, sourceField);
			}catch(Exception e){
				// catch and rethrown the exception with more information
				Error.badConversion(destinationField, destinationClass, sourceField, sourceClass,e.getMessage());
			}
			
			if(isUndefined)	
				Error.undefinedMapping(destinationField, destinationClass, sourceField, sourceClass);
			
			InfoOperation info = operationAnalyzer.getInfo();
			
			OperationType operationType = info.getOperationType();

			AGeneralOperation operation = OperationFactory.getOperation(operationType);
			
			if(operationType.isBasic())
				simpleOperations.add((ASimpleOperation) operation);	
				
			if(operationType.isComplex())
				complexOperations.add(((AComplexOperation) operation)
						.setDestinationClass(defineStructure(destinationMappedField.getValue(), sourceMappedField.getValue())));
			
 			if(operationType.isRecursive())
				((ARecursiveOperation) operation).setDynamicMethodsToWrite(dynamicMethodsToWrite)
				 							     .setXml(xml)
				                                 .setConfigChosen(isNull(info.getConfigChosen()) // if both classes are configured
										                    	  ?configurationChosen		     // returns the configuration chosen
												                  :info.getConfigChosen());      // else returns the configuration retrieved
			// common settings
			operation.setDestinationField(destinationMappedField)
					 .setSourceField(sourceMappedField)
					 .setInfoOperation(info)
					 .setNestedMappingInfo(nestedMappingInfo);
						
			
			boolean isAvoidSet = false;
			boolean isConversion = info.getOperationType().isAConversion();
			
			if(isConversion)
				isAvoidSet = conversionAnalyzer.getMethod().isAvoidSet();
			
			// verifies destination accessors only if isn't a nested field
			if(!isNestedMapping || !targetClass.equals(destinationClass))
				if(isAvoidSet)	verifyGetterMethods(destinationClass,destinationMappedField);
				else		verifiesAccessorMethods(destinationClass,destinationMappedField);
			
			// verifies source accessors only if isn't a nested field
			if(!isNestedMapping || !targetClass.equals(sourceClass))
				verifyGetterMethods(sourceClass,sourceMappedField);
				findSetterMethods(sourceClass,sourceMappedField);
			
			operation.avoidDestinationSet(isAvoidSet);

			if(isConversion){
				
				conversionHandler.load(conversionAnalyzer)
				                 .from(sourceMappedField).to(destinationMappedField);
				
				// in case of dynamic conversion
				if(conversionHandler.toBeCreated())
					dynamicMethodsToWrite.add(conversionHandler.loadMethod());
				
				operation.setConversionMethod(conversionHandler.getMethod())
						 .setMemberShip      (conversionHandler.getMembership());
			}
				
		}
		
		// checks if there isn't a correspondence between classes
		if(simpleOperations.isEmpty() && complexOperations.isEmpty())
				Error.absentRelationship(configuredClass, targetClass);	
	}
1000329
private void populateAnnotations(Collection<Annotation> annotations) {
        for (Annotation each : annotations) {
            this.annotations.put(each.annotationType(), each);
        }
    }
1060333
private static List<List<Annotation>> getParameterAnnotations(Method method) {
		if (methodParamAnnotationCache.containsKey(method)) {
			return methodParamAnnotationCache.get(method);
		}
		List<List<Annotation>> annotations = new ArrayList<>();
		for (Annotation[] paramAnnotations : method.getParameterAnnotations()) {
			List<Annotation> listAnnotations = new ArrayList<>();
			Collections.addAll(listAnnotations, paramAnnotations);
			annotations.add(listAnnotations);
		}
		annotations = Collections.unmodifiableList(annotations);
		methodParamAnnotationCache.put(method, annotations);
		return annotations;
	}
1357659
public AnnotatedTypeBuilder<X> addToMethod(Method method, Annotation annotation) {
       if (methods.get(method) == null) {
           methods.put(method, new AnnotationBuilder());
       }
       methods.get(method).add(annotation);
       return this;
   }
854163
public void registerFormatter(Class<IFormatter>... formatterClasses) {
        for (Class<IFormatter> cls : formatterClasses) {
            try {
                IFormatter fmt = cls.newInstance();
                extensionManager().registerFormatter(fmt);
            } catch (Exception e) {
                Logger.error(e, "Error get formatter instance from class[%s]", cls);
            }
        }
    }
900008
public static void loadResource(final String serializerId,
      @SuppressWarnings("rawtypes") final Map<String, ArtifactSerializer> artifactSerializers,
      final String resourcePath, final Map<String, Object> resources) {

    final File resourceFile = new File(resourcePath);
    if (resourceFile != null) {
      final String resourceId = IOUtils
          .normalizeLexiconName(resourceFile.getName());
      final ArtifactSerializer<?> serializer = artifactSerializers
          .get(serializerId);
      final InputStream resourceIn = IOUtils.openFromFile(resourceFile);
      try {
        resources.put(resourceId, serializer.create(resourceIn));
      } catch (final InvalidFormatException e) {
        e.printStackTrace();
      } catch (final IOException e) {
        e.printStackTrace();
      } finally {
        try {
          resourceIn.close();
        } catch (final IOException e) {
        }
      }
    }
  }
1101955
function loadFormatters(){
    var arrFiles = glob.sync('./formatters/*.js', {
        'cwd': __dirname,
        'dot': false,
        'nodir': true,
        'strict': false,
        'silent': true
    });
    var mapFormatters = {};
    arrFiles.forEach(function(file){
        var fileInfo = path.parse(file);
        var formatterPath = path.resolve(__dirname, file);
        mapFormatters[fileInfo.name] = require(formatterPath);
    });
    return mapFormatters;
}