aboutsummaryrefslogtreecommitdiff
path: root/src/net/pacien/util/CleanJSONObject.java
blob: 0982ca89df32c98b9308bc2a5fab6d61352fc239 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package net.pacien.util;

import java.util.Collection;
import java.util.Map;

import org.json.simple.JSONObject;

public class CleanJSONObject extends JSONObject {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6700060746446264070L;

	public CleanJSONObject() {
		super();
	}

	@Override
	public Object put(final String key, final Object value) {
		if (value == null) {
			return null;
		}
		return super.put(key, value);
	}

	public Object put(final String key, final Map<?, ?> map) {
		if (map.isEmpty()) {
			return null;
		}
		return super.put(key, map);
	}

	public Object put(final String key, final Collection<?> collection) {
		if (collection.isEmpty()) {
			return null;
		}
		return super.put(key, collection);
	}

	public Object put(final String key, final Object[] array) {
		if (array.length == 0) {
			return null;
		}
		return super.put(key, array);
	}

}