All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.skillw.asahi.internal.namespacing.infix.linking.InfixMap.kt Maven / Gradle / Ivy

There is a newer version: 1.6.7-beta-6
Show newest version
package com.skillw.asahi.internal.namespacing.infix.linking

import com.skillw.asahi.api.annotation.AsahiInfix
import com.skillw.asahi.api.member.parser.infix.namespacing.BaseInfix

/**
 * @className ActionMap
 *
 * @author Glom
 * @date 2022/8/9 16:26 Copyright 2022 user.
 */
@AsahiInfix
internal object InfixMap : BaseInfix>(MutableMap::class.java) {

    init {
        infix("get") { map ->
            val key = parse()
            map[key]
        }

        infix("put", "set") { map ->
            map as? MutableMap? ?: error("MutableMap")
            val key = parse()
            expect("to")
            val value = parse()
            map[key] = value
            value
        }

        infix("putAll") { map ->
            map as? MutableMap? ?: error("MutableMap")
            val other = parse>()
            map.putAll(other)
        }

        infix("remove") { map ->
            val key = parse()
            map.remove(key)
        }

        infix("contains") { map ->
            val key = parse()
            map.containsKey(key)
        }

        infix("size") { map ->
            map.size
        }

        infix("keys") { map ->
            map.keys
        }

        infix("values") { map ->
            map.values
        }

        infix("entries") { map ->
            map.entries
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy