// Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java
// public class JsonArrayBuilder {
//     private ArrayList<Object> jsonList = new ArrayList<>();
// 
//     JsonArrayBuilder() {
//     }
// 
//     public JsonArrayBuilder add(Object item) {
//         jsonList.add(item);
//         return this;
//     }
// 
//     public JsonArrayBuilder addAll(Collection items) {
//         jsonList.addAll(items);
//         return this;
//     }
// 
//     public JSONArray build() {
//         JSONArray array = new JSONArray();
//         array.addAll(jsonList);
//         return array;
//     }
// }
// 
// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java
// public class JsonBuilderFactory {
//     public static JsonObjectBuilder object() {
//         return new JsonObjectBuilder();
//     }
// 
//     public static JsonArrayBuilder array() {
//         return new JsonArrayBuilder();
//     }
// }


import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.persistence.*;
import javax.validation.constraints.Size;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.web.bind.annotation.ResponseBody;
import com.aemreunal.helper.json.JsonArrayBuilder;
import com.aemreunal.helper.json.JsonBuilderFactory;
import com.fasterxml.jackson.annotation.JsonIgnore;
    public Beacon() {
        // Empty constructor for Spring & Hibernate
    }
    /*
     * END: Constructors
     *------------------------------------------------------------
     */

    /*
     *------------------------------------------------------------
     * BEGIN: Helpers
     */
    public void addConnection(Connection connection) {
        this.getConnections().add(connection);
    }

    public void removeConnection(Connection connection) {
        this.getConnections().remove(connection);
    }

    @JsonSerialize
    public boolean hasLocationInfo() {
        return getLocationInfoTextFileName() != null;
    }

    // Weird stuff: when this method is named something like 'getConnectionsJson',
    // 'getConnectionsList', 'getConnectionsAsList', Jackson tries to use it and
    // causes a LazyInit exception.
    @JsonIgnore
    public JSONArray getConnsAsJson() {
// Path: src/main/java/com/aemreunal/helper/json/JsonArrayBuilder.java
// public class JsonArrayBuilder {
//     private ArrayList<Object> jsonList = new ArrayList<>();
// 
//     JsonArrayBuilder() {
//     }
// 
//     public JsonArrayBuilder add(Object item) {
//         jsonList.add(item);
//         return this;
//     }
// 
//     public JsonArrayBuilder addAll(Collection items) {
//         jsonList.addAll(items);
//         return this;
//     }
// 
//     public JSONArray build() {
//         JSONArray array = new JSONArray();
//         array.addAll(jsonList);
//         return array;
//     }
// }
// 
// Path: src/main/java/com/aemreunal/helper/json/JsonBuilderFactory.java
// public class JsonBuilderFactory {
//     public static JsonObjectBuilder object() {
//         return new JsonObjectBuilder();
//     }
// 
//     public static JsonArrayBuilder array() {
//         return new JsonArrayBuilder();
//     }
// }


// Path: src/main/java/com/aemreunal/domain/Beacon.java
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.persistence.*;
import javax.validation.constraints.Size;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.web.bind.annotation.ResponseBody;
import com.aemreunal.helper.json.JsonArrayBuilder;
import com.aemreunal.helper.json.JsonBuilderFactory;
import com.fasterxml.jackson.annotation.JsonIgnore;

    public Beacon() {
        // Empty constructor for Spring & Hibernate
    }
    /*
     * END: Constructors
     *------------------------------------------------------------
     */

    /*
     *------------------------------------------------------------
     * BEGIN: Helpers
     */
    public void addConnection(Connection connection) {
        this.getConnections().add(connection);
    }

    public void removeConnection(Connection connection) {
        this.getConnections().remove(connection);
    }

    @JsonSerialize
    public boolean hasLocationInfo() {
        return getLocationInfoTextFileName() != null;
    }

    // Weird stuff: when this method is named something like 'getConnectionsJson',
    // 'getConnectionsList', 'getConnectionsAsList', Jackson tries to use it and
    // causes a LazyInit exception.
    @JsonIgnore
    public JSONArray getConnsAsJson() {
        JsonArrayBuilder connArray = JsonBuilderFactory.array();