Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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