blob: 1d146a55b3fb1a618e4a1e58af3945d5adecfb83 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.store.serializers;
Yuta HIGUCHI8ee7d4c2014-10-09 23:09:41 -070017
Yuta HIGUCHI8ee7d4c2014-10-09 23:09:41 -070018import com.esotericsoftware.kryo.Kryo;
19import com.esotericsoftware.kryo.Serializer;
20import com.esotericsoftware.kryo.io.Input;
21import com.esotericsoftware.kryo.io.Output;
22
Jonathan Hartd9df7bd2015-11-10 17:10:25 -080023import java.net.URI;
24
Yuta HIGUCHI8ee7d4c2014-10-09 23:09:41 -070025/**
26 * Serializer for {@link URI}.
27 */
Jonathan Hartd9df7bd2015-11-10 17:10:25 -080028public class UriSerializer extends Serializer<URI> {
Yuta HIGUCHI8ee7d4c2014-10-09 23:09:41 -070029
30 /**
31 * Creates {@link URI} serializer instance.
32 */
Jonathan Hartd9df7bd2015-11-10 17:10:25 -080033 public UriSerializer() {
Yuta HIGUCHI8ee7d4c2014-10-09 23:09:41 -070034 super(false);
35 }
36
37 @Override
38 public void write(Kryo kryo, Output output, URI object) {
39 output.writeString(object.toString());
40 }
41
42 @Override
43 public URI read(Kryo kryo, Input input, Class<URI> type) {
44 return URI.create(input.readString());
45 }
46}