### Question:
WritableUnion implements Union, Writable { @Override public Object switchObject(int newPosition) { this.position = newPosition; return getObject(); } protected  WritableUnion(Class<?>... classes); protected  WritableUnion(Writable... objects); @Override final int getPosition(); @Override Object switchObject(int newPosition); @Override final Object getObject(); @Override void write(DataOutput out); @Override void readFields(DataInput in); @Override String toString();  }### Answer:
@Test public void createFromObject() throws Exception { Union union = new WritableUnion( new IntOption(100), new LongOption(200L), new StringOption("Hello, world!")); assertThat(union.switchObject(0), is((Object) new IntOption(100))); assertThat(union.switchObject(1), is((Object) new LongOption(200L))); assertThat(union.switchObject(2), is((Object) new StringOption("Hello, world!"))); }