A struct represents the struct in C, but then more powerful. Any class that extends a struct must only use a set of basic classes in public fields. Though implementation classes may have methods (public or private) it should not have any non-public fields or abstract the access to the fields in get/set methods. The basic idea of the struct is that the public fields are the public API.
The reason for the struct is that classes fall apart when there is a process boundary. A programmer has a reasonable expectation that the program its code runs in is consistent, the same classes are used to access the objects. This is not true once you go to a distributed world, and today most worlds are distributed. Once an object escapes the program, it MUST expose its internal state, turning the internal state into public API. This is one of the main reasons serialization in Java has failed. In an OO environment there is the illusion that an object has privacy, but in virtually all non-toy programs this illusion is too easily shattered. It also explains the success of ruby and Javascript that both not even attempt to have private state.
However, Java has many good parts and also OO has proven to be very useful in lots of applications. To leverage all these good parts (especially the amazing things IDEs do with the type information) this class attempts to find a middle ground between the error-prone permissiveness of dynamic languages and the overly constrained and often illusionary Java world. A struct is like a constrained map (see {@link #asMap()} for more information). However,structs provide type safe access and all the wonders of IDE magic like refactoring and completion.
structs should be used in places where information is shared between different processes. The available methods make it possible to easily serialize (JSON is built in, but other serializations are possible) because its types are strictly limited. Traversing an object is straightforward for this reason.
Since the purpose of structs is to be used anywhere, this package is kept simple and small to minimize the burden. However, it is expected that there are many libraries that leverage structs since the type information in fields makes it possible to decode for example a JSON stream into the type safe structs.
The following types are allowed in fields of structs:
struct String primitives Number subclasses Iterable (lists, sets, etc) {@code Map}arrays
Custom types are allowed but are translated to their toString() representation and must be constructable with that representation. It is usually MUCH better to deconstruct such objects into a complex struct.