org.joinedworkz.common.strategies.TableNameStrategy.xtend Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-base Show documentation
Show all versions of common-base Show documentation
DSL based modeling framework - facilities common base
package org.joinedworkz.common.strategies
import javax.inject.Singleton
import org.joinedworkz.common.helper.NameHelper
import org.joinedworkz.core.facility.AbstractStrategy
import org.joinedworkz.core.model.CmnFieldContainer
import org.joinedworkz.core.model.CmnObject
import org.joinedworkz.common.helper.CmnModelHelper
import javax.inject.Inject
@Singleton
class TableNameStrategy extends AbstractStrategy {
@Inject
protected extension CmnModelHelper
@Inject
protected extension NameHelper
override Object apply(CmnObject obj) {
if (obj instanceof CmnFieldContainer) {
return obj.defaultTableName
}
}
def String defaultTableName(CmnFieldContainer it) {
val prefix = model?.getString('tableNamePrefix')
val tableName = name.camelCaseToUnderLineSeperated.toLowerCase
if (prefix !== null) {
return prefix + tableName
} else {
return tableName
}
}
}