Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access message_type in PNFetchMessageItem #249

Open
VietAnh14 opened this issue Oct 20, 2022 · 2 comments
Open

Cannot access message_type in PNFetchMessageItem #249

VietAnh14 opened this issue Oct 20, 2022 · 2 comments

Comments

@VietAnh14
Copy link

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);
}
}

@kleewho
Copy link
Contributor

kleewho commented Dec 6, 2022

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

@junzuijifei
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants