package guangyin.internal.types;

import clojure.lang.Keyword;
import clojure.lang.ILookup;
import clojure.lang.IPersistentMap;
import java.time.temporal.TemporalField;
import java.time.temporal.TemporalAccessor;

public class TemporalAccessorWrapper extends ObjectWrapper implements ILookup {
    protected IPersistentMap keymap;
    private TemporalAccessor wrapped;

    public TemporalAccessorWrapper(IPersistentMap keymap, TemporalAccessor wrapped) {
        super(wrapped);
        this.keymap = keymap;
        this.wrapped = wrapped;
    }

    public Object valAt(Object key) {
        return this.valAt(key, null);
    }

    public Object valAt(Object key, Object notFound) {
        Keyword keyword = (Keyword) key;
        TemporalField field = (TemporalField) keyword.invoke(this.keymap);
        if (field == null || !wrapped.isSupported(field)) {
            return notFound;
        }
        return wrapped.getLong(field);
    }
}

@@ -106,26 +106,97 @@
 e.lang.I
-Persistent
+MapEntry;%0Aimport clojure.lang.IPersistentMap;%0Aimport clojure.lang.PersistentArray
 Map;%0Aimp
@@ -368,75 +368,112 @@
   pr
-otected IPersistentMap keymap;%0A    private TemporalAccessor wrapped
+ivate TemporalAccessor wrapped;%0A    protected IPersistentMap keymap;%0A    protected IPersistentMap valmap
 ;%0A%0A 
@@ -585,37 +585,8 @@
 d);%0A
-        this.keymap = keymap;
 %0A   
@@ -610,24 +610,435 @@
  = wrapped;%0A
+        this.keymap = keymap;%0A%0A        IPersistentMap valmap = PersistentArrayMap.EMPTY;%0A        for (Object val : keymap) %7B%0A            IMapEntry entry = (IMapEntry) val;%0A            TemporalField field = (TemporalField) entry.val();%0A            if (wrapped.isSupported(field)) %7B%0A                valmap = valmap.assoc(entry.key(), wrapped.getLong(field));%0A            %7D%0A        %7D%0A        this.valmap = valmap;%0A
     %7D%0A%0A    p
@@ -1097,20 +1097,21 @@
 .val
+map.val
 At(key
-, null
 );%0A 
@@ -1183,250 +1183,45 @@
     
-Keyword keyword = (Keyword) key;%0A        TemporalField field = (TemporalField) keyword.invoke(this.keymap);%0A        if (field == null %7C%7C !wrapped.isSupported(field)) %7B%0A            return notFound;%0A        %7D%0A        return wrapped.getLong(fiel
+return this.valmap.valAt(key, notFoun
 d);%0A

Create an actual map of TemporalAccessor in wrapper.