diff options
author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2019-04-13 12:17:14 -0400 |
---|---|---|
committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2019-04-13 12:17:14 -0400 |
commit | e0c5021a9ba85debf0c0722d78f75a0dbcc8376b (patch) | |
tree | fff7da15995839b099f1e5b66111e94da9b9b3b2 /src/org/unitConverter/converterGUI/MutablePredicate.java | |
parent | 8e613844ae19a4dea2089ac34c1f0ae650eaeae7 (diff) |
Implemented the dimension-based converter.
Also added a search box list, and fixed a bug with dimension exponentiation.
Diffstat (limited to 'src/org/unitConverter/converterGUI/MutablePredicate.java')
-rw-r--r-- | src/org/unitConverter/converterGUI/MutablePredicate.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/org/unitConverter/converterGUI/MutablePredicate.java b/src/org/unitConverter/converterGUI/MutablePredicate.java new file mode 100644 index 0000000..157903c --- /dev/null +++ b/src/org/unitConverter/converterGUI/MutablePredicate.java @@ -0,0 +1,60 @@ +/** + * Copyright (C) 2019 Adrien Hopkins + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package org.unitConverter.converterGUI; + +import java.util.function.Predicate; + +/** + * A container for a predicate, which can be changed later. + * + * @author Adrien Hopkins + * @since 2019-04-13 + */ +final class MutablePredicate<T> implements Predicate<T> { + private Predicate<T> predicate; + + /** + * Creates the {@code MutablePredicate}. + * + * @since 2019-04-13 + */ + public MutablePredicate(final Predicate<T> predicate) { + this.predicate = predicate; + } + + /** + * @return predicate + * @since 2019-04-13 + */ + public final Predicate<T> getPredicate() { + return this.predicate; + } + + /** + * @param predicate + * new value of predicate + * @since 2019-04-13 + */ + public final void setPredicate(final Predicate<T> predicate) { + this.predicate = predicate; + } + + @Override + public boolean test(final T t) { + return this.predicate.test(t); + } +} |