code: public static String cloneArgument (Class<?> dsclazz, Field field, String name)
      {
          Class<?> clazz = field.getType();
          if (clazz.isArray() || dsclazz.equals(clazz)) {
              return "(" + name + " == null) ? null : " + name + ".clone()";
          } else if (dsclazz.isAssignableFrom(clazz)) {
              return "(" + name + " == null) ? null : " +
                  "(" + simpleName(field) + ")" + name + ".clone()";
          } else {
              return name;
          }
      }
docs: Potentially clones the supplied argument if it is the type that needs such treatment.