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

com.microsoft.azure.management.network.model.GroupableParentResourceWithTagsImpl Maven / Gradle / Ivy

There is a newer version: 1.41.4
Show newest version
/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 */
package com.microsoft.azure.management.network.model;

import com.microsoft.azure.management.resources.fluentcore.arm.implementation.ManagerBase;
import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource;
import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource;
import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableParentResourceImpl;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceFuture;
import rx.Observable;
import rx.functions.Func1;

/**
 * The implementation for {@link GroupableResource} that can update tags as a separate operation.
 *
 * @param  The fluent model type
 * @param  Azure inner resource class type
 * @param  the implementation type of the fluent model type
 * @param  the service manager type
 */
public abstract class GroupableParentResourceWithTagsImpl<
        FluentModelT extends Resource,
        InnerModelT extends com.microsoft.azure.Resource,
        FluentModelImplT extends GroupableParentResourceWithTagsImpl,
        ManagerT extends ManagerBase>
        extends
            GroupableParentResourceImpl
        implements
            UpdatableWithTags,
            AppliableWithTags {
    protected GroupableParentResourceWithTagsImpl(String name, InnerModelT innerObject, ManagerT manager) {
        super(name, innerObject, manager);
    }

    @Override
    @SuppressWarnings("unchecked")
    public FluentModelImplT updateTags() {
        return (FluentModelImplT) this;
    }

    @Override
    public FluentModelT applyTags() {
        return applyTagsAsync().toBlocking().last();
    }

    protected abstract Observable applyTagsToInnerAsync();

    @Override
    public Observable applyTagsAsync() {
        @SuppressWarnings("unchecked")
        final FluentModelT self = (FluentModelT) this;
        return applyTagsToInnerAsync()
                .flatMap(new Func1>() {
                    @Override
                    public Observable call(InnerModelT inner) {
                        setInner(inner);
                        return Observable.just(self);                    }
                });
    }

    @Override
    public ServiceFuture applyTagsAsync(ServiceCallback callback) {
        return ServiceFuture.fromBody(applyTagsAsync(), callback);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy