001/**
002 * Copyright 2010-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.common.util.log;
017
018import java.util.List;
019
020import org.kuali.common.util.Assert;
021import org.kuali.common.util.ListUtils;
022import org.kuali.common.util.nullify.NullUtils;
023import org.slf4j.Logger;
024
025public class LogTableContext {
026
027        public static final LoggerLevel DEFAULT_LOGGER_LEVEL = LoggerLevel.INFO;
028        public static final boolean DEFAULT_LEFT_ALIGN = false;
029        public static final Logger DEFAULT_LOGGER = LoggerUtils.LOGGER_UTILS_LOGGER;
030        public static final String NO_TITLE = NullUtils.NONE;
031        public static final String DEFAULT_TITLE = NO_TITLE;
032
033        private final String title;
034        private final List<String> columns;
035        private final List<Object[]> rows;
036        private final Logger logger;
037        private final LoggerLevel level;
038        private final boolean leftAlign;
039
040        public LogTableContext(List<String> columns, List<Object[]> rows) {
041                this(columns, rows, DEFAULT_LOGGER);
042        }
043
044        public LogTableContext(String title, List<String> columns, List<Object[]> rows) {
045                this(title, columns, rows, DEFAULT_LOGGER_LEVEL, DEFAULT_LOGGER, DEFAULT_LEFT_ALIGN);
046        }
047
048        public LogTableContext(List<String> columns, List<Object[]> rows, Logger logger) {
049                this(DEFAULT_TITLE, columns, rows, logger);
050        }
051
052        public LogTableContext(String title, List<String> columns, List<Object[]> rows, Logger logger) {
053                this(title, columns, rows, DEFAULT_LOGGER_LEVEL, logger, DEFAULT_LEFT_ALIGN);
054
055        }
056
057        public LogTableContext(List<String> columns, List<Object[]> rows, LoggerLevel level, Logger logger, boolean leftAlign) {
058                this(DEFAULT_TITLE, columns, rows, level, logger, leftAlign);
059        }
060
061        public LogTableContext(String title, List<String> columns, List<Object[]> rows, LoggerLevel level, Logger logger, boolean leftAlign) {
062                Assert.noNulls(columns, rows, logger, level);
063                Assert.noBlanks(title);
064                this.title = title;
065                this.columns = ListUtils.newImmutableArrayList(columns);
066                this.rows = ListUtils.newImmutableArrayList(rows);
067                this.level = level;
068                this.logger = logger;
069                this.leftAlign = leftAlign;
070        }
071
072        public String getTitle() {
073                return title;
074        }
075
076        public List<String> getColumns() {
077                return columns;
078        }
079
080        public List<Object[]> getRows() {
081                return rows;
082        }
083
084        public Logger getLogger() {
085                return logger;
086        }
087
088        public LoggerLevel getLevel() {
089                return level;
090        }
091
092        public boolean isLeftAlign() {
093                return leftAlign;
094        }
095
096}