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

  @Override
  public Optional<Object> convert(MappingContext<Object, Optional<Object>> mappingContext) {<FILL_FUNCTION_BODY>}
}

    if (mappingContext.getSource() == null) {
      return Optional.empty();
    }

    MappingContext<?, ?> propertyContext = mappingContext.create(
        mappingContext.getSource(), MappingContextHelper.resolveDestinationGenericType(mappingContext));
    Object destination = mappingContext.getMappingEngine().map(propertyContext);
    return Optional.ofNullable(destination);
  
<no_super_class>