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

io.dylemma.spac.json.impl.ArrayIndexContextMatcher.scala Maven / Gradle / Ivy

There is a newer version: 0.12.1
Show newest version
package io.dylemma.spac
package json
package impl

class ArrayIndexContextMatcher[A](debugName: String, f: JsonEvent.IndexStart => Option[A]) extends ContextMatcher[JsonStackElem, A] {
	override def toString = debugName
	def applyChained[B](stack: collection.IndexedSeq[JsonStackElem], offset: Int, avail: Int, next: ContextMatcher[JsonStackElem, B]) = {
		if (avail >= 2) {
			for {
				indexStart <- stack(offset + 1).asIndexStart
				if stack(offset).isArrayStart
				a <- f(indexStart)
				b <- next(stack, offset + 2, avail - 2)
			} yield (a, b)
		} else {
			None
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy