Flatten IllegalArgumentCodec class hierarchy
[yangtools.git] / common / concepts / src / main / java / org / opendaylight / yangtools / concepts / IllegalArgumentCodec.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.concepts;
9
10 import com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.NonNull;
12
13 /**
14  * Utility interface for translation between a external form and an internal form. Implementations should consider
15  * subclassing {@link AbstractIllegalArgumentCodec}.
16  *
17  * @param <S> Serialized (external) type
18  * @param <D> Deserialized (internal) type
19  */
20 @Beta
21 public interface IllegalArgumentCodec<S, D> {
22     /**
23      * Produce an internal object based on an external object.
24      *
25      * @param input Input object
26      * @return Product derived from input
27      * @throws NullPointerException if input is null
28      * @throws IllegalArgumentException when input is not valid
29      */
30     @NonNull D deserialize(@NonNull S input);
31
32     /**
33      * Produce an external object based on an internal object.
34      *
35      * @param input Input
36      * @return An external form object
37      * @throws NullPointerException if input is null
38      * @throws IllegalArgumentException when input is not valid
39      */
40     @NonNull S serialize(@NonNull D input);
41 }