1   /*
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2026, 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 v2.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.core.util;
16  
17  /**
18   * A simple mutable holder for an integer value, providing basic operations
19   * like incrementing, setting, and retrieving the value. This class is not
20   * thread-safe and should be used in single-threaded contexts or with external
21   * synchronization.
22   *
23   * @since 1.5.24
24   */
25  public class IntHolder {
26      public int value;
27  
28      /**
29       * Constructs an IntHolder with the specified initial value.
30       *
31       * @param value the initial integer value to hold
32       */
33      public IntHolder(int value) {
34          this.value = value;
35      }
36  
37      /**
38       * Increments the held value by 1.
39       */
40      public void inc() {
41          value++;
42      }
43  
44      /**
45       * Sets the held value to the specified new value.
46       *
47       * @param newValue the new integer value to set
48       */
49      public void set(int newValue) {
50          value = newValue;
51      }
52  
53      /**
54       * Returns the current held value.
55       *
56       * @return the current integer value
57       */
58      public int get(){
59          return value;
60      }
61  }