@Override public Object decode(List<Object> parts, State state) { NestedDecoderState s = getDecoder(state); int index = s.getIndex(); index += s.incPartsIndex(); if (fixedIndex != null && parts.isEmpty()) { s.resetPartsIndex(); } if (index == -1 || (fixedIndex != null && state.getLevel() == 0)) { return decoders[decoders.length-1].decode(parts, state); } Object res = decoders[index].decode(parts, state); if (res == null) { index = s.incIndex() + s.getPartsIndex(); return decoders[index].decode(parts, state); } // TODO refactor it! Decoder<Object> decoder = decoders[index].getDecoder(0, state); if (decoder == RESET_INDEX) { s.setIndex(-1); } return res; }
@Override public Object decode(List<Object> parts, State state) { NestedDecoderState s = getDecoder(state); int index = s.getIndex(); index += s.incPartsIndex(); if (fixedIndex != null && parts.isEmpty()) { s.resetPartsIndex(); } if (index == -1 || (fixedIndex != null && state.getLevel() == 0)) { return decoders[decoders.length-1].decode(parts, state); } Object res = decoders[index].decode(parts, state); if (res == null) { index = s.incIndex() + s.getPartsIndex(); return decoders[index].decode(parts, state); } // TODO refactor it! Decoder<Object> decoder = decoders[index].getDecoder(0, state); if (decoder == RESET_INDEX) { s.setIndex(-1); } return res; }
@Override public Object decode(List<Object> parts, State state) { NestedDecoderState s = getDecoder(state); int index = s.getIndex(); index += s.incPartsIndex(); if (fixedIndex != null && parts.isEmpty()) { s.resetPartsIndex(); } if (index == -1 || (fixedIndex != null && state.getLevel() == 0)) { return decoders[decoders.length-1].decode(parts, state); } Object res = decoders[index].decode(parts, state); if (res == null) { index = s.incIndex() + s.getPartsIndex(); return decoders[index].decode(parts, state); } // TODO refactor it! Decoder<Object> decoder = decoders[index].getDecoder(0, state); if (decoder == RESET_INDEX) { s.setIndex(-1); } return res; }