// Path: src/main/java/de/fesere/hypermedia/cj/transformer/WriteTransformer.java
// public interface WriteTransformer<T> {
// 
//     Item transform(T input);
// }
// 
// Path: src/main/java/de/fesere/hypermedia/cj/model/builder/DataEntryFactory.java
// public static DataEntry create(String name, Object value, String prompt) {
// 
//     if(StringUtils.isBlank(name)){
//         return createNone();
//     }
// 
//     if(value == null) {
//        throw new MalformedDataValueException("value of '"+name+"' can not be null");
//     }
// 
//     Class type = value.getClass();
// 
//     if (TypeUtils.isString(type)) {
//         return new StringDataEntry(name, (String) value, prompt);
//     } else if (TypeUtils.isNumber(type)) {
//         return new NumberDataEntry(name, (Number) value, prompt);
//     } else if (TypeUtils.isBoolean(type)) {
//         return new BooleanDataEntry(name, (Boolean) value, prompt);
//     } else {
//        throw new SerializationException("'"+name+"' of type " + type + " can not be converted to DataEntry");
//     }
// }


import de.fesere.hypermedia.cj.model.*;
import de.fesere.hypermedia.cj.transformer.WriteTransformer;
import org.junit.Test;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import static de.fesere.hypermedia.cj.model.builder.DataEntryFactory.create;
        Person person = new Person("jdoe", "J. Doe", "jdoe@example.org");
        Collection collection = new CollectionBuilder<>(href, transformer).addObject(person).build();

        assertCollectionSerialization(expected, collection);
    }

    @Test
    public void test_addSingleItemWithLinks() {
        String expected = readFile("/examples/builder/single-item-with-links.json");

        PersonTransformerWithLinks transformer = new PersonTransformerWithLinks(URI.create("http://example.org"));
        Person person = new Person("jdoe", "J. Doe", "jdoe@example.org");
        Collection collection = new CollectionBuilder<>(href, transformer).addObject(person).build();

        assertCollectionSerialization(expected, collection);
    }


    private class Person {
        private String id;
        private final String fullName;
        private final String email;

        public Person(String id, String fullName, String email) {
            this.id = id;
            this.fullName = fullName;
            this.email = email;
        }
    }

// Path: src/main/java/de/fesere/hypermedia/cj/transformer/WriteTransformer.java
// public interface WriteTransformer<T> {
// 
//     Item transform(T input);
// }
// 
// Path: src/main/java/de/fesere/hypermedia/cj/model/builder/DataEntryFactory.java
// public static DataEntry create(String name, Object value, String prompt) {
// 
//     if(StringUtils.isBlank(name)){
//         return createNone();
//     }
// 
//     if(value == null) {
//        throw new MalformedDataValueException("value of '"+name+"' can not be null");
//     }
// 
//     Class type = value.getClass();
// 
//     if (TypeUtils.isString(type)) {
//         return new StringDataEntry(name, (String) value, prompt);
//     } else if (TypeUtils.isNumber(type)) {
//         return new NumberDataEntry(name, (Number) value, prompt);
//     } else if (TypeUtils.isBoolean(type)) {
//         return new BooleanDataEntry(name, (Boolean) value, prompt);
//     } else {
//        throw new SerializationException("'"+name+"' of type " + type + " can not be converted to DataEntry");
//     }
// }


// Path: src/test/java/de/fesere/hypermedia/cj/model/builder/CollectionBuilderTest.java
import de.fesere.hypermedia.cj.model.*;
import de.fesere.hypermedia.cj.transformer.WriteTransformer;
import org.junit.Test;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import static de.fesere.hypermedia.cj.model.builder.DataEntryFactory.create;

        Person person = new Person("jdoe", "J. Doe", "jdoe@example.org");
        Collection collection = new CollectionBuilder<>(href, transformer).addObject(person).build();

        assertCollectionSerialization(expected, collection);
    }

    @Test
    public void test_addSingleItemWithLinks() {
        String expected = readFile("/examples/builder/single-item-with-links.json");

        PersonTransformerWithLinks transformer = new PersonTransformerWithLinks(URI.create("http://example.org"));
        Person person = new Person("jdoe", "J. Doe", "jdoe@example.org");
        Collection collection = new CollectionBuilder<>(href, transformer).addObject(person).build();

        assertCollectionSerialization(expected, collection);
    }


    private class Person {
        private String id;
        private final String fullName;
        private final String email;

        public Person(String id, String fullName, String email) {
            this.id = id;
            this.fullName = fullName;
            this.email = email;
        }
    }

    private class PersonTransformerWithLinks implements WriteTransformer<Person> {