Skip to main content
summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorBrian Vosburgh2016-07-28 16:52:37 +0000
committerBrian Vosburgh2017-05-18 22:38:29 +0000
commit30568218f5d0545034d1a8430aee7f57c29f9295 (patch)
tree70094ce60879fcfec913a333d4e51e9b2b654381 /common
parent9dde5df7730bbd223d8a6b257226aa6a77e7d4e7 (diff)
downloadwebtools.dali-30568218f5d0545034d1a8430aee7f57c29f9295.tar.gz
webtools.dali-30568218f5d0545034d1a8430aee7f57c29f9295.tar.xz
webtools.dali-30568218f5d0545034d1a8430aee7f57c29f9295.zip
add PropertyValueModelTools.modelAspectAdapter(...)
Diffstat (limited to 'common')
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelTools.java42
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticPropertyValueModel.java10
2 files changed, 47 insertions, 5 deletions
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 f95fe94520..0c23168973 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
@@ -937,6 +937,37 @@ public final class PropertyValueModelTools {
/**
* Construct a model property aspect adapter for the
+ * specified subject, aspect name, and transformer.
+ * <p>
+ * <strong>NB:</strong>
+ * The specified transformer will <em>never</em> be passed a <code>null</code> subject.
+ * Instead, a <code>null</code> subject will be transformed into a <code>null</code> value.
+ */
+ public static <V, S extends Model> PropertyValueModel<V> modelAspectAdapter(
+ S subject,
+ String aspectName,
+ Transformer<? super S, ? extends V> transformer
+ ) {
+ return modelAspectAdapter(staticPropertyValueModel(subject), aspectName, transformer);
+ }
+
+ /**
+ * Construct a model property aspect adapter for the
+ * specified subject, aspect name, and transformer.
+ * <p>
+ * <strong>NB:</strong>
+ * The specified transformer must be able to handle a <code>null</code> subject.
+ */
+ public static <V, S extends Model> PropertyValueModel<V> modelAspectAdapter_(
+ S subject,
+ String aspectName,
+ Transformer<? super S, ? extends V> transformer
+ ) {
+ return modelAspectAdapter_(staticPropertyValueModel(subject), aspectName, transformer);
+ }
+
+ /**
+ * Construct a model property aspect adapter for the
* specified subject model, aspect name, and transformer.
* <p>
* <strong>NB:</strong>
@@ -1165,11 +1196,22 @@ public final class PropertyValueModelTools {
* Construct property value model that can be used for
* returning a static value, but still allows listeners to be added.
* Listeners will <em>never</em> be notified of any changes, because there should be none.
+ *
+ * @see #simpleModel(Object)
*/
public static <V> PropertyValueModel<V> staticPropertyValueModel(V value) {
return new StaticPropertyValueModel<>(value);
}
+ /**
+ * Construct a simple property value model that has the specified value.
+ *
+ * @see #staticPropertyValueModel(Object)
+ */
+ public static <V> ModifiablePropertyValueModel<V> simpleModel(V value) {
+ return new SimplePropertyValueModel<>(value);
+ }
+
// ********** value transformers/closures **********
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticPropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticPropertyValueModel.java
index 53d1d5f89a..eb7f0257a8 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticPropertyValueModel.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticPropertyValueModel.java
@@ -18,12 +18,12 @@ import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
* returning a static value, but still allows listeners to be added.
* Listeners will <em>never</em> be notified of any changes, because there should be none.
*/
-public class StaticPropertyValueModel<T>
+public class StaticPropertyValueModel<V>
extends AbstractModel
- implements PropertyValueModel<T>, Serializable
+ implements PropertyValueModel<V>, Serializable
{
/** The value. */
- protected final T value;
+ protected final V value;
private static final long serialVersionUID = 1L;
@@ -31,12 +31,12 @@ public class StaticPropertyValueModel<T>
/**
* Construct a static property value model for the specified value.
*/
- public StaticPropertyValueModel(T value) {
+ public StaticPropertyValueModel(V value) {
super();
this.value = value;
}
- public T getValue() {
+ public V getValue() {
return this.value;
}

Back to the top