diff options
author | Brian Vosburgh | 2016-07-13 14:34:41 +0000 |
---|---|---|
committer | Brian Vosburgh | 2017-05-18 22:37:48 +0000 |
commit | 12501aae35bc90a6847f33a925a5dde09510801d (patch) | |
tree | ae3f9f30e6ada30a9f6d6098c4127f046adf106a /common/plugins | |
parent | c06255a0b27d949afea7c27a528e2fb913908eca (diff) | |
download | webtools.dali-12501aae35bc90a6847f33a925a5dde09510801d.tar.gz webtools.dali-12501aae35bc90a6847f33a925a5dde09510801d.tar.xz webtools.dali-12501aae35bc90a6847f33a925a5dde09510801d.zip |
move some composite boolean PVM static methods
Diffstat (limited to 'common/plugins')
3 files changed, 103 insertions, 99 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java index 33fdf4af61..7d60bb9d9e 100644 --- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java +++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java @@ -27,7 +27,6 @@ import org.eclipse.jpt.common.ui.internal.swt.TriStateCheckBoxModelAdapter; import org.eclipse.jpt.common.ui.internal.swt.bindings.SWTBindingTools; import org.eclipse.jpt.common.ui.internal.swt.events.DisposeAdapter; import org.eclipse.jpt.common.ui.internal.swt.listeners.SWTListenerTools; -import org.eclipse.jpt.common.utility.internal.model.value.CollectionValueModelTools; import org.eclipse.jpt.common.utility.internal.model.value.PropertyValueModelTools; import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel; import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools; @@ -324,7 +323,7 @@ public abstract class Pane<T extends Model> { private static PropertyValueModel<Boolean> andEnabledModel(Pane<?> pane, PropertyValueModel<Boolean> enabledModel) { enabledModel = buildNonNullModel(enabledModel); // NB: we fetch private state from the pane - return (pane == null) ? enabledModel : CollectionValueModelTools.and(pane.enabledModel, enabledModel); + return (pane == null) ? enabledModel : PropertyValueModelTools.and(pane.enabledModel, enabledModel); } /** diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionValueModelTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionValueModelTools.java index a8a6934eef..42b64d2103 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionValueModelTools.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionValueModelTools.java @@ -14,7 +14,6 @@ import java.util.Collection; import org.eclipse.jpt.common.utility.closure.Closure; import org.eclipse.jpt.common.utility.internal.closure.BooleanClosure; import org.eclipse.jpt.common.utility.internal.closure.ClosureTools; -import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter; import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools; import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel; @@ -157,78 +156,8 @@ public final class CollectionValueModelTools { * otherwise its value is {@link Boolean#FALSE}. * The model's default value, when it contains no nested models, is {@link Boolean#TRUE}. */ - @SafeVarargs - public static PropertyValueModel<Boolean> and(PropertyValueModel<Boolean>... models) { - return compositePropertyValueModel(AND_TRANSFORMER, models); - } - - /** - * Construct a boolean property value model that is a composite AND of the - * specified boolean property value models; i.e. the model's value is {@link Boolean#TRUE} - * if all the contained models' values are {@link Boolean#TRUE}, - * otherwise its value is {@link Boolean#FALSE}. - * The model's default value, when it contains no nested models, is {@link Boolean#TRUE}. - */ - public static PropertyValueModel<Boolean> and(Collection<? extends PropertyValueModel<Boolean>> models) { - return compositePropertyValueModel(models, AND_TRANSFORMER); - } - - /** - * Construct a boolean property value model that is a composite AND of the - * specified boolean property value models; i.e. the model's value is {@link Boolean#TRUE} - * if all the contained models' values are {@link Boolean#TRUE}, - * otherwise its value is {@link Boolean#FALSE}. - * The model's default value, when it contains no nested models, is {@link Boolean#TRUE}. - */ public static PropertyValueModel<Boolean> and(CollectionValueModel<? extends PropertyValueModel<Boolean>> collectionModel) { - return compositePropertyValueModel(collectionModel, AND_TRANSFORMER); - } - - /** - * @see AndTransformer - */ - public static final Transformer<Collection<Boolean>, Boolean> AND_TRANSFORMER = new AndTransformer(); - - /** - * A transformer that transforms a collection of {@link Boolean}s into a single - * {@link Boolean} by ANDing them together. Its default value is {@link Boolean#TRUE}. - * @see #and(CollectionValueModel) - */ - public static final class AndTransformer - extends TransformerAdapter<Collection<Boolean>, Boolean> - { - @Override - public Boolean transform(Collection<Boolean> booleans) { - for (Boolean b : booleans) { - if ( ! b.booleanValue()) { - return Boolean.FALSE; - } - } - return Boolean.TRUE; - } - } - - /** - * Construct a boolean property value model that is a composite OR of the - * specified boolean property value models; i.e. the model's value is {@link Boolean#FALSE} - * if all the contained models' values are {@link Boolean#FALSE}, - * otherwise its value is {@link Boolean#TRUE}. - * The model's default value, when it contains no nested models, is {@link Boolean#FALSE}. - */ - @SafeVarargs - public static PropertyValueModel<Boolean> or(PropertyValueModel<Boolean>... models) { - return compositePropertyValueModel(OR_TRANSFORMER, models); - } - - /** - * Construct a boolean property value model that is a composite OR of the - * specified boolean property value models; i.e. the model's value is {@link Boolean#FALSE} - * if all the contained models' values are {@link Boolean#FALSE}, - * otherwise its value is {@link Boolean#TRUE}. - * The model's default value, when it contains no nested models, is {@link Boolean#FALSE}. - */ - public static PropertyValueModel<Boolean> or(Collection<? extends PropertyValueModel<Boolean>> models) { - return compositePropertyValueModel(models, OR_TRANSFORMER); + return compositePropertyValueModel(collectionModel, PropertyValueModelTools.AND_TRANSFORMER); } /** @@ -239,31 +168,7 @@ public final class CollectionValueModelTools { * The model's default value, when it contains no nested models, is {@link Boolean#FALSE}. */ public static PropertyValueModel<Boolean> or(CollectionValueModel<? extends PropertyValueModel<Boolean>> collectionModel) { - return compositePropertyValueModel(collectionModel, OR_TRANSFORMER); - } - - /** - * @see OrTransformer - */ - public static final Transformer<Collection<Boolean>, Boolean> OR_TRANSFORMER = new OrTransformer(); - - /** - * A transformer that transforms a collection of {@link Boolean}s into a single - * {@link Boolean} by ORing them together. Its default value is {@link Boolean#FALSE}. - * @see #or(CollectionValueModel) - */ - public static final class OrTransformer - extends TransformerAdapter<Collection<Boolean>, Boolean> - { - @Override - public Boolean transform(Collection<Boolean> booleans) { - for (Boolean b : booleans) { - if (b.booleanValue()) { - return Boolean.TRUE; - } - } - return Boolean.FALSE; - } + return compositePropertyValueModel(collectionModel, PropertyValueModelTools.OR_TRANSFORMER); } diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelTools.java index 058294e03c..8141d8ed6e 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelTools.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelTools.java @@ -9,9 +9,12 @@ ******************************************************************************/ package org.eclipse.jpt.common.utility.internal.model.value; +import java.util.Collection; import org.eclipse.jpt.common.utility.closure.Closure; import org.eclipse.jpt.common.utility.internal.predicate.PredicateTools; +import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter; import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools; +import org.eclipse.jpt.common.utility.model.value.CollectionValueModel; import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel; import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; import org.eclipse.jpt.common.utility.predicate.Predicate; @@ -244,6 +247,103 @@ public final class PropertyValueModelTools { } + // ********** Composite boolean adapters ********** + + /** + * Construct a boolean property value model that is a composite AND of the + * specified boolean property value models; i.e. the model's value is {@link Boolean#TRUE} + * if all the contained models' values are {@link Boolean#TRUE}, + * otherwise its value is {@link Boolean#FALSE}. + * The model's default value, when it contains no nested models, is {@link Boolean#TRUE}. + */ + @SafeVarargs + public static PropertyValueModel<Boolean> and(PropertyValueModel<Boolean>... models) { + return CollectionValueModelTools.compositePropertyValueModel(AND_TRANSFORMER, models); + } + + /** + * Construct a boolean property value model that is a composite AND of the + * specified boolean property value models; i.e. the model's value is {@link Boolean#TRUE} + * if all the contained models' values are {@link Boolean#TRUE}, + * otherwise its value is {@link Boolean#FALSE}. + * The model's default value, when it contains no nested models, is {@link Boolean#TRUE}. + */ + public static PropertyValueModel<Boolean> and(Collection<? extends PropertyValueModel<Boolean>> models) { + return CollectionValueModelTools.compositePropertyValueModel(models, AND_TRANSFORMER); + } + + /** + * @see AndTransformer + */ + public static final Transformer<Collection<Boolean>, Boolean> AND_TRANSFORMER = new AndTransformer(); + + /** + * A transformer that transforms a collection of {@link Boolean}s into a single + * {@link Boolean} by ANDing them together. Its default value is {@link Boolean#TRUE}. + * @see CollectionValueModelTools#and(CollectionValueModel) + */ + public static final class AndTransformer + extends TransformerAdapter<Collection<Boolean>, Boolean> + { + @Override + public Boolean transform(Collection<Boolean> booleans) { + for (Boolean b : booleans) { + if ( ! b.booleanValue()) { + return Boolean.FALSE; + } + } + return Boolean.TRUE; + } + } + + /** + * Construct a boolean property value model that is a composite OR of the + * specified boolean property value models; i.e. the model's value is {@link Boolean#FALSE} + * if all the contained models' values are {@link Boolean#FALSE}, + * otherwise its value is {@link Boolean#TRUE}. + * The model's default value, when it contains no nested models, is {@link Boolean#FALSE}. + */ + @SafeVarargs + public static PropertyValueModel<Boolean> or(PropertyValueModel<Boolean>... models) { + return CollectionValueModelTools.compositePropertyValueModel(OR_TRANSFORMER, models); + } + + /** + * Construct a boolean property value model that is a composite OR of the + * specified boolean property value models; i.e. the model's value is {@link Boolean#FALSE} + * if all the contained models' values are {@link Boolean#FALSE}, + * otherwise its value is {@link Boolean#TRUE}. + * The model's default value, when it contains no nested models, is {@link Boolean#FALSE}. + */ + public static PropertyValueModel<Boolean> or(Collection<? extends PropertyValueModel<Boolean>> models) { + return CollectionValueModelTools.compositePropertyValueModel(models, OR_TRANSFORMER); + } + + /** + * @see OrTransformer + */ + public static final Transformer<Collection<Boolean>, Boolean> OR_TRANSFORMER = new OrTransformer(); + + /** + * A transformer that transforms a collection of {@link Boolean}s into a single + * {@link Boolean} by ORing them together. Its default value is {@link Boolean#FALSE}. + * @see CollectionValueModelTools#or(CollectionValueModel) + */ + public static final class OrTransformer + extends TransformerAdapter<Collection<Boolean>, Boolean> + { + @Override + public Boolean transform(Collection<Boolean> booleans) { + for (Boolean b : booleans) { + if (b.booleanValue()) { + return Boolean.TRUE; + } + } + return Boolean.FALSE; + } + } + + // ********** filtering wrappers ********** /** |