I recently learn that in Python 3, to minimize the number of accessor methods for a class, you can use a dictionaries to essentially just have one set of accessor methods as follows:
def __init__(self, **kwargs):
self.properties = kwargs
def get_properties(self):
return self.properties
def get_property(self, key):
return self.properties.get(key, None)
This seems really useful and I want to apply something similar in Java. I have been working on applications that may have multiple attributes, and creating and keeping track of all the accessor methods can be a pain. Is there a similar strategy that I could use for Java?