// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java
// @Data
// @AllArgsConstructor
// public class Bar {
// 
// 	private UUID id;
// 	private String name;
// 
// 	private Foo foo;
// 
// }
// 
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java
// public static String toFriendlyId(UUID uuid) {
// 	return Url62.encode(uuid);
// }


import com.devskiller.friendly_id.sample.hateos.domain.Bar;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory;
import static com.devskiller.friendly_id.FriendlyId.toFriendlyId;
package com.devskiller.friendly_id.sample.hateos;



public class BarResourceAssembler extends RepresentationModelAssemblerSupport<Bar, BarResource> {

	public BarResourceAssembler() {
		super(BarController.class, BarResource.class);
	}

	@Override
	public BarResource toModel(Bar entity) {
		BarResource resource = new BarResource(entity.getName());
		WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory();
		resource.add(factory.linkTo(FooController.class).withRel("foos"));
// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/domain/Bar.java
// @Data
// @AllArgsConstructor
// public class Bar {
// 
// 	private UUID id;
// 	private String name;
// 
// 	private Foo foo;
// 
// }
// 
// Path: friendly-id/src/main/java/com/devskiller/friendly_id/FriendlyId.java
// public static String toFriendlyId(UUID uuid) {
// 	return Url62.encode(uuid);
// }


// Path: friendly-id-samples/friendly-id-spring-boot-hateos/src/main/java/com/devskiller/friendly_id/sample/hateos/BarResourceAssembler.java
import com.devskiller.friendly_id.sample.hateos.domain.Bar;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory;
import static com.devskiller.friendly_id.FriendlyId.toFriendlyId;

package com.devskiller.friendly_id.sample.hateos;



public class BarResourceAssembler extends RepresentationModelAssemblerSupport<Bar, BarResource> {

	public BarResourceAssembler() {
		super(BarController.class, BarResource.class);
	}

	@Override
	public BarResource toModel(Bar entity) {
		BarResource resource = new BarResource(entity.getName());
		WebMvcLinkBuilderFactory factory = new WebMvcLinkBuilderFactory();
		resource.add(factory.linkTo(FooController.class).withRel("foos"));
		resource.add(factory.linkTo(BarController.class, toFriendlyId(entity.getFoo().getId())).slash(toFriendlyId(entity.getId())).withSelfRel());