Stop installing librairies during tests
[parser.git] / verigraph / src / main / java / it / polito / escape / verify / serializer / CustomMapSerializer.java
1 /*******************************************************************************
2  * Copyright (c) 2017 Politecnico di Torino and others.
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Apache License, Version 2.0
6  * which accompanies this distribution, and is available at
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *******************************************************************************/
9
10 package it.polito.escape.verify.serializer;
11
12 import java.io.IOException;
13 import java.util.Map;
14
15 import com.fasterxml.jackson.core.JsonGenerator;
16 import com.fasterxml.jackson.databind.JsonSerializer;
17 import com.fasterxml.jackson.databind.SerializerProvider;
18
19 import it.polito.escape.verify.exception.InternalServerErrorException;
20
21 public class CustomMapSerializer extends JsonSerializer<Map<?, ?>> {
22         @Override
23         public void serialize(final Map<?, ?> value, final JsonGenerator jgen, final SerializerProvider provider) {
24                 try {
25                         jgen.writeObject(value.values());
26                 } catch (IOException e) {
27                         throw new InternalServerErrorException("I/O error serializing a map: " + e.getMessage());
28                 }
29         }
30 }