All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.yangtools.binding.impl.AbstractDataObjectIdentifierBuilder Maven / Gradle / Ivy

/*
 * Copyright (c) 2024 PANTHEON.tech, s.r.o. 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.binding.impl;

import static java.util.Objects.requireNonNull;

import org.opendaylight.yangtools.binding.Augmentation;
import org.opendaylight.yangtools.binding.ChildOf;
import org.opendaylight.yangtools.binding.ChoiceIn;
import org.opendaylight.yangtools.binding.DataObject;
import org.opendaylight.yangtools.binding.DataObjectIdentifier;
import org.opendaylight.yangtools.binding.DataObjectIdentifier.Builder;
import org.opendaylight.yangtools.binding.DataObjectStep;
import org.opendaylight.yangtools.binding.EntryObject;
import org.opendaylight.yangtools.binding.ExactDataObjectStep;
import org.opendaylight.yangtools.binding.InexactDataObjectStep;
import org.opendaylight.yangtools.binding.Key;
import org.opendaylight.yangtools.binding.KeyStep;
import org.opendaylight.yangtools.binding.NodeStep;

public abstract sealed class AbstractDataObjectIdentifierBuilder
        extends AbstractDataObjectReferenceBuilder
        implements DataObjectIdentifier.Builder
        permits DataObjectIdentifierBuilder, DataObjectIdentifierBuilderWithKey {
    AbstractDataObjectIdentifierBuilder(final AbstractDataObjectIdentifierBuilder prev) {
        super(prev);
    }

    AbstractDataObjectIdentifierBuilder(final DataObjectIdentifier base) {
        super(base);
    }

    AbstractDataObjectIdentifierBuilder(final ExactDataObjectStep item) {
        super(item);
    }

    @Override
    public > Builder augmentation(final Class augmentation) {
        return append(new NodeStep<>(augmentation));
    }

    @Override
    public > Builder child(final Class container) {
        return append(DataObjectStep.of(container));
    }

    @Override
    public  & DataObject, N extends ChildOf> Builder child(
            final Class caze, final Class container) {
        return append(DataObjectStep.of(caze, container));
    }

    @Override
    public  & ChildOf, K extends Key> Builder.WithKey child(
            final Class listItem, final K listKey) {
        return append(new KeyStep<>(listItem, listKey));
    }

    @Override
    public  & DataObject, K extends Key,
            N extends EntryObject & ChildOf>
            Builder.WithKey child(final Class caze, final Class listItem, final K listKey) {
        return append(new KeyStep<>(listItem, requireNonNull(caze), listKey));
    }

    @Override
    protected final void appendItem(final InexactDataObjectStep item) {
        throw new IllegalArgumentException("Cannot make inexact step " + item);
    }

    @Override
    protected abstract  Builder append(DataObjectStep step);

    @Override
    protected abstract , Y extends Key> Builder.WithKey append(KeyStep step);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy