source: profileconnection/src/main/java/geniusweb/profileconnection/FileProfileConnector.java@ 2

Last change on this file since 2 was 2, checked in by bart, 5 years ago

Added new parties : linear, hardliner, conceder, boulware

File size: 965 bytes
Line 
1package geniusweb.profileconnection;
2
3import java.io.File;
4import java.io.IOException;
5import java.nio.charset.StandardCharsets;
6import java.nio.file.Files;
7import java.nio.file.Path;
8
9import com.fasterxml.jackson.databind.ObjectMapper;
10
11import geniusweb.profile.Profile;
12
13/**
14 * ProfileInterface based on a plain filesystem UTF8 file.
15 */
16public class FileProfileConnector implements ProfileInterface {
17 private final static ObjectMapper jackson = new ObjectMapper();
18 private final Profile profile;
19
20 /**
21 *
22 * @param filename the filename of the file containing the profile
23 * @throws IOException if the profile is not proper json
24 */
25 public FileProfileConnector(String filename) throws IOException {
26 Path path = new File(filename).toPath();
27 String serialized = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
28 profile = jackson.readValue(serialized, Profile.class);
29 }
30
31 @Override
32 public Profile getProfile() {
33 return profile;
34 }
35
36}
Note: See TracBrowser for help on using the repository browser.