From 60c7ea5a01c0909db3e9460de8af738ce104fdb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=9E=E5=BA=90?= <109708109+CiiLu@users.noreply.github.com> Date: Fri, 28 Aug 2026 21:59:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=20`MappedProperty`=20(#6761)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmcl/util/javafx/MappedProperty.java | 88 ------------------- 1 file changed, 88 deletions(-) delete mode 100644 HMCLCore/src/main/java/org/jackhuang/hmcl/util/javafx/MappedProperty.java diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/javafx/MappedProperty.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/javafx/MappedProperty.java deleted file mode 100644 index 2111ac33cf..0000000000 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/javafx/MappedProperty.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Hello Minecraft! Launcher - * Copyright (C) 2020 huangyuhui and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.jackhuang.hmcl.util.javafx; - -import javafx.beans.binding.Bindings; -import javafx.beans.binding.ObjectBinding; -import javafx.beans.property.Property; -import javafx.beans.property.SimpleObjectProperty; -import javafx.beans.value.ObservableValue; - -import java.util.function.Function; - -/** - * @author yushijinhun - */ -public final class MappedProperty extends SimpleObjectProperty { - - private final Property predecessor; - private final Function reservedMapper; - - private final ObjectBinding binding; - - public MappedProperty(Property predecessor, Function mapper, Function reservedMapper) { - this(null, "", predecessor, mapper, reservedMapper); - } - - public MappedProperty(Object bean, String name, Property predecessor, Function mapper, Function reservedMapper) { - super(bean, name); - this.predecessor = predecessor; - this.reservedMapper = reservedMapper; - - binding = new ObjectBinding() { - { - bind(predecessor); - } - - @Override - protected U computeValue() { - return mapper.apply(predecessor.getValue()); - } - - @Override - protected void onInvalidating() { - MappedProperty.this.fireValueChangedEvent(); - } - }; - } - - @Override - public U get() { - return binding.get(); - } - - @Override - public void set(U value) { - predecessor.setValue(reservedMapper.apply(value)); - } - - @Override - public void bind(ObservableValue observable) { - predecessor.bind(Bindings.createObjectBinding(() -> reservedMapper.apply(observable.getValue()), observable)); - } - - @Override - public void unbind() { - predecessor.unbind(); - } - - @Override - public boolean isBound() { - return predecessor.isBound(); - } -}