code: public static byte[] serialize(final Object obj) {
          if (obj == null) {
              return null;
          }
          try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
              final ObjectOutputStream out = new ObjectOutputStream(baos);
              out.writeObject(obj);
              return baos.toByteArray();
          } catch (final IOException ex) {
              throw new RuntimeException(ex);
          }
      }
docs: Serializes the given object. A <code>null</code> argument returns <code>null</code>.
  
  @param obj
  Object to serialize or <code>null</code>.
  
  @return Serialized object or <code>null</code>.