public class DefaultBook extends Object
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
private Book |
book
The default book
|
private BookList |
books
The list of candidate books.
|
private BookFilter |
filter
The filter against books that returns candidates.
|
private static org.slf4j.Logger |
LOGGER
The log stream
|
Constructor and Description |
---|
DefaultBook(BookList bookList,
BookFilter bookFilter) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkReplacement()
Go through all of the current books checking to see if we need to replace
the current defaults with one of these.
|
Book |
getDefault()
Get the current default book or null if there is none.
|
String |
getDefaultName()
This method is identical to
getDefault().getName() and is
only used by Config which works best with strings under reflection. |
void |
setDefault(Book newBook)
Set the default Book.
|
void |
setDefaultByName(String name)
Trawl through all the known Books satisfying the filter looking for the
one matching the given name.
|
void |
setDefaultConditionally(Book newBook)
Set the default Book conditionally.
|
protected void |
unsetDefault()
Unset the current default book and attempt to appoint another.
|
protected void |
unsetDefaultConditionally(Book oldBook)
Unset the current default book, if it matches the argument and attempt to
appoint another.
|
private Book book
private final BookList books
private final BookFilter filter
private static final org.slf4j.Logger LOGGER
public DefaultBook(BookList bookList, BookFilter bookFilter)
public void setDefault(Book newBook)
newBook
- The version to use as default.public void setDefaultConditionally(Book newBook)
newBook
- The version to use as default.protected void unsetDefault()
protected void unsetDefaultConditionally(Book oldBook)
oldBook
- the book to unset if it is the defaultpublic Book getDefault()
public String getDefaultName()
getDefault().getName()
and is
only used by Config which works best with strings under reflection.public void setDefaultByName(String name)
This method is for use with config scripts and other things that need to work with Strings. The preferred method is to use Book objects.
This method is picky in that it only matches when the driver and the version are the same. The user (probably) only cares about the version though, and so might be disappointed when we fail to match AV (FooDriver) against AV (BarDriver).
name
- The version to use as default.protected void checkReplacement()