1 /* 2 * Logback: the reliable, generic, fast and flexible logging framework. 3 * Copyright (C) 1999-2024, QOS.ch. All rights reserved. 4 * 5 * This program and the accompanying materials are dual-licensed under 6 * either the terms of the Eclipse Public License v1.0 as published by 7 * the Eclipse Foundation 8 * 9 * or (per the licensee's choosing) 10 * 11 * under the terms of the GNU Lesser General Public License version 2.1 12 * as published by the Free Software Foundation. 13 */ 14 15 package ch.qos.logback.classic.boolex; 16 17 import org.slf4j.Marker; 18 19 import java.util.List; 20 21 /** 22 * A helper class to be used in conjunction with {@link ch.qos.logback.classic.boolex.JaninoEventEvaluator} 23 * 24 * @since 1.5.4 25 */ 26 public class MarkerList { 27 28 List<Marker> markers; 29 30 public MarkerList(List<Marker> markers) { 31 this.markers = markers; 32 } 33 34 /** 35 * Check whether this list contains a given marker. 36 * 37 * @param markerName 38 * @return 39 */ 40 public boolean contains(String markerName) { 41 if(markerName == null || markerName.trim().length() == 0) 42 return false; 43 44 if(markers == null || markers.isEmpty()) 45 return false; 46 47 final boolean result = markers.stream().anyMatch( m -> m.contains(markerName)); 48 return result; 49 } 50 51 /** 52 * Return the first marker on the list, can be null. 53 * 54 * 55 * @return the first marker on the list, can be null 56 */ 57 public Marker getFirstMarker() { 58 if(markers == null || markers.isEmpty()) { 59 return null; 60 } else { 61 return markers.get(0); 62 } 63 } 64 }