/* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.yangtools.yang.binding; import static java.util.Objects.requireNonNull; import java.util.Map; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; /** * Augmentable (extensible) object which could carry additional data defined by a third-party extension, without * introducing conflict between various extension. * *

* This interface uses extended version of ExtensibleInterface pattern which also adds marker interface for * augmentations (extensions) - {@link Augmentable}. * * @param Base class which should implements this interface and is target for augmentation. * @author Tony Tkacik */ public interface Augmentable { /** * Returns instance of augmentation. * * @param augmentationType Type of augmentation to be returned. * @param Type capture for augmentation type * @return instance of augmentation, or null if the augmentationType is not present. * @throws NullPointerException if augmentationType is null */ @SuppressWarnings("unchecked") default > @Nullable A augmentation(final Class augmentationType) { return (A) augmentations().get(requireNonNull(augmentationType)); } /** * Returns map of all augmentations. * * @return map of all augmentations. */ @NonNull Map>, Augmentation> augmentations(); }