// Path: src/main/java/de/fesere/hypermedia/cj/exceptions/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
//     public ElementNotFoundException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/de/fesere/hypermedia/cj/model/builder/DataEntryFactory.java
// public final class DataEntryFactory {
// 
//     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");
//         }
//     }
// 
//     public static DataEntry create(String name, Object value) {
//         return create(name, value, null);
//     }
// 
//     private static DataEntry createNone() {
//         return new NoneDataEntry("none");
//     }
// 
//     public static DataEntry createNull(String name, String prompt) {
//         return new NullDataEntry(name,prompt);
//     }
// 
//     public static DataEntry createNull(String name) {
//         return createNull(name, null);
//     }
// 
//     public static DataEntry createEmpty(String name, String prompt) {
//         return new StringDataEntry(name, "", prompt);
//     }
// 
//     public static DataEntry createEmpty(String name) {
//         return new StringDataEntry(name);
//     }
// }


import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import de.fesere.hypermedia.cj.exceptions.ElementNotFoundException;
import de.fesere.hypermedia.cj.model.builder.DataEntryFactory;
import org.apache.commons.lang3.StringUtils;
import java.net.URI;
import java.util.LinkedList;
import java.util.List;
        super(rel, href, prompt);
        this.data = new LinkedList<>(data);
    }

    public Query(String rel, String prompt,  List<DataEntry> data) {
       this(null, rel, prompt, data);
    }

    public List<DataEntry> getData() {
        return data;
    }


    public Query set(String name, Object o) {
        DataEntry found = findDataEntry(name);

        DataEntry replacement = DataEntryFactory.create(name, o, found.getPrompt());


        data.remove(found);
        data.add(replacement);
        return this;
    }

    private DataEntry findDataEntry(String name) {
        for (DataEntry dataEntry : data) {
            if (dataEntry.getName().equals(name)) {
                return dataEntry;
            }
        }
// Path: src/main/java/de/fesere/hypermedia/cj/exceptions/ElementNotFoundException.java
// public class ElementNotFoundException extends RuntimeException {
//     public ElementNotFoundException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/de/fesere/hypermedia/cj/model/builder/DataEntryFactory.java
// public final class DataEntryFactory {
// 
//     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");
//         }
//     }
// 
//     public static DataEntry create(String name, Object value) {
//         return create(name, value, null);
//     }
// 
//     private static DataEntry createNone() {
//         return new NoneDataEntry("none");
//     }
// 
//     public static DataEntry createNull(String name, String prompt) {
//         return new NullDataEntry(name,prompt);
//     }
// 
//     public static DataEntry createNull(String name) {
//         return createNull(name, null);
//     }
// 
//     public static DataEntry createEmpty(String name, String prompt) {
//         return new StringDataEntry(name, "", prompt);
//     }
// 
//     public static DataEntry createEmpty(String name) {
//         return new StringDataEntry(name);
//     }
// }


// Path: src/main/java/de/fesere/hypermedia/cj/model/Query.java
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import de.fesere.hypermedia.cj.exceptions.ElementNotFoundException;
import de.fesere.hypermedia.cj.model.builder.DataEntryFactory;
import org.apache.commons.lang3.StringUtils;
import java.net.URI;
import java.util.LinkedList;
import java.util.List;

        super(rel, href, prompt);
        this.data = new LinkedList<>(data);
    }

    public Query(String rel, String prompt,  List<DataEntry> data) {
       this(null, rel, prompt, data);
    }

    public List<DataEntry> getData() {
        return data;
    }


    public Query set(String name, Object o) {
        DataEntry found = findDataEntry(name);

        DataEntry replacement = DataEntryFactory.create(name, o, found.getPrompt());


        data.remove(found);
        data.add(replacement);
        return this;
    }

    private DataEntry findDataEntry(String name) {
        for (DataEntry dataEntry : data) {
            if (dataEntry.getName().equals(name)) {
                return dataEntry;
            }
        }
        throw new ElementNotFoundException("Did not find element '"+name+"' in query '"+getRel()+"'");