1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.tools.io 18 19 import android.tools.Tag 20 21 /** Descriptor for files inside flicker result artifacts */ 22 class ResultArtifactDescriptor( 23 /** Trace or dump type */ 24 val traceType: TraceType, 25 /** If the trace/dump is associated with a tag */ 26 val tag: String = Tag.ALL 27 ) { 28 private val isTagTrace: Boolean 29 get() = tag != Tag.ALL 30 31 /** Name of the trace file in the result artifact (e.g. zip) */ <lambda>null32 val fileNameInArtifact: String = buildString { 33 if (isTagTrace) { 34 append(tag) 35 append("__") 36 } 37 append(traceType.fileName) 38 } 39 equalsnull40 override fun equals(other: Any?): Boolean { 41 if (this === other) return true 42 if (other !is ResultArtifactDescriptor) return false 43 44 if (traceType != other.traceType) return false 45 if (tag != other.tag) return false 46 47 return true 48 } 49 hashCodenull50 override fun hashCode(): Int { 51 var result = traceType.hashCode() 52 result = 31 * result + tag.hashCode() 53 return result 54 } 55 toStringnull56 override fun toString(): String = fileNameInArtifact 57 } 58