Package org.matsim.utils.objectattributes
Supports keeping track of arbitrary attributes for identifiable objects.
An example usage can be seen in For this reason, there is
no method available directly in
RunObjectAttributesExample
.
Design thoughts
I think of ObjectAttributes (OA) as a way to provide specific additional data to algorithms and modules. Typically, specialized algorithms/modules might require additional data than what is available by default in MATSim's data container (like population, network). For example, modules could need information about persons' income, a node's z-coordinate, or a link's curviness. Important to consider is that the algorithm always has to specify what additional data it needs so it can access it. In the example above, an algorithm that needs a person's income needs to know the name of the attribute containing the income. Typically, it could do so by providing a settersetPersonIncomeAttributeName(String)
or even exposing it as a config-parameter.
This implies that modules should always just access a few specific attributes, but
they should never have the need to just access all attributes and then maybe figure
out what they could do with the available attributes, probably even guessing some
interpretation of the attributes based on their names. ObjectAttributes
that returns all attributes
for a specific object. Only getters for single, named attributes are providers.
-
Interface Summary Interface Description AttributeConverter<T> Converts an attribute to a String (for being written out) or from a String (after being read in). -
Class Summary Class Description FailingObjectAttributes Deprecated. ObjectAttributes A simple helper class to store arbitrary attributes (identified by Strings) for arbitrary objects (identified by String-Ids).ObjectAttributesConverter Object that converts arbitrary objects to and from strings based on the logic defined by sObjectAttributesUtils ObjectAttributesXmlReader Reads object attributes from a file.ObjectAttributesXmlWriter Writes object attributes to a file.RunObjectAttributesExample Shows an example usage ofObjectAttributes
.