Top Description Fields Constructors Methods
com.dlsc.preferencesfx.history

public Class Change<P>

extends Object
Class Inheritance
Type Parameters
<P>
the data type of the change, which is reflected in a ListProperty for a list change and in a ObjectProperty for regular changes as well
Imports
com.dlsc.preferencesfx.model.Setting, java.time.LocalDateTime, java.time.format.DateTimeFormatter, .FormatStyle, java.util.Arrays, .Objects, java.util.concurrent.Callable, javafx.beans.binding.Bindings, javafx.beans.property.BooleanProperty, .ListProperty, .ObjectProperty, .ReadOnlyBooleanProperty, .ReadOnlyListProperty, .ReadOnlyObjectProperty, .SimpleBooleanProperty, .SimpleListProperty, .SimpleObjectProperty, javafx.collections.FXCollections, .ObservableList, org.slf4j.Logger, .LoggerFactory

Represents a change, which is comprised of a new and an old value.

Implementation Note

There are two types: List changes and regular changes. Internally, all changes are saved into a ListProperty for the old and the new value, regardless of the type of change. However, if two ObservableList are used to create a change, a boolean flags the change as a list change. In case of a regular change, a binding will also set an ObjectProperty for easier handling.

Authors
François Martin, Marco Sanfratello

Field Summary

Modifier and TypeField and Description
private final BooleanProperty
private static final Logger
private final ListProperty<P>
private final ObjectProperty<P>
private final ListProperty<P>
private final ObjectProperty<P>
protected final Setting<E extends Element<E extends Element<E>>, P extends Property<T>>
private final LocalDateTime

Constructor Summary

AccessConstructor and Description
protected
Change(Setting<E extends Element<E extends Element<E>>, P extends Property<T>>
the setting that was changed
setting
,
boolean
true if this is a list change
listChange
)

Constructs a generalized change.

public
Change(Setting<E extends Element<E extends Element<E>>, P extends Property<T>>
the setting that was changed
setting
,
ObservableList<P>
the "before" value(s) of the change
oldList
,
ObservableList<P>
the "after" value(s) of the change
newList
)

Constructs a list change.

public
Change(Setting<E extends Element<E extends Element<E>>, P extends Property<T>>
the setting that was changed
setting
,
P
the "before" value of the change
oldValue
,
P
the "after" value of the change
newValue
)

Constructs a regular object change.

Method Summary

Modifier and TypeMethod and Description
private Callable<V>

Returns:

Callable function, which binds a list to an object property.
createListToObjectBinding
(ListProperty<P>
to be bound to the object property
listProperty
)

Creates a function, which handles binding between a ListProperty and an ObjectProperty.

public ObservableList<P>
public P
public ObservableList<P>
public P
public Setting<E extends Element<E extends Element<E>>, P extends Property<T>>
public String
public boolean
public boolean

Returns:

true if redundant, else if otherwise.
isRedundant
()

Compares newValue and oldValue to see if they are the same.

public ReadOnlyBooleanProperty
public ReadOnlyListProperty<P>
public ReadOnlyObjectProperty<P>
public ReadOnlyListProperty<P>
public ReadOnlyObjectProperty<P>
public void
redo()

Redos a change.

public void
public void
setNewValue(P newValue)

private void
public void
undo()

Undos a change.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

listChangeback to summary
private final BooleanProperty listChange
LOGGERback to summary
private static final Logger LOGGER
newListback to summary
private final ListProperty<P> newList
newValueback to summary
private final ObjectProperty<P> newValue
oldListback to summary
private final ListProperty<P> oldList
oldValueback to summary
private final ObjectProperty<P> oldValue
settingback to summary
protected final Setting<E extends Element<E extends Element<E>>, P extends Property<T>> setting
timestampback to summary
private final LocalDateTime timestamp

Constructor Detail

Changeback to summary
protected Change(Setting<E extends Element<E extends Element<E>>, P extends Property<T>> setting, boolean listChange)

Constructs a generalized change.

Parameters
setting:Setting<E extends Element<E extends Element<E>>, P extends Property<T>>

the setting that was changed

listChange:boolean

true if this is a list change

Changeback to summary
public Change(Setting<E extends Element<E extends Element<E>>, P extends Property<T>> setting, ObservableList<P> oldList, ObservableList<P> newList)

Constructs a list change.

Parameters
setting:Setting<E extends Element<E extends Element<E>>, P extends Property<T>>

the setting that was changed

oldList:ObservableList<P>

the "before" value(s) of the change

newList:ObservableList<P>

the "after" value(s) of the change

Changeback to summary
public Change(Setting<E extends Element<E extends Element<E>>, P extends Property<T>> setting, P oldValue, P newValue)

Constructs a regular object change.

Parameters
setting:Setting<E extends Element<E extends Element<E>>, P extends Property<T>>

the setting that was changed

oldValue:P

the "before" value of the change

newValue:P

the "after" value of the change

Method Detail

createListToObjectBindingback to summary
private Callable<V> createListToObjectBinding(ListProperty<P> listProperty)

Creates a function, which handles binding between a ListProperty and an ObjectProperty.

If this change isn't a list change, oldValue and newValue properties will have the single element inside of the list, for easier usage.

Parameters
listProperty:ListProperty<P>

to be bound to the object property

Returns:Callable<V>

Callable function, which binds a list to an object property.

getNewListback to summary
public ObservableList<P> getNewList()
getNewValueback to summary
public P getNewValue()
getOldListback to summary
public ObservableList<P> getOldList()
getOldValueback to summary
public P getOldValue()
getSettingback to summary
public Setting<E extends Element<E extends Element<E>>, P extends Property<T>> getSetting()
getTimestampback to summary
public String getTimestamp()
isListChangeback to summary
public boolean isListChange()
isRedundantback to summary
public boolean isRedundant()

Compares newValue and oldValue to see if they are the same. If this is the case, this change is redundant, since it doesn't represent a true change. This can happen on compounded changes.

Returns:boolean

true if redundant, else if otherwise.

listChangePropertyback to summary
public ReadOnlyBooleanProperty listChangeProperty()
newListPropertyback to summary
public ReadOnlyListProperty<P> newListProperty()
newValuePropertyback to summary
public ReadOnlyObjectProperty<P> newValueProperty()
oldListPropertyback to summary
public ReadOnlyListProperty<P> oldListProperty()
oldValuePropertyback to summary
public ReadOnlyObjectProperty<P> oldValueProperty()
redoback to summary
public void redo()

Redos a change. Does this by setting the corresponding value of the Setting to the new value of this change.

setNewListback to summary
public void setNewList(ObservableList<P> newList)
setNewValueback to summary
public void setNewValue(P newValue)
setupBindingsback to summary
private void setupBindings()
undoback to summary
public void undo()

Undos a change. Does this by setting the corresponding value of the Setting to the old value of this change.