@Override protected ValueUpdate readTensorModifyUpdate(DataType type) { byte operationId = getByte(null); TensorModifyUpdate.Operation operation = TensorModifyUpdate.Operation.getOperation(operationId); if (operation == null) { throw new DeserializationException("Unknown operation id " + operationId + " for tensor modify update"); } if (!(type instanceof TensorDataType)) { throw new DeserializationException("Expected tensor data type, got " + type); } TensorDataType tensorDataType = (TensorDataType)type; TensorFieldValue tensor = new TensorFieldValue(TensorModifyUpdate.convertToCompatibleType(tensorDataType.getTensorType())); tensor.deserialize(this); return new TensorModifyUpdate(operation, tensor); } }
public static Operation getOperation(int id) { for (Operation operation : Operation.values()) { if (operation.id == id) { return operation; } } return null; } }