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

com.pubnub.internal.endpoints.objects_api.channel.SetChannelMetadataImpl Maven / Gradle / Ivy

Go to download

PubNub is a cross-platform client-to-client (1:1 and 1:many) push service in the cloud, capable of broadcasting real-time messages to millions of web and mobile clients simultaneously, in less than a quarter second!

There is a newer version: 10.3.2
Show newest version
package com.pubnub.internal.endpoints.objects_api.channel;

import com.pubnub.api.endpoints.objects_api.channel.SetChannelMetadata;
import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction;
import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction;
import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult;
import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadata;
import com.pubnub.api.models.consumer.objects_api.channel.PNSetChannelMetadataResult;
import com.pubnub.internal.EndpointInterface;
import com.pubnub.internal.PubNubCore;
import com.pubnub.internal.endpoints.DelegatingEndpoint;
import lombok.AllArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.jetbrains.annotations.NotNull;

import java.util.HashMap;
import java.util.Map;

@Accessors(chain = true, fluent = true)
public class SetChannelMetadataImpl
        extends DelegatingEndpoint implements SetChannelMetadata {

    public SetChannelMetadataImpl(final String channel, final PubNubCore pubnubInstance) {
        super(pubnubInstance);
        this.channel = channel;
    }

    @NotNull
    @Override
    protected ExtendedRemoteAction mapResult(@NotNull ExtendedRemoteAction action) {
        return new MappingRemoteAction<>(action, pnChannelMetadataResult ->
                new PNSetChannelMetadataResult(
                        pnChannelMetadataResult.getStatus(),
                        PNChannelMetadata.from(pnChannelMetadataResult.getData())
                )
        );
    }

    @Override
    @NotNull
    protected EndpointInterface createAction() {
        return pubnub.setChannelMetadata(
                channel,
                name,
                description,
                custom,
                includeCustom,
                type,
                status
        );
    }

    private final String channel;

    @Setter
    private String description;

    @Setter
    private String name;

    private Map custom;

    @Setter
    private String status;

    @Setter
    private String type;

    @Setter
    private boolean includeCustom;

    @Override
    public SetChannelMetadata custom(Map custom) {
        final HashMap customHashMap = new HashMap<>();
        if (custom != null) {
            customHashMap.putAll(custom);
        }
        this.custom = customHashMap;
        return this;
    }

    @AllArgsConstructor
    public static class Builder implements SetChannelMetadata.Builder {
        private final PubNubCore pubnubInstance;

        @Override
        public SetChannelMetadata channel(final String channel) {
            return new SetChannelMetadataImpl(channel, pubnubInstance);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy