Package jetbrains.buildServer.util
Class Property<T>
- java.lang.Object
-
- jetbrains.buildServer.util.Property<T>
-
- Type Parameters:
T- type of the property.
public final class Property<T> extends Object
Holds a (not-nullable) property value and provides an event when the value is changed.- Author:
- Leonid Bushuev from JetBrains
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceProperty.Listener<T>Receives a notification when property value is changed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattachListener(Property.Listener<T> listener)Attaches the given listener.voiddetachListener(Property.Listener<T> listener)Detaches the given listener.Tget()Returns the property value.voidset(T newValue)Assigns the new value to this property and fires notifications if the value is really changed.StringtoString()
-
-
-
Constructor Detail
-
Property
public Property(@NotNull T initialValue)Initializes the property with the given value.- Parameters:
initialValue- the initial value.
-
-
Method Detail
-
set
public void set(@NotNull T newValue)Assigns the new value to this property and fires notifications if the value is really changed.This method uses the equals function of the value to check whether the value differs.
- Parameters:
newValue- the new value.
-
get
@NotNull public T get()
Returns the property value.- Returns:
- the property value.
-
attachListener
public void attachListener(@NotNull Property.Listener<T> listener)Attaches the given listener.- Parameters:
listener- the listener to attach.
-
detachListener
public void detachListener(@NotNull Property.Listener<T> listener)Detaches the given listener.If the listener already was detached or was never attached - does nothing silently.
- Parameters:
listener- the listener to detach.
-
-