Abstract infrastructure for normalized nodes translation.
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / transform / base / serializer / LeafSetEntryNodeBaseSerializer.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, 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.yangtools.yang.data.impl.schema.transform.base.serializer;
9
10 import java.util.Collections;
11
12 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
13 import org.opendaylight.yangtools.yang.data.impl.schema.transform.FromNormalizedNodeSerializer;
14 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
15
16 /**
17  * Abstract(base) serializer for LeafSetEntryNodes, serializes elements of type E.
18  *
19  * @param <E> type of serialized elements
20  */
21 public abstract class LeafSetEntryNodeBaseSerializer<E> implements
22         FromNormalizedNodeSerializer<E, LeafSetEntryNode<?>, LeafListSchemaNode> {
23
24     @Override
25     public final Iterable<E> serialize(LeafListSchemaNode schema, LeafSetEntryNode<?> node) {
26         return Collections.singletonList(serializeLeaf(schema, node));
27     }
28
29     /**
30      *
31      * Serialize the inner value of a LeafSetEntryNode into element of type E.
32      *
33      * @param node to be serialized
34      * @param schema schema for leaf-list
35      * @return serialized inner value as an Element
36      */
37     protected abstract E serializeLeaf(LeafListSchemaNode schema, LeafSetEntryNode<?> node);
38 }