use of org.fagu.fmv.soft.find.FoundReason in project fmv by f-agu.
the class SoftInfoContributor method content.
// *********************************************
/**
* @return
*/
private Map<String, String> content() {
Map<String, String> map = new HashMap<>();
for (Soft soft : Softs.getInfoContributors()) {
String msg = null;
if (soft.isFound()) {
StringBuilder buf = new StringBuilder(100);
SoftInfo softInfo = soft.getFirstInfo();
if (softInfo instanceof VersionSoftInfo) {
((VersionSoftInfo) softInfo).getVersion().ifPresent(v -> buf.append(v).append(", "));
}
if (softInfo instanceof VersionDateSoftInfo) {
((VersionDateSoftInfo) softInfo).getDate().ifPresent(d -> {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
buf.append(dateFormat.format(d)).append(", ");
});
}
buf.append(soft.getFile().getAbsolutePath());
msg = buf.toString();
} else {
StringJoiner joiner = new StringJoiner(" ; ");
for (SoftFound softFound : soft.getFounds()) {
StringBuilder buf = new StringBuilder();
FoundReason foundReason = softFound != null ? softFound.getFoundReason() : FoundReasons.NOT_FOUND;
buf.append(foundReason.name());
String reason = softFound.getReason();
if (reason != null) {
buf.append(": ").append(reason);
}
joiner.add(buf.toString());
}
msg = joiner.toString();
}
map.put(soft.getName(), msg);
}
return map;
}
use of org.fagu.fmv.soft.find.FoundReason in project fmv by f-agu.
the class SoftLogger method toLine.
/**
* @param line
* @param softProvider
* @param softFound
* @param formatConsumer
*/
private void toLine(StringBuilder line, SoftProvider softProvider, SoftFound softFound, Consumer<String> formatConsumer) {
if (softFound != null) {
String info = softFound.getInfo();
if (softFound.isFound()) {
appendFile(line, softFound);
if (StringUtils.isNotBlank(info)) {
line.append(' ').append('(').append(info).append(')');
}
formatConsumer.accept(line.toString());
return;
}
appendFile(line, softFound);
FoundReason foundReason = softFound.getFoundReason();
if (foundReason == FoundReasons.BAD_VERSION) {
line.append(" (find version ").append(info != null ? info : "?").append(" but I need another version: ");
line.append(softFound.getReason()).append(')');
formatConsumer.accept(line.toString());
return;
}
String reason = softFound.getReason();
if (StringUtils.isNotBlank(reason)) {
line.append(": ").append(reason);
}
formatConsumer.accept(line.toString());
String downloadURL = softProvider.getDownloadURL();
if (StringUtils.isNotBlank(downloadURL)) {
formatConsumer.accept(" Download at: " + downloadURL);
}
String minVersion = softProvider.getMinVersion();
if (StringUtils.isNotBlank(minVersion)) {
formatConsumer.accept(" Minimum version: " + minVersion);
}
}
}
Aggregations