2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.binding;
10 import static java.util.Objects.requireNonNull;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
17 * Augmentable (extensible) object which could carry additional data defined by a third-party extension, without
18 * introducing conflict between various extension.
21 * This interface uses extended version of ExtensibleInterface pattern which also adds marker interface for
22 * augmentations (extensions) - {@link Augmentable}.
24 * @param <T> Base class which should implements this interface and is target for augmentation.
27 public interface Augmentable<T> {
29 * Returns instance of augmentation.
31 * @param augmentationType Type of augmentation to be returned.
32 * @param <A> Type capture for augmentation type
33 * @return instance of augmentation, or null if the augmentationType is not present.
34 * @throws NullPointerException if augmentationType is null
36 @SuppressWarnings("unchecked")
37 default <A extends Augmentation<T>> @Nullable A augmentation(final Class<A> augmentationType) {
38 return (A) augmentations().get(requireNonNull(augmentationType));
42 * Returns map of all augmentations.
44 * @return map of all augmentations.
46 @NonNull Map<Class<? extends Augmentation<T>>, Augmentation<T>> augmentations();