Correct docs declaration
[mdsal.git] / binding2 / mdsal-binding2-spec / src / main / java / org / opendaylight / mdsal / binding / javav2 / spec / structural / Augmentable.java
1 /*
2  * Copyright (c) 2017 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
9 package org.opendaylight.mdsal.binding.javav2.spec.structural;
10
11 import com.google.common.annotations.Beta;
12 import com.google.common.collect.ClassToInstanceMap;
13
14 /**
15  * Augmentable (extensible) object which could carry additional data defined by third-party
16  * extension, without introducing conflict between various extension.
17  *
18  * This interface uses extended version of ExtensibleInterface pattern which also adds marker
19  * interface for augmentations (extensions) - {@link Augmentable}
20  *
21  * @author Tony Tkacik
22  * @param <T> Base class which should implements this interface and is target for augmentation.
23  */
24 @Beta
25 public interface Augmentable<T> {
26
27     /**
28      * Returns instance of augmentation based on class
29      *
30      * @param augment Type of augmentation to be returned.
31      * @return instance of augmentation.
32      */
33     default <E extends Augmentation<? super T>> E getAugmentation(Class<E> augment) {
34         return augments().getInstance(augment);
35     }
36
37     /**
38      *
39      * Returns map of all instantiated augmentations.
40      *
41      * @return Class to Instance Map
42      */
43     // REPLACES: BindingReflections#getAugmentations()
44     ClassToInstanceMap<Augmentation<? super T>> augments();
45 }