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

net.java.ao.schema.TransformsTableNameConverter Maven / Gradle / Ivy

Go to download

This is the full Active Objects library, if you don't know which one to use, you probably want this one.

There is a newer version: 6.1.1
Show newest version
package net.java.ao.schema;

import java.util.List;

import static com.google.common.base.Preconditions.checkNotNull;
import static net.java.ao.Common.convertSimpleClassName;

abstract class TransformsTableNameConverter extends CanonicalClassNameTableNameConverter {
    private List transforms;
    private CanonicalClassNameTableNameConverter delegateTableNameConverter;

    TransformsTableNameConverter(List transforms, CanonicalClassNameTableNameConverter delegateTableNameConverter) {
        this.transforms = checkNotNull(transforms);
        this.delegateTableNameConverter = checkNotNull(delegateTableNameConverter);
    }

    @Override
    protected final String getName(String entityClassCanonicalName) {
        return delegateTableNameConverter.getName(transform(entityClassCanonicalName));
    }

    private String transform(String entityClassCanonicalName) {
        for (Transform transform : transforms) {
            if (transform.accept(entityClassCanonicalName)) {
                return transform.apply(entityClassCanonicalName);
            }
        }
        return entityClassCanonicalName;
    }

    static interface Transform {
        boolean accept(String entityClassCanonicalName);

        String apply(String entityClassCanonicalName);
    }

    final static class ClassNameTableNameConverter extends CanonicalClassNameTableNameConverter {
        @Override
        protected String getName(String entityClassCanonicalName) {
            return convertSimpleClassName(entityClassCanonicalName);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy