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.log4j.model; 017 018import java.util.ArrayList; 019import java.util.Collections; 020import java.util.List; 021 022import javax.xml.bind.annotation.XmlAttribute; 023import javax.xml.bind.annotation.XmlElement; 024 025import org.kuali.common.util.Assert; 026import org.kuali.common.util.nullify.NullUtils; 027 028public final class Appender { 029 030 public static final List<Appender> EMPTY = Collections.<Appender> emptyList(); 031 public static final Class<? extends org.apache.log4j.Appender> NO_APPENDER_CLASS = org.apache.log4j.Appender.class; 032 public static final Appender NONE = new Appender(); 033 034 @XmlAttribute 035 private final String name; 036 037 @XmlAttribute(name = "class") 038 private final Class<? extends org.apache.log4j.Appender> appenderClass; 039 040 @XmlElement(name = "param") 041 private final List<Param> params; 042 043 @XmlElement 044 private final Layout layout; 045 046 private Appender() { 047 this(NullUtils.NONE, NO_APPENDER_CLASS, Layout.NONE, Param.EMPTY); 048 } 049 050 public Appender(String name, Class<? extends org.apache.log4j.Appender> appenderClass, Layout layout) { 051 this(name, appenderClass, layout, Param.EMPTY); 052 } 053 054 public Appender(String name, Class<? extends org.apache.log4j.Appender> appenderClass, Layout layout, List<Param> params) { 055 Assert.noNulls(appenderClass, layout, params); 056 Assert.noBlanks(name); 057 this.name = name; 058 this.appenderClass = appenderClass; 059 this.layout = layout; 060 this.params = new ArrayList<Param>(params); 061 } 062 063 public List<Param> getParams() { 064 return Collections.unmodifiableList(params); 065 } 066 067 public String getName() { 068 return name; 069 } 070 071 public Class<? extends org.apache.log4j.Appender> getAppenderClass() { 072 return appenderClass; 073 } 074 075 public Layout getLayout() { 076 return layout; 077 } 078 079}