All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.avanza.astrix.config.DynamicProperty Maven / Gradle / Ivy

There is a newer version: 0.43.6
Show newest version
/*
 * Copyright 2014 Avanza Bank AB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.avanza.astrix.config;
/**
 * A property that can change state even after it is read
 * from a {@link DynamicConfigSource}. 

* * DynamicProperty instances are designed to be lightweight with no dependencies * to the underlying configuration sources, thereby keeping consumers of DynamicProperty * instances decoupled from the underlying configuration sources.

* * @author Elias Lindholm (elilin) * * @param */ public interface DynamicProperty { /** * Adds a given listener to the underlying property. The listener * will be notified each time the property value changes.

* * Events are not guaranteed to be received in the same order * as the underlying property is set.

* * The listener will be notified synchronously on the same thread * that mutates the underlying property, so don't do any long-running * work on the thread thats notifies the {@link DynamicPropertyListener}.

* * @param listener */ void addListener(DynamicPropertyListener listener); /** * Removes a given listener. After remove the given listener will * not receive events when this property is changed. * * @param listener */ void removeListener(DynamicPropertyListener listener); /** * Returns the current value of this DynamicPropery. For primitive * types the boxed version is returned (never null). * * @return */ T getCurrentValue(); /** * Sets the value of this DynamicProperty. If the underlying * property is a primitive type then this method throws * {@link NullPointerException} when passing a null argument. All * other DynamicPropery types accepts null as a value. * @param value */ void setValue(T value); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy