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

org.opendaylight.yangtools.binding.impl.DataObjectIdentifierBuilder 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 org.opendaylight.yangtools.binding.DataObject;
import org.opendaylight.yangtools.binding.DataObjectIdentifier;
import org.opendaylight.yangtools.binding.DataObjectStep;
import org.opendaylight.yangtools.binding.EntryObject;
import org.opendaylight.yangtools.binding.ExactDataObjectStep;
import org.opendaylight.yangtools.binding.Key;
import org.opendaylight.yangtools.binding.KeyStep;

public final class DataObjectIdentifierBuilder extends AbstractDataObjectIdentifierBuilder {
    DataObjectIdentifierBuilder(final AbstractDataObjectIdentifierBuilder prev) {
        super(prev);
    }

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

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

    public DataObjectIdentifierBuilder(final DataObjectStep item) {
        this(validate(item));
    }

    @Override
    public DataObjectIdentifier build() {
        return new DataObjectIdentifierImpl<>(null, buildSteps());
    }

    @Override
    @SuppressWarnings("unchecked")
    protected  DataObjectIdentifierBuilder append(final DataObjectStep step) {
        appendItem(step);
        return (DataObjectIdentifierBuilder) this;
    }

    @Override
    protected , Y extends Key> DataObjectIdentifierBuilderWithKey append(
            final KeyStep step) {
        return new DataObjectIdentifierBuilderWithKey(this).append(step);
    }

    private static  ExactDataObjectStep validate(final DataObjectStep step) {
        if (step instanceof ExactDataObjectStep exact) {
            return exact;
        }
        throw new IllegalArgumentException("Cannot use with " + step);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy