class OptionalConverter implements ConditionalConverter<Optional<?>, Optional<?>> {
  @Override
  public MatchResult match(Class<?> sourceType, Class<?> destinationType) {
    return (Optional.class.equals(sourceType) && Optional.class.equals(destinationType))
        ? MatchResult.FULL
        : MatchResult.NONE;
  }

  @Override
  @SuppressWarnings("all")
  public Optional<?> convert(MappingContext<Optional<?>, Optional<?>> mappingContext) {<FILL_FUNCTION_BODY>}


  private Class<?> getElementType(MappingContext<Optional<?>, Optional<?>> mappingContext) {
    Mapping mapping = mappingContext.getMapping();
    if (mapping instanceof PropertyMapping) {
      PropertyInfo destInfo = mapping.getLastDestinationProperty();
      Class<?> elementType = TypeResolver.resolveRawArgument(destInfo.getGenericType(),
          destInfo.getInitialType());
      return elementType == TypeResolver.Unknown.class ? Object.class : elementType;
    } else if (mappingContext.getGenericDestinationType() instanceof ParameterizedType) {
      return Types.rawTypeFor(((ParameterizedType) mappingContext.getGenericDestinationType()).getActualTypeArguments()[0]);
    }

    return Object.class;
  }

}

    Class<?> optionalType = getElementType(mappingContext);
    Optional<?> source = mappingContext.getSource();
    if (source == null) {
      return null;
    } else if (source.isPresent()) {
      MappingContext<?, ?> optionalContext = mappingContext.create(source.get(), optionalType);
      return Optional.ofNullable(mappingContext.getMappingEngine().map(optionalContext));
    } else {
      return Optional.empty();
    }
  
<no_super_class>