package ktak.immutablejava;

public abstract class Option<T> {
    
    public abstract <R> R visit(Visitor<R,T> visitor);
    
    public interface Visitor<R,T> {
        public R visitNone();
        public R visitSome(T value);
    }
    
    public static final class None<T> extends Option<T> {
        
        @Override
        public <R> R visit(Visitor<R, T> visitor) {
            return visitor.visitNone();
        }
        
    }
    
    public static final class Some<T> extends Option<T> {
        
        private final T val;
        
        public Some(T val) {
            this.val = val;
        }
        
        @Override
        public <R> R visit(Visitor<R, T> visitor) {
            return visitor.visitSome(val);
        }
        
    }
    
    public static <T> Option<T> none() { return new None<T>(); }
    
    public static <T> Option<T> some(T val) { return new Some<T>(val); }
    
}

@@ -117,24 +117,89 @@
 itor);%0A    %0A
+    public abstract %3CU%3E Option%3CU%3E mapSome(Function%3CT,U%3E f);%0A    %0A
     public i
@@ -218,24 +218,24 @@
 itor%3CR,T%3E %7B%0A
-
         publ
@@ -488,32 +488,153 @@
      %7D%0A        %0A
+        @Override%0A        public %3CU%3E Option%3CU%3E mapSome(Function%3CT, U%3E f) %7B%0A            return none();%0A        %7D%0A        %0A
     %7D%0A    %0A    p
@@ -871,32 +871,32 @@
 , T%3E visitor) %7B%0A
-
             retu
@@ -933,32 +933,165 @@
      %7D%0A        %0A
+        @Override%0A        public %3CU%3E Option%3CU%3E mapSome(Function%3CT, U%3E f) %7B%0A            return some(f.apply(val));%0A        %7D%0A        %0A
     %7D%0A    %0A    p

add mapSome function to Option