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

com.innovenso.townplan.dsl.SortKeyContext.groovy Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package com.innovenso.townplan.dsl

import lombok.NonNull

class SortKeyContext {
	private final Map counterMap = [:]
	private String prefix = ""

	public String getPrefix() {
		return prefix
	}

	public void setPrefix(String prefixToSet) {
		if (prefixToSet) this.prefix = "${prefixToSet}."
		else this.prefix = ""
	}

	String nextSortKey(@NonNull String sortableType) {
		Integer currentCount = ++counterMap.getOrDefault(sortableType, 0)
		counterMap.put(sortableType, currentCount)
		"${prefix}${currentCount}"
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy