本文整理匯總了Java中xdean.jex.util.cache.CacheUtil.cache方法的典型用法代碼示例。如果您正苦於以下問題:Java CacheUtil.cache方法的具體用法?Java CacheUtil.cache怎麽用?Java CacheUtil.cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xdean.jex.util.cache.CacheUtil
的用法示例。
在下文中一共展示了CacheUtil.cache方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTasks
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
public List<Function<String, Paint>> getTasks() {
return CacheUtil.cache(CSSPaintPaser.class, () -> Arrays.asList(
text -> Color.web(text, 1),
text -> LinearGradient.valueOf(text),
text -> RadialGradient.valueOf(text),
text -> context.lookup(text),
text -> DeriveColorConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
text -> LadderConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
text -> LinearGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault()),
text -> RadialGradientConverter.getInstance().convert(factory.apply(text), Font.getDefault())
));
}
示例2: seriesTimeThen
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
/**
* @param uniqueKey unique key
* @param r the task
* @param then (this time, total time) -> {...}
*/
public static void seriesTimeThen(Object uniqueKey, Runnable r, BiConsumer<Long, Long> then) {
Stopwatch total = CacheUtil.cache(TimingUtil.class, uniqueKey, () -> Stopwatch.createUnstarted());
Stopwatch temp = getShareStopwatch();
temp.reset();
temp.start();
total.start();
r.run();
temp.stop();
total.stop();
if (then != null) {
then.accept(temp.elapsed(TimeUnit.MILLISECONDS), total.elapsed(TimeUnit.MILLISECONDS));
}
}
示例3: TabEntity
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
TabEntity() {
this.tab = new Tab();
this.manager = new CodeAreaManager(new CodeArea());
this.codeArea = manager.getCodeArea();
this.file = new SimpleObjectProperty<>();
this.name = new SimpleStringProperty();
this.icon = new FontAwesomeIconView();
this.order = new SimpleIntegerProperty(nameOrder.next());
init();
CacheUtil.cache(MainFrameController.this, tab, () -> this);
}
示例4: init
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
private void init() {
// name
name.bind(Bindings.when(file.isNull())
.then(Bindings.createStringBinding(() -> "new" + order.get(), order))
.otherwise(toStringBinding(map(file, f -> f.getName()))));
// graphics
tab.setGraphic(icon);
icon.setStyleClass("tab-icon");
icon.setIcon(FontAwesomeIcon.SAVE);
// Hold the object in cache to avoid gc
StringBinding state = CacheUtil.cache(this, "state",
() -> Bindings.when(Bindings.equal(toObjectBinding(currentTabEntity()), this))
.then(Bindings.when(manager.modifiedProperty())
.then("selected-modified")
.otherwise("selected"))
.otherwise(Bindings.when(manager.modifiedProperty())
.then("modified")
.otherwise("")));
state.addListener((ob, o, n) -> {
uncatch(() -> icon.pseudoClassStateChanged(PseudoClass.getPseudoClass(o), false));
uncatch(() -> icon.pseudoClassStateChanged(PseudoClass.getPseudoClass(n), true));
});
// recent
file.addListener((ob, o, n) -> todoAll(
() -> ifThat(n != null).todo(() -> recentSupport.setLastFile(n)),
() -> ifThat(o == null && n != null).todo(() -> releaseName())
));
}
示例5: currentTabEntity
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
private ObservableValue<TabEntity> currentTabEntity() {
return CacheUtil.cache(this, "currentTabEntity", () -> {
ObjectProperty<TabEntity> op = new SimpleObjectProperty<>();
op.bind(map(tabPane.getSelectionModel().selectedIndexProperty(),
i -> uncatch(() -> tabList.get(i.intValue()))));
return op;
});
}
示例6: currentCodeArea
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
private ObservableValue<CodeArea> currentCodeArea() {
return CacheUtil.cache(this, "currentCodeArea", () -> {
ObjectProperty<CodeArea> op = new SimpleObjectProperty<CodeArea>();
op.bind(map(currentManager(), m -> uncatch(() -> m.getCodeArea())));
return op;
});
}
示例7: getShareStopwatch
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
private static Stopwatch getShareStopwatch() {
Stopwatch share = CacheUtil.cache(TimingUtil.class, Thread.currentThread(), () -> Stopwatch.createUnstarted());
return share.isRunning() ? Stopwatch.createUnstarted() : share;
}
示例8: getTasks
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
public List<Function<String, Border>> getTasks() {
return CacheUtil.cache(CSSPaintPaser.class, () -> Arrays.asList(
));
}
示例9: modifiedProperty
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
private ObservableValue<Boolean> modifiedProperty() {
return CacheUtil.cache(this, "modified", () -> nestValue(currentManager(), m -> m.modifiedProperty()));
}
示例10: currentFile
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
private ObservableValue<File> currentFile() {
return CacheUtil.cache(this, "currentFile", () -> nestValue(currentTabEntity(), t -> t.file));
}
示例11: currentManager
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
private ObservableValue<CodeAreaManager> currentManager() {
return CacheUtil.cache(this, "currentManager", () -> map(currentTabEntity(), t -> t.manager));
}
示例12: getChildren
import xdean.jex.util.cache.CacheUtil; //導入方法依賴的package包/類
public List<Either<Option<?>, OptionGroup>> getChildren() {
return CacheUtil.cache(this, () -> Collections.unmodifiableList(list));
}