Skip to content

Cannot access message_type in PNFetchMessageItem #249

Open

Description

@VietAnh14

Hi, why the getMessageType function is private, and how can I get message type? It's difference with the example in the docs

@Getter(AccessLevel.NONE)
private final String messageType;
private int getMessageType() {
if (messageType == null || messageType.isEmpty()) {
return 0;
} else {
return Integer.parseInt(messageType);
}
}

Activity

  1. kleewho commented on Dec 6, 2022

    @kleewho
    Contributor

    @VietAnh14 Hi. We're working on a new version that should give you access to this field.

  2. junzuijifei commented on Nov 1, 2023

    @junzuijifei

    The code you provided is for a private method called getMessageType() in a Java class PNFetchMessageItem from the PubNub API. This method is used to get the message type from an instance of PNFetchMessageItem. The reason it's marked as private is because it is intended to be an internal method of the class and not something that should be accessed directly from outside the class.

    In object-oriented programming, it's a common practice to encapsulate the internal details of a class and provide a public interface for interacting with the class. This helps to maintain the integrity and consistency of the class by preventing external code from directly modifying its internal state. Instead, external code should use the public methods and properties of the class to interact with it.

    In the code you provided, the getMessageType() method is used internally by the class to get the message type, but it's not meant to be accessed from outside the class. To get the message type of a PNFetchMessageItem object, you should use the public methods or properties provided by the class, if available.

    If you're looking at the documentation and the code you provided doesn't match the example in the docs, it's possible that the documentation might be outdated or incorrect. You should refer to the official documentation or code comments provided by the library's developers for the correct way to use the PNFetchMessageItem class and get the message type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions