1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */1718package org.apache.commons.lang3.mutable;
1920/**21 * Provides mutable access to a value.22 * <p>23 * <code>Mutable</code> is used as a generic interface to the implementations in this package.24 * <p>25 * A typical use case would be to enable a primitive or string to be passed to a method and allow that method to26 * effectively change the value of the primitive/string. Another use case is to store a frequently changing primitive in27 * a collection (for example a total in a map) without needing to create new Integer/Long wrapper objects.28 * 29 * @param <T> the type to set and get 30 * @since 2.131 */32publicinterface Mutable<T> {
3334/**35 * Gets the value of this mutable.36 * 37 * @return the stored value38 */39 T getValue();
4041/**42 * Sets the value of this mutable.43 * 44 * @param value45 * the value to store46 * @throws NullPointerException47 * if the object is null and null is invalid48 * @throws ClassCastException49 * if the type is invalid50 */51void setValue(T value);
5253 }