module Module4 { enum SizeType {smaller, bigger, questionable}; union SizedNumber switch (SizeType) { case smaller: short smallNum; case bigger: long bigNum; default: long someNum; }; };
public short smallNum() { if( discriminator != Module4.SizeType.bigger) throw new org.omg.CORBA.BAD_OPERATION(); return smallNum; }
public int someNum() { return someNum; }
public int bigNum() { if( discriminator != Module4.SizeType.bigger) throw new org.omg.CORBA.BAD_OPERATION(); return bigNum; }
againstsmaller
notbigger
SizedNumber
SizedNumber num = new SizedNumber(); num.bigNum(999); return num;
return new SizedNumber(999);
SizedNumber num = new SizedNumber(Module4.SizeType.bigger); num.bigNum(999); return num;