1 /* 2 * Copyright (c) 2014, 2015, Dynatrace and/or its affiliates. All rights reserved. 3 * 4 * This file is part of the Lock Contention Tracing Subsystem for the HotSpot 5 * Virtual Machine, which is developed at Christian Doppler Laboratory on 6 * Monitoring and Evolution of Very-Large-Scale Software Systems. Please 7 * contact us at <http://mevss.jku.at/> if you need additional information 8 * or have any questions. 9 * 10 * This code is free software; you can redistribute it and/or modify it 11 * under the terms of the GNU General Public License version 2 only, as 12 * published by the Free Software Foundation. 13 * 14 * This code is distributed in the hope that it will be useful, but WITHOUT 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 * version 2 for more details (a copy is included in the LICENSE file that 18 * accompanied this code). 19 * 20 * You should have received a copy of the GNU General Public License version 21 * 2 along with this work. If not, see <http://www.gnu.org/licenses/>. 22 * 23 */ 24 package sun.evtracing.processing.statistics.metadata; 25 26 import java.util.Arrays; 27 import java.util.stream.Collectors; 28 29 import sun.evtracing.parser.metadata.JavaClass; 30 31 public class JavaClassStack { 32 33 public static final JavaClassStack HIDDEN = new JavaClassStack(JavaClass.UNKNOWN) { 34 @Override 35 public boolean equals(Object obj) { 36 return (this == obj); 37 } 38 }; 39 40 private final JavaClass[] classes; 41 42 public JavaClassStack(JavaClass... classes) { 43 this.classes = classes; 44 } 45 46 public JavaClass[] classes() { 47 return classes; 48 } 49 50 @Override 51 public int hashCode() { 52 return Arrays.hashCode(classes); 53 } 54 55 @Override 56 public boolean equals(Object obj) { 57 if (this == obj) 58 return true; 59 if (obj == null || getClass() != obj.getClass()) 60 return false; 61 62 JavaClassStack other = (JavaClassStack) obj; 63 return Arrays.equals(classes, other.classes); 64 } 65 66 @Override 67 public String toString() { 68 return Arrays.stream(classes).map(c -> c.toString()).collect(Collectors.joining(", ")); 69 } 70 }