ffcd416d4096057c18c05193065ed96eade323ea
[lispflowmapping.git] / mappingservice / implementation / src / main / java / org / opendaylight / lispflowmapping / implementation / serializer / address / LispNoAddressSerializer.java
1 /*
2  * Copyright (c) 2014 Contextream, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.lispflowmapping.implementation.serializer.address;
9
10 import java.nio.ByteBuffer;
11
12 import org.opendaylight.lispflowmapping.type.AddressFamilyNumberEnum;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.LispAFIAddress;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.LispNoAddress;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.lispaddress.lispaddresscontainer.address.no.NoAddressBuilder;
16
17 public class LispNoAddressSerializer extends LispAddressSerializer {
18
19     private static final LispNoAddressSerializer INSTANCE = new LispNoAddressSerializer();
20
21     // Private constructor prevents instantiation from other classes
22     private LispNoAddressSerializer() {
23     }
24
25     public static LispNoAddressSerializer getInstance() {
26         return INSTANCE;
27     }
28
29     @Override
30     public int getAddressSize(LispAFIAddress lispAddress) {
31         return Length.NO;
32     }
33
34     @Override
35     protected void serializeData(ByteBuffer buffer, LispAFIAddress lispAddress) {
36     }
37
38     @Override
39     protected LispNoAddress deserializeData(ByteBuffer buffer) {
40         return new NoAddressBuilder().setAfi(AddressFamilyNumberEnum.NO_ADDRESS.getIanaCode()).build();
41     }
42
43     private interface Length {
44         int NO = 0;
45     }
46
47 }