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

org.joinedworkz.common.strategies.TableNameStrategy.xtend Maven / Gradle / Ivy

There is a newer version: 1.3.51
Show newest version
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
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy