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

com.justai.jaicf.generic.Compositions.kt Maven / Gradle / Ivy

package com.justai.jaicf.generic

import com.justai.jaicf.api.BotRequest
import com.justai.jaicf.context.ActivatorContext
import com.justai.jaicf.reactions.Reactions

/*
 * All type tokens' compositions are presented here
 *
 * The fowlloing are true for all compositions:
 *  1. the second argument of the composition must always be more (or no less) specific
 *     by all common type parameters than the first one;
 *  2. the result of the composition is the type token,
 *     that the most specific by all presented in both arguments type parameters
 */

private typealias Act = ActivatorTypeToken
private typealias Ch = ChannelTypeToken
private typealias Ctx = ContextTypeToken

private typealias Req = BotRequest
private typealias React = Reactions
private typealias ActCtx = ActivatorContext

// ---- ActivatorTypeToken and ActivatorTypeToken
infix fun  Act.and(other: Act): Act = other

// ---- ActivatorTypeToken and ChannelTypeToken
infix fun  Act.and(other: Ch): Ctx = Ctx(activatorType, other.requestType, other.reactionsType)

// ---- ActivatorTypeToken and ContextTypeToken
infix fun  Act.and(other: Ctx): Ctx = other

// ---- ChannelTypeToken and ActivatorTypeToken
infix fun  Ch.and(other: Act): Ctx = Ctx(other.activatorType, requestType, reactionsType)

// ---- ChannelTypeToken and ChannelTypeToken
infix fun  Ch.and(other: Ch): Ch = other

// ---- ChannelTypeToken and ContextTypeToken
infix fun  Ch.and(other: Ctx): Ctx = other

// ---- ContextTypeToken and ActivatorTypeToken
infix fun  Ctx.and(other: Act): Ctx = Ctx(other.activatorType, requestType, reactionsType)

// ---- ContextTypeToken and ChannelTypeToken
infix fun  Ctx.and(other: Ch): Ctx = Ctx(activatorType, other.requestType, other.reactionsType)

// ---- ContextTypeToken and ContextTypeToken
infix fun  Ctx.and(other: Ctx): Ctx = other




© 2015 - 2024 Weber Informatics LLC | Privacy Policy