aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/equalparts/cardbase/utils/IO.java
blob: 5d4bef5f4bac7f9a369fbf942fbf4011e0d5af8a (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
package eu.equalparts.cardbase.utils;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * This class simply holds an {@code ObjectMapper} to be used whenever JSON must be parsed.
 * In the future it may be removed in favour of individual mappers for each function.
 * 
 * @author Eduardo Pedroni
 */
public final class IO {
	
	/**
	 * The Jackson {@code ObjectMapper} which parses fetched JSON files.
	 */
	public static final ObjectMapper jsonMapper = createMapper();

	/**
	 * Private constructor, this class is not to be instantiated.
	 */
	private IO() {}
	
	/**
	 * Instantiate and configure Jackson mapper statically. 
	 * 
	 * @return the {@code ObjectMapper}, ready to use.
	 */
	private static ObjectMapper createMapper() {
		ObjectMapper objectMapper = new ObjectMapper();
		// TODO decide what to do about this
		objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
		return objectMapper;
	}
}