001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.core.pattern.parser; 015 016public class CompositeNode extends SimpleKeywordNode { 017 Node childNode; 018 019 CompositeNode(String keyword) { 020 super(Node.COMPOSITE_KEYWORD, keyword); 021 022 } 023 024 public Node getChildNode() { 025 return childNode; 026 } 027 028 public void setChildNode(Node childNode) { 029 this.childNode = childNode; 030 } 031 032 public boolean equals(Object o) { 033 if (!super.equals(o)) { 034 return false; 035 } 036 if (!(o instanceof CompositeNode)) { 037 return false; 038 } 039 CompositeNode r = (CompositeNode) o; 040 041 return (childNode != null) ? childNode.equals(r.childNode) : (r.childNode == null); 042 } 043 044 @Override 045 public int hashCode() { 046 return super.hashCode(); 047 } 048 049 public String toString() { 050 StringBuilder buf = new StringBuilder(); 051 if (childNode != null) { 052 buf.append("CompositeNode(" + childNode + ")"); 053 } else { 054 buf.append("CompositeNode(no child)"); 055 } 056 buf.append(printNext()); 057 return buf.toString(); 058 } 059}