public static String convertTextToObject(Object source, MediaType sourceType) {
      if (source == null) return null;
      if (source instanceof String) return source.toString();
      if (source instanceof byte[]) {
         byte[] bytesSource = (byte[]) source;
         return new String(bytesSource, sourceType.getCharset());
      }
      throw CONTAINER.invalidTextContent(source);
   }
@Test
   public void testTextToObjectConversion() {
      String source = "Can the maker repair what he makes?";
      String source2 = "I had your job once. I was good at it.";

      byte[] sourceBytes = source2.getBytes(US_ASCII);

      Object result = StandardConversions.convertTextToObject(source, APPLICATION_OBJECT);
      Object result2 = StandardConversions.convertTextToObject(sourceBytes, TEXT_PLAIN.withCharset(US_ASCII));

      assertEquals(source, result);
      assertEquals(source2, result2);
   }