join

fun Mappings.join(otherMappings: Mappings, intermediateNamespace: String, requireMatch: Boolean = false): Mappings(source)

Joins together this Mappings with otherMappings, by matching on intermediateNamespace, producing new Mappings that contain all entries from this Mappings and otherMappings. If requireMatch is true, this method will throw an exception when no method or field or class is found

Samples

import com.grappenmaker.mappings.*
import com.grappenmaker.mappings.Mappings
import kotlin.test.*

fun main() { 
   //sampleStart 
   val someMappings = GenericMappings(
    namespaces = listOf("official", "intermediary"),
    classes = listOf(MappedClass(
        names = listOf("a", "b"),
    ))
)

val otherMappings = GenericMappings(
    namespaces = listOf("intermediary", "named"),
    classes = listOf(MappedClass(
        names = listOf("b", "c"),
    ))
)

val joined = someMappings.join(otherMappings, intermediateNamespace = "intermediary")

assertEquals(
    GenericMappings(
        namespaces = listOf("official", "intermediary", "named"),
        classes = listOf(MappedClass(
            names = listOf("a", "b", "c"),
        ))
    ), joined
) 
   //sampleEnd
}

fun Iterable<Mappings>.join(intermediateNamespace: String, requireMatch: Boolean = false): Mappings(source)

Joins together an Iterable of Mappings, producing new Mappings that contain all entries from all Mappings. Note: all namespaces are kept, in order to be able to reduce the mappings nicely without a lot of overhead. If you want to exclude certain namespaces, use Mappings.filterNamespaces. If this Iterable would be considered empty (its Iterator.hasNext would return false on the first iteration), EmptyMappings is returned.

The order of these namespaces will be confusing due to the way Mappings.join orders namespaces. Use Mappings.reorderNamespaces to ensure the resulting Mappings will be properly namespaced, if required.

See also

Samples

import com.grappenmaker.mappings.*
import com.grappenmaker.mappings.Mappings
import kotlin.test.*

fun main() { 
   //sampleStart 
   val someMappings = GenericMappings(
    namespaces = listOf("official", "intermediary"),
    classes = listOf(MappedClass(
        names = listOf("a", "b"),
    ))
)

val otherMappings = GenericMappings(
    namespaces = listOf("intermediary", "named"),
    classes = listOf(MappedClass(
        names = listOf("b", "c"),
    ))
)

val moreMappings = GenericMappings(
    namespaces = listOf("intermediary", "obfuscated"),
    classes = listOf(MappedClass(
        names = listOf("b", "e"),
    ))
)

val joined = listOf(someMappings, otherMappings, moreMappings).join(intermediateNamespace = "intermediary")

assertEquals(
    GenericMappings(
        namespaces = listOf("official", "named", "intermediary", "obfuscated"),
        classes = listOf(MappedClass(
            names = listOf("a", "c", "b", "e"),
        ))
    ), joined
)

assertEquals(emptyList<Mappings>().join(intermediateNamespace = "intermediary"), EmptyMappings) 
   //sampleEnd
}