@Override public CounterState readObject(ObjectInput input) throws IOException, ClassNotFoundException { return MarshallUtil.unmarshallEnum(input, CounterState::valueOf); } }
@Override public CacheContainerAdmin.AdminFlag readObject(ObjectInput input) throws IOException, ClassNotFoundException { return MarshallUtil.unmarshallEnum(input, CacheContainerAdmin.AdminFlag::valueOf); }
@Override public AuthenticationSessionModel.ExecutionStatus readObject(ObjectInput input) throws IOException, ClassNotFoundException { return MarshallUtil.unmarshallEnum(input, ExternalizerImpl::fromOrdinal); } };
@Override public void readFrom(ObjectInput input) throws IOException, ClassNotFoundException { commandType = MarshallUtil.unmarshallEnum(input, CQCommandType::valueOf); queryDefinition = (QueryDefinition) input.readObject(); queryId = MarshallUtil.unmarshallUUID(input, true); docIndex = input.readInt(); }
@Override public void readFrom(ObjectInput input) throws IOException, ClassNotFoundException { commandType = MarshallUtil.unmarshallEnum(input, ClusteredQueryCommandType::valueOf); query = (HSQuery) input.readObject(); lazyQueryId = MarshallUtil.unmarshallUUID(input, true); docIndex = input.readInt(); }
static SortField readObjectStatic(ObjectInput input) throws IOException { String fieldName = input.readUTF(); Type sortType = MarshallUtil.unmarshallEnum(input, (ordinal) -> SORTFIELD_TYPE_VALUES[ordinal]); boolean reverseSort = input.readBoolean(); return new SortField(fieldName, sortType, reverseSort); } }
@Override public ClusteredLockValue readObject(ObjectInput input) throws IOException, ClassNotFoundException { String requestId = MarshallUtil.unmarshallString(input); Object owner = input.readObject(); ClusteredLockState state = MarshallUtil.unmarshallEnum(input, ClusteredLockState::valueOf); return new ClusteredLockValue(requestId, owner, state); } }
@Test public void testEnum() throws IOException { ObjectInputOutput io = new ObjectInputOutput(); MarshallUtil.marshallEnum(null, io); Assert.assertNull(MarshallUtil.unmarshallEnum(io, ordinal -> TestEnum.values()[ordinal])); Assert.assertEquals(0, io.buffer.size()); for (TestEnum e : TestEnum.values()) { io.reset(); MarshallUtil.marshallEnum(e, io); Assert.assertEquals(e, MarshallUtil.unmarshallEnum(io, ordinal -> TestEnum.values()[ordinal])); Assert.assertEquals(0, io.buffer.size()); } }