001/*
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 *  Copyright (C) 1999-2026, 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 */
014
015package ch.qos.logback.core.util;
016
017/**
018 * A simple mutable holder for an integer value, providing basic operations
019 * like incrementing, setting, and retrieving the value. This class is not
020 * thread-safe and should be used in single-threaded contexts or with external
021 * synchronization.
022 *
023 * @since 1.5.24
024 */
025public class IntHolder {
026    public int value;
027
028    /**
029     * Constructs an IntHolder with the specified initial value.
030     *
031     * @param value the initial integer value to hold
032     */
033    public IntHolder(int value) {
034        this.value = value;
035    }
036
037    /**
038     * Increments the held value by 1.
039     */
040    public void inc() {
041        value++;
042    }
043
044    /**
045     * Sets the held value to the specified new value.
046     *
047     * @param newValue the new integer value to set
048     */
049    public void set(int newValue) {
050        value = newValue;
051    }
052
053    /**
054     * Returns the current held value.
055     *
056     * @return the current integer value
057     */
058    public int get(){
059        return value;
060    }
061}