Seal ItemOrder and MutationBehaviour
[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  * @deprecated This interface ignores a number of complications when dealing with external forms. For one, it assumes
20  *             a serdes operation does not have further context than the input -- and this is seldom the case. The other
21  *             failing is that it actively discourages use of checked exceptions to deal with errors at the appropriate
22  *             level. Based on these, this interface is deprecated for removal without a replacement. Users are
23  *             encouraged to define similar interface fitting their needs.
24  */
25 @Beta
26 @Deprecated(since = "8.0.0", forRemoval = true)
27 public interface IllegalArgumentCodec<S, D> {
28     /**
29      * Produce an internal object based on an external object.
30      *
31      * @param input Input object
32      * @return Product derived from input
33      * @throws NullPointerException if input is null
34      * @throws IllegalArgumentException when input is not valid
35      */
36     @NonNull D deserialize(@NonNull S input);
37
38     /**
39      * Produce an external object based on an internal object.
40      *
41      * @param input Input
42      * @return An external form object
43      * @throws NullPointerException if input is null
44      * @throws IllegalArgumentException when input is not valid
45      */
46     @NonNull S serialize(@NonNull D input);
47 }