// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java
// public class FriendlyId {
// 
// 	/**
// 	 * Create FriendlyId id
// 	 *
// 	 * @return Friendly Id encoded UUID
// 	 */
// 	public static String createFriendlyId() {
// 		return Url62.encode(UUID.randomUUID());
// 	}
// 
// 	/**
// 	 * Encode UUID to FriendlyId id
// 	 *
// 	 * @param uuid UUID to be encoded
// 	 * @return Friendly Id encoded UUID
// 	 */
// 	public static String toFriendlyId(UUID uuid) {
// 		return Url62.encode(uuid);
// 	}
// 
// 	/**
// 	 * Decode Friendly Id to UUID
// 	 *
// 	 * @param friendlyId encoded UUID
// 	 * @return decoded UUID
// 	 */
// 	public static UUID toUuid(String friendlyId) {
// 		return Url62.decode(friendlyId);
// 	}
// 
// }
// 
// Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdModule.java
// public class FriendlyIdModule extends SimpleModule {
// 
// 	private FriendlyIdAnnotationIntrospector introspector;
// 
// 	public FriendlyIdModule() {
// 		introspector = new FriendlyIdAnnotationIntrospector();
// 		addDeserializer(UUID.class, new FriendlyIdDeserializer());
// 		addSerializer(UUID.class, new FriendlyIdSerializer());
// 	}
// 
// 	@Override
// 	public void setupModule(SetupContext context) {
// 		context.insertAnnotationIntrospector(introspector);
// 	}
// }


import java.util.UUID;
import com.fasterxml.jackson.databind.Module;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.devskiller.friendly_id.FriendlyId;
import com.devskiller.friendly_id.jackson.FriendlyIdModule;
package com.devskiller.friendly_id.spring;





@Configuration
public class FriendlyIdConfiguration implements WebMvcConfigurer {

	@Override
	public void addFormatters(FormatterRegistry registry) {
		registry.addConverter(new StringToUuidConverter());
		registry.addConverter(new UuidToStringConverter());
	}

	@Bean
	public Module friendlyIdModule() {
		return new FriendlyIdModule();
	}

	//FIXME: make this public
	public static class StringToUuidConverter implements Converter<String, UUID> {

		@Override
		public UUID convert(String id) {
			return FriendlyId.toUuid(id);
		}
	}


	public static class UuidToStringConverter implements Converter<UUID, String> {

		@Override
		public String convert(UUID id) {
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java
// public class FriendlyId {
// 
// 	/**
// 	 * Create FriendlyId id
// 	 *
// 	 * @return Friendly Id encoded UUID
// 	 */
// 	public static String createFriendlyId() {
// 		return Url62.encode(UUID.randomUUID());
// 	}
// 
// 	/**
// 	 * Encode UUID to FriendlyId id
// 	 *
// 	 * @param uuid UUID to be encoded
// 	 * @return Friendly Id encoded UUID
// 	 */
// 	public static String toFriendlyId(UUID uuid) {
// 		return Url62.encode(uuid);
// 	}
// 
// 	/**
// 	 * Decode Friendly Id to UUID
// 	 *
// 	 * @param friendlyId encoded UUID
// 	 * @return decoded UUID
// 	 */
// 	public static UUID toUuid(String friendlyId) {
// 		return Url62.decode(friendlyId);
// 	}
// 
// }
// 
// Path: friendly-id-jackson-datatype/src/main/java/com/devskiller/friendly_id/jackson/FriendlyIdModule.java
// public class FriendlyIdModule extends SimpleModule {
// 
// 	private FriendlyIdAnnotationIntrospector introspector;
// 
// 	public FriendlyIdModule() {
// 		introspector = new FriendlyIdAnnotationIntrospector();
// 		addDeserializer(UUID.class, new FriendlyIdDeserializer());
// 		addSerializer(UUID.class, new FriendlyIdSerializer());
// 	}
// 
// 	@Override
// 	public void setupModule(SetupContext context) {
// 		context.insertAnnotationIntrospector(introspector);
// 	}
// }


// Path: friendly-id-spring-boot/src/main/java/com/devskiller/friendly_id/spring/FriendlyIdConfiguration.java
import java.util.UUID;
import com.fasterxml.jackson.databind.Module;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.devskiller.friendly_id.FriendlyId;
import com.devskiller.friendly_id.jackson.FriendlyIdModule;

package com.devskiller.friendly_id.spring;





@Configuration
public class FriendlyIdConfiguration implements WebMvcConfigurer {

	@Override
	public void addFormatters(FormatterRegistry registry) {
		registry.addConverter(new StringToUuidConverter());
		registry.addConverter(new UuidToStringConverter());
	}

	@Bean
	public Module friendlyIdModule() {
		return new FriendlyIdModule();
	}

	//FIXME: make this public
	public static class StringToUuidConverter implements Converter<String, UUID> {

		@Override
		public UUID convert(String id) {
			return FriendlyId.toUuid(id);
		}
	}


	public static class UuidToStringConverter implements Converter<UUID, String> {

		@Override
		public String convert(UUID id) {
			return FriendlyId.toFriendlyId(id);