Build the new serializer method.

@param mappedTypeClass the type to map

@return the method
770025
private MethodSpec buildNewSerializerMethod( JClassType mappedTypeClass ) throws UnableToCompleteException {
        JSerializerType type;
        try {
            type = getJsonSerializerFromType( mappedTypeClass );
        } catch ( UnsupportedTypeException e ) {
            logger.log( Type.ERROR, "Cannot generate mapper due to previous errors : " + e.getMessage() );
            throw new UnableToCompleteException();
        }

        return MethodSpec.methodBuilder( "newSerializer" )
                .addModifiers( Modifier.PROTECTED )
                .addAnnotation( Override.class )
                .returns( ParameterizedTypeName.get( ClassName.get( JsonSerializer.class ), DEFAULT_WILDCARD ) )
                .addStatement( "return $L", type.getInstance() )
                .build();
    }
607670
public <T extends Mapping> T getMapping(MappingType type)
    {
        return (T) mappings.get(type);
    }
257379
protected function buildMapping($mappedClass)
    {
        return (\is_string($mappedClass) && \class_exists($mappedClass, true)) ?
            MappingFactory::fromClass($mappedClass) :
            MappingFactory::fromArray($mappedClass);
    }
434722
public static <A extends Annotation> EnhancedAnnotation<A> create(SlimAnnotatedType<A> annotatedType, ClassTransformer classTransformer) {

        Class<A> annotationType = annotatedType.getJavaClass();

        Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
        annotationMap.putAll(buildAnnotationMap(annotatedType.getAnnotations()));
        annotationMap.putAll(buildAnnotationMap(classTransformer.getTypeStore().get(annotationType)));
        // Annotations and declared annotations are the same for annotation type
        return new EnhancedAnnotationImpl<A>(annotatedType, annotationMap, annotationMap, classTransformer);
    }
1001525
public static Class<?> getMapperClass(String msId) {
        if (msId.indexOf(".") == -1) {
            throw new MapperException("当前MappedStatement的id=" + msId + ",不符合MappedStatement的规则!");
        }
        String mapperClassStr = msId.substring(0, msId.lastIndexOf("."));
        //由于一个接口中的每个方法都会进行下面的操作，因此缓存
        Class<?> mapperClass = (Class<?>) CLASS_CACHE.getObject(mapperClassStr);
        if(mapperClass != null){
            return mapperClass;
        }
        ClassLoader[] classLoader = getClassLoaders();

        for (ClassLoader cl : classLoader) {
            if (null != cl) {
                try {
                    mapperClass = Class.forName(mapperClassStr, true, cl);
                    if (mapperClass != null) {
                        break;
                    }
                } catch (ClassNotFoundException e) {
                    // we'll ignore this until all class loaders fail to locate the class
                }
            }
        }
        if (mapperClass == null) {
            throw new MapperException("class loaders failed to locate the class " + mapperClassStr);
        }
        CLASS_CACHE.putObject(mapperClassStr, mapperClass);
        return mapperClass;
    }
1103687
private static TypeSerializer<?>[] createRegisteredSubclassSerializers(
			LinkedHashSet<Class<?>> registeredSubclasses,
			ExecutionConfig executionConfig) {

		final TypeSerializer<?>[] subclassSerializers = new TypeSerializer[registeredSubclasses.size()];

		int i = 0;
		for (Class<?> registeredClass : registeredSubclasses) {
			subclassSerializers[i] = TypeExtractor.createTypeInfo(registeredClass).createSerializer(executionConfig);
			i++;
		}

		return subclassSerializers;
	}
276668
public static <T> RuntimeSchema<T> createFrom(Class<T> typeClass)
    {
        return createFrom(typeClass, NO_EXCLUSIONS, ID_STRATEGY);
    }
19285
public <T> JsonReaderI<T> getMapper(Class<T> type) {
		// look for cached Mapper
		@SuppressWarnings("unchecked")
		JsonReaderI<T> map = (JsonReaderI<T>) cache.get(type);
		if (map != null)
			return map;
		/*
		 * Special handle
		 */
		if (type instanceof Class) {
			if (Map.class.isAssignableFrom(type))
				map = new DefaultMapperCollection<T>(this, type);
			else if (List.class.isAssignableFrom(type))
				map = new DefaultMapperCollection<T>(this, type);
			if (map != null) {
				cache.put(type, map);
				return map;
			}
		}

		if (type.isArray())
			map = new ArraysMapper.GenericMapper<T>(this, type);
		else if (List.class.isAssignableFrom(type))
			map = new CollectionMapper.ListClass<T>(this, type);
		else if (Map.class.isAssignableFrom(type))
			map = new CollectionMapper.MapClass<T>(this, type);
		else
			// use bean class
			map = new BeansMapper.Bean<T>(this, type);
		cache.putIfAbsent(type, map);
		return map;
	}
1097394
public MappedClass addMappedClass(final Class c) {

        MappedClass mappedClass = mappedClasses.get(c.getName());
        if (mappedClass == null) {
            mappedClass = new MappedClass(c, this);
            return addMappedClass(mappedClass, true);
        }
        return mappedClass;
    }
205155
@Nonnull
  public static <IDTYPE extends Serializable> TypedObject <IDTYPE> create (@Nonnull final ITypedObject <IDTYPE> aObj)
  {
    return new TypedObject <> (aObj);
  }
198081
public final <T> SerializerJson<T> serializer(Class<T> cl)
  {
    return (SerializerJson) _serMap.get(cl);
  }
588060
private static <T> Map<Field, TypeSerializer<?>> buildNewFieldSerializersIndex(PojoSerializer<T> newPojoSerializer) {
		final Field[] newFields = newPojoSerializer.getFields();
		final TypeSerializer<?>[] newFieldSerializers = newPojoSerializer.getFieldSerializers();

		checkState(newFields.length == newFieldSerializers.length);

		int numFields = newFields.length;
		final Map<Field, TypeSerializer<?>> index = new HashMap<>(numFields);
		for (int i = 0; i < numFields; i++) {
			index.put(newFields[i], newFieldSerializers[i]);
		}

		return index;
	}
1111141
public static <T> RuntimeSchema<T> createFrom(Class<T> typeClass,
            IdStrategy strategy)
    {
        return createFrom(typeClass, NO_EXCLUSIONS, strategy);
    }
1297552
private static synchronized <D,S> IMapper<D,S> createMapper(MapperBuilder mapper) throws Throwable{
	    
		Class<Mapper<D,S>> mapperClass = mapper.exist()?mapper.<D,S>get()
				                                       :mapper.<D,S>generate();
		return mapperClass.newInstance();
	}
842400
private MapperInstance getInstance( JType mappedType, JClassType classType, boolean isSerializers ) throws UnableToCompleteException {
        int nbParam = 0;
        if ( null != mappedType.isGenericType() && (!isSerializers || !typeOracle.isEnumSupertype( mappedType )) ) {
            nbParam = mappedType.isGenericType().getTypeParameters().length;
        }

        // we first look at static method
        for ( JMethod method : classType.getMethods() ) {
            // method must be public static, return the instance type and take no parameters
            if ( method.isStatic() && null != method.getReturnType().isClassOrInterface()
                    && classType.isAssignableTo( method.getReturnType().isClassOrInterface() )
                    && method.getParameters().length == nbParam && method.isPublic() ) {
                MapperType[] parameters = getParameters( mappedType, method, isSerializers );
                if ( null == parameters ) {
                    continue;
                }

                return new MapperInstance( classType, method, parameters );
            }
        }

        // then we search the default constructor
        for ( JConstructor constructor : classType.getConstructors() ) {
            if ( constructor.isPublic() && constructor.getParameters().length == nbParam ) {
                MapperType[] parameters = getParameters( mappedType, constructor, isSerializers );
                if ( null == parameters ) {
                    continue;
                }

                return new MapperInstance( classType, constructor, parameters );
            }
        }

        logger.log( Type.ERROR, "Cannot instantiate the custom serializer/deserializer " + classType.getQualifiedSourceName() + ". "
                + "Check the page https://github.com/nmorel/gwt-jackson/wiki/Custom-serializers-and-deserializers for more details." );
        throw new UnableToCompleteException();
    }
1264320
public CacheConfigurationBuilder<K, V> withKeySerializer(Class<? extends Serializer<K>> keySerializerClass) {
    return withSerializer(new DefaultSerializerConfiguration<>(requireNonNull(keySerializerClass, "Null key serializer class"), DefaultSerializerConfiguration.Type.KEY));
  }
524598
def build(self) -> type:
        
        def _get_property_mappings(encoder: MappingJSONEncoder) -> List[JsonPropertyMapping]:
            return _get_all_property_mappings(encoder, self.mappings, self.superclasses)

        def get_serializable_cls(encoder: MappingJSONEncoder) -> type:
            return self.target_cls

        def default(encoder: MappingJSONEncoder, serializable):
            if serializable is None:
                # Fix for #18
                return None
            elif isinstance(serializable, List):
                # Fix for #8
                return [encoder.default(item) for item in serializable]
            else:
                # Sort subclasses so subclass' default method is called last
                superclasses_as_list = list(self.superclasses)
                superclasses_as_list.sort(key=lambda superclass: 1 if superclass == MappingJSONEncoder else -1)

                encoded_combined = {}
                for superclass in superclasses_as_list:
                    encoded = superclass.default(encoder, serializable)
                    encoded_combined.update(encoded)

                return encoded_combined

        return type(
            "%sDynamicMappingJSONEncoder" % self.target_cls.__name__,
            self.superclasses,
            {
                "_get_property_mappings": _get_property_mappings,
                "_get_serializable_cls": get_serializable_cls,
                "default": default
            }
        )