I am building an API for my application as a middle layer between model and the controller. The model contains all data and low-level function. I have created a new class for API which uses the model but makes things easier for the user and does not let the user to access the data directly.
Now, I would like to prevent the user from accessing the model and let him to use only the functions from API.
How do I do that?
As far as I believe, this can be simply done by specifying whether the method or variable is private or public. The problem is that I have many static fields for global data. Can I restrict access to static fields so that only private functions of API can access them?
private,protectedorpublicmodifiers. When you do that, the default visibility of the field or method ispackage, which means that only classes that are within the same package may access that field or method. I guess you can think of it as "public" to the package only.