aboutsummaryrefslogtreecommitdiff
path: root/Mammoth/SimpleResult.cs
blob: f20cd42c981f7ca10edc1aa96ca35b1156f1da3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.Collections.Generic;
using Mammoth.Couscous;
using Mammoth.Couscous.org.zwobble.mammoth.@internal.results;

namespace Mammoth {
    internal static class SimpleResult {
        internal static IResult<T> ToResult<T>(this InternalResult<T> result) {
            var warnings = new HashSet<string>(FromJava.IterableToEnumerable(result.getWarnings()));
            return new SimpleResult<T>(result.getValue(), warnings);
        }
    }
    
    internal class SimpleResult<T> : IResult<T> {
        public T Value { get; }
        public ISet<string> Warnings { get; }
        
        internal SimpleResult(T value, ISet<string> warnings) {
            Value = value;
            Warnings = warnings;
        }
    }
}