Very, very, lightweight dynamic-class-based immutable value types for Java 8.
You don’t actually want this. It’s more or less a fanwork based on the canon of Dominic Fox’s endless stream of attempts to bring structs to Java. It is not the first.
Define types as follows:
public interface Address extends Struct<Address> {
Collection<String> addressLines();
String postcode();
}
public interface Person extends Struct<Person> {
String name();
int age();
Address address();
}
Build values like this:
Person person = Struct.of(Person.class);
Read properties like this:
int age = person.age();
At the moment, you can’t actually create structs whose properties have non-zero values, or update structs in any way. Rest assured that this is the project’s highest priority. After that we’ll get on to lenses and destructors and Q-algebras and all that.