code: public static <T, V> T update(T object, Class<V> type, String pattern, Bifunctor<V, String, V> updater) {
          if (type.isPrimitive()) {
              throw new IllegalArgumentException("Primitive type must be boxed");
          }
          Pattern regex = pattern != null ? Pattern.compile(pattern) : null;
          for (Field field: object.getClass().getFields()) {
              if ((regex == null || regex.matcher(field.getName()).matches()) && type.isAssignableFrom(boxPrimitive(field.getType()))) {
                  try {
                      field.set(object, updater.invoke(field.getName(), type.cast(field.get(object))));
                  } catch (Exception x) {}
              }
          }
          return object;
      }
docs: Updates an object by modifying all of its public fields that match a certain name pattern or a super type
  with a transforming function.
  
  @param <T> the class of the object
  @param <V> the class of the object's public fields to be updated
  @param object a Java object
  @param type an upper bound Class matching, or boxing, the type of the data members
  @param pattern an optional regex that matches the fields' names
  @param updater a Bifunctor
  @return the same object with fields updated