//union.idl // Union example - Weather ServiceThe IDL union ForecastDetail is mapped to a corresponding Java class
package Module 4; public final class ForecastDetail implements org.omg.CORBA.portable.IDLEntity{ ..... public Module4.ForecastType discriminator();The branch type is mapped to a corresponding discriminator field and a discriminator() accessor for the field.
package Module 4; public final class ForecastDetail implements org.omg.CORBA.portable.IDLEntity { ..... private double windchill; ... private double windchill() { if (discriminator != Module4.ForecastType.cold) throw new org.omg.CORBA.BAD_OPERATION(); return windchill; } public void windchill(double _x) { discriminator = Module4.ForecastType.cold; windchill = _x; }The cold/wind chill branch is mapped to the corresponding field, an accessor, and a mutator.