summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/dnbd3/status/output/EdgeSerializer.java
blob: e014bb39e12b7c8ffd86a4d8ae02b2d346e40d56 (plain) (blame)
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
package org.openslx.dnbd3.status.output;

import java.lang.reflect.Type;

import org.openslx.graph.Edge;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

public class EdgeSerializer implements JsonSerializer<Edge>
{

	@Override
	public JsonElement serialize( Edge src, Type typeOfSrc, JsonSerializationContext context )
	{
		final JsonObject out = new JsonObject();
		out.addProperty( "source", src.getSource().getId() );
		out.addProperty( "target", src.getTarget().getId() );
		out.addProperty( "width", src.getWeight() );
		return out;
	}

}