Verified Owner
Top Description Inners Fields Constructors Methods
org.jabref.logic.util

public Class ProgressCounter

extends Object
implements ai.djl.util.Progress
Class Inheritance
Imports
java.time.Duration, .Instant, java.util.List, java.util.concurrent.Executors, .ScheduledExecutorService, .ThreadFactory, .TimeUnit, javafx.beans.property.IntegerProperty, .ReadOnlyStringProperty, .SimpleIntegerProperty, .SimpleStringProperty, .StringProperty, org.jabref.logic.l10n.Localization, ai.djl.util.Progress

Convenient class for managing ETA for background tasks.

Always call ProgressCounter#stop() when your task is done, because there is a background timer that periodically updates the ETA.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
private final StringProperty
private static final Duration
private final ScheduledExecutorService
private static final List<ProgressCounter.ProgressMessage>
private final IntegerProperty
private final IntegerProperty
private final Instant

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
end()

public String
public int
public int
public void
increaseWorkDone(int incr)

public void
increaseWorkMax(int incr)

public void
increment(long increment)

public void
public ReadOnlyStringProperty
public void
reset(String message, long max, String trailingMessage)

public void
start(long initialProgress)

public void
stop()

private void
public void
update(long progress, String message)

private void
public IntegerProperty
public IntegerProperty
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

messageback to summary
private final StringProperty message
PERIODIC_UPDATE_DURATIONback to summary
private static final Duration PERIODIC_UPDATE_DURATION
periodicUpdateback to summary
private final ScheduledExecutorService periodicUpdate
PROGRESS_MESSAGESback to summary
private static final List<ProgressCounter.ProgressMessage> PROGRESS_MESSAGES
workDoneback to summary
private final IntegerProperty workDone
workMaxback to summary
private final IntegerProperty workMax
workStartTimeback to summary
private final Instant workStartTime

Constructor Detail

ProgressCounterback to summary
public ProgressCounter()

Method Detail

endback to summary
public void end()
Annotations
@Override
getMessageback to summary
public String getMessage()
getWorkDoneback to summary
public int getWorkDone()
getWorkMaxback to summary
public int getWorkMax()
increaseWorkDoneback to summary
public void increaseWorkDone(int incr)
increaseWorkMaxback to summary
public void increaseWorkMax(int incr)
incrementback to summary
public void increment(long increment)
Annotations
@Override
listenToAllPropertiesback to summary
public void listenToAllProperties(Runnable runnable)
messagePropertyback to summary
public ReadOnlyStringProperty messageProperty()
resetback to summary
public void reset(String message, long max, String trailingMessage)
Annotations
@Override
startback to summary
public void start(long initialProgress)
Annotations
@Override
stopback to summary
public void stop()
updateback to summary
private void update()
updateback to summary
public void update(long progress, String message)
Annotations
@Override
updateMessageback to summary
private void updateMessage(Duration eta)
workDonePropertyback to summary
public IntegerProperty workDoneProperty()
workMaxPropertyback to summary
public IntegerProperty workMaxProperty()
org.jabref.logic.util back to summary

private final Record ProgressCounter.ProgressMessage

extends Record
Class Inheritance
Record Components
maxTime:int 
message:String 

Field Summary

Modifier and TypeField and Description
private final int
maxTime

Record Component accessed by maxTime().

private final String
message

Record Component accessed by message().

Constructor Summary

AccessConstructor and Description
private
ProgressMessage(int maxTime, String message)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public int
maxTime()

Record Component getter of maxTime.

public String
message()

Record Component getter of message.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

maxTimeback to summary
private final int maxTime

Record Component accessed by maxTime().

messageback to summary
private final String message

Record Component accessed by message().

Constructor Detail

ProgressMessageback to summary
private ProgressMessage(int maxTime, String message)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

maxTimeback to summary
public int maxTime()

Record Component getter of maxTime.

messageback to summary
public String message()

Record Component getter of message.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.