View Javadoc
1   package com.atlassian.activeobjects.ao;
2   
3   import com.atlassian.activeobjects.internal.Prefix;
4   import net.java.ao.SchemaConfiguration;
5   import org.slf4j.Logger;
6   import org.slf4j.LoggerFactory;
7   
8   import static com.google.common.base.Preconditions.checkNotNull;
9   
10  /**
11   * A {@link SchemaConfiguration schema configuration} that will allow table starting with a given {@link com.atlassian.activeobjects.internal.Prefix prefix}
12   * to be managed.
13   */
14  public final class PrefixedSchemaConfiguration implements SchemaConfiguration {
15      private final Logger logger = LoggerFactory.getLogger(this.getClass());
16  
17      private final Prefix prefix;
18  
19      public PrefixedSchemaConfiguration(Prefix prefix) {
20          this.prefix = checkNotNull(prefix);
21      }
22  
23      public final boolean shouldManageTable(String tableName, boolean caseSensitive) {
24          final boolean should = prefix.isStarting(tableName, caseSensitive);
25          logger.debug("Active objects will {} manage table {}", should ? "" : "NOT", tableName);
26          return should;
27      }
28  }