class MapValue extends VirtualValue {

    public MapValue updatedWith( String key, AnyValue value )
    {
        AnyValue current = get( key );
        if ( current.equals( value ) )
        {
            return this;
        }
        else if ( current == NO_VALUE )
        {
            return new UpdatedMapValue( this, new String[]{key}, new AnyValue[]{value} );
        }
        else
        {
            return new MappedMapValue( this, ( k, v ) -> {
                if ( k.equals( key ) )
                {
                    return value;
                }
                else
                {
                    return v;
                }
            } );
        }
    }

}