Skip to main content
summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorBrian Vosburgh2016-08-05 19:41:01 +0000
committerBrian Vosburgh2017-05-18 22:38:46 +0000
commit483d225def0875941fba5cef7642cde054271465 (patch)
treeeb24c8ddccc332839661eca472904093d86f6a77 /common
parente5a4e77cd675678804ddccfbbba377f5dee8e299 (diff)
downloadwebtools.dali-483d225def0875941fba5cef7642cde054271465.tar.gz
webtools.dali-483d225def0875941fba5cef7642cde054271465.tar.xz
webtools.dali-483d225def0875941fba5cef7642cde054271465.zip
aspect adapters 2016-08-05
Diffstat (limited to 'common')
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF15
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/BooleanSetClosureAdapter.java2
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/IntSetClosureAdapter.java31
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelTools.java204
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerTools.java11
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntObjectTransformerAdapter.java45
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntTransformerAdapter.java31
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntegerIntTransformerAdapter.java45
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/BooleanSetClosure.java6
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/IntSetClosure.java32
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/transformer/IntTransformer.java32
11 files changed, 446 insertions, 8 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF
index ab1726a452..56f1df4976 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF
@@ -28,7 +28,7 @@ Export-Package: org.eclipse.jpt.common.utility,
org.eclipse.jpt.jpa.gen,
org.eclipse.jpt.jpa.annotate,
org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.collection;
+ org.eclipse.jpt.common.utility.internal.closure;
x-friends:="org.eclipse.jpt.jpa.core,
org.eclipse.jpt.common.core,
org.eclipse.jpt.common.ui,
@@ -40,7 +40,7 @@ Export-Package: org.eclipse.jpt.common.utility,
org.eclipse.jpt.jpa.annotate,
org.eclipse.jpt.jpa.ui,
org.eclipse.jpt.jaxb.core.schemagen",
- org.eclipse.jpt.common.utility.internal.closure;
+ org.eclipse.jpt.common.utility.internal.collection;
x-friends:="org.eclipse.jpt.jpa.core,
org.eclipse.jpt.common.core,
org.eclipse.jpt.common.ui,
@@ -297,6 +297,17 @@ Export-Package: org.eclipse.jpt.common.utility,
org.eclipse.jpt.jpa.gen,
org.eclipse.jpt.jpa.annotate,
org.eclipse.jpt.jpa.ui",
+ org.eclipse.jpt.common.utility.internal.transformer.int_;
+ x-friends:="org.eclipse.jpt.common.core,
+ org.eclipse.jpt.common.ui,
+ org.eclipse.jpt.jaxb.core,
+ org.eclipse.jpt.jaxb.ui,
+ org.eclipse.jpt.jpa.core,
+ org.eclipse.jpt.jpa.db,
+ org.eclipse.jpt.jpa.db.ui,
+ org.eclipse.jpt.jpa.gen,
+ org.eclipse.jpt.jpa.annotate,
+ org.eclipse.jpt.jpa.ui",
org.eclipse.jpt.common.utility.io,
org.eclipse.jpt.common.utility.iterable,
org.eclipse.jpt.common.utility.model,
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/BooleanSetClosureAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/BooleanSetClosureAdapter.java
index d1c2156d38..928d784619 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/BooleanSetClosureAdapter.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/BooleanSetClosureAdapter.java
@@ -13,7 +13,7 @@ import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.model.BooleanSetClosure;
/**
- * Convenience boolean "set" closure that does nothing.
+ * Convenience <code>boolean</code> "set" closure that does nothing.
*
* @param <M> the type of the model (i.e. first object) passed to the closure
*/
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/IntSetClosureAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/IntSetClosureAdapter.java
new file mode 100644
index 0000000000..11ae2784e3
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/IntSetClosureAdapter.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.utility.internal.model;
+
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.model.IntSetClosure;
+
+/**
+ * Convenience <code>int</code> "set" closure that does nothing.
+ *
+ * @param <M> the type of the model (i.e. first object) passed to the closure
+ */
+public class IntSetClosureAdapter<M>
+ implements IntSetClosure<M>
+{
+ public void execute(M model, int value) {
+ // NOP
+ }
+
+ @Override
+ public String toString() {
+ return ObjectTools.toString(this);
+ }
+}
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 a0510365b0..bbc08efd6d 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
@@ -20,11 +20,13 @@ 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.BooleanSetClosure;
+import org.eclipse.jpt.common.utility.model.IntSetClosure;
import org.eclipse.jpt.common.utility.model.Model;
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;
+import org.eclipse.jpt.common.utility.transformer.IntTransformer;
import org.eclipse.jpt.common.utility.transformer.Transformer;
/**
@@ -888,7 +890,48 @@ public final class PropertyValueModelTools {
}
/**
- * Construct a "set" bi-closure that wraps a boolean "set" closure and
+ * Construct a "set" bi-closure that wraps an <code>int</code> "set" closure and
+ * forwards its arguments to it, converting the {@link Integer} to
+ * an <code>int</code>.
+ *
+ * @param <S> the type of the "set" closure's "target" object
+ */
+ public static <S> BiClosure<S, Integer> intSetBiClosureAdapter(IntSetClosure<? super S> closure) {
+ return new IntSetBiClosureAdapter<>(closure);
+ }
+
+ /**
+ * "Set" bi-closure that wraps an <code>int</code> "set" closure and
+ * forwards its arguments to it, converting the {@link Integer} to
+ * an <code>int</code>.
+ *
+ * @param <S> the type of the "set" closure's "target" object
+ */
+ public static final class IntSetBiClosureAdapter<S>
+ implements BiClosure<S, Integer>
+ {
+ private final IntSetClosure<? super S> closure;
+
+ public IntSetBiClosureAdapter(IntSetClosure<? super S> closure) {
+ super();
+ if (closure == null) {
+ throw new NullPointerException();
+ }
+ this.closure = closure;
+ }
+
+ public void execute(S subject, Integer value) {
+ this.closure.execute(subject, value.intValue());
+ }
+
+ @Override
+ public String toString() {
+ return ObjectTools.toString(this, this.closure);
+ }
+ }
+
+ /**
+ * Construct a "set" bi-closure that wraps a <code>boolean</code> "set" closure and
* forwards its arguments to it, converting the {@link Boolean} to
* a <code>boolean</code>.
*
@@ -899,7 +942,7 @@ public final class PropertyValueModelTools {
}
/**
- * "Set" bi-closure that wraps a boolean "set" closure and
+ * "Set" bi-closure that wraps a <code>boolean</code> "set" closure and
* forwards its arguments to it, converting the {@link Boolean} to
* a <code>boolean</code>.
*
@@ -1123,6 +1166,43 @@ public final class PropertyValueModelTools {
// ********** aspect adapters **********
/**
+ * Construct an <code>int</code> 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>
+ * <code>Integer</code> value.
+ *
+ * @param <S> the type of the subject
+ */
+ public static <S extends Model> PropertyValueModel<Integer> modelAspectAdapter(
+ S subject,
+ String aspectName,
+ IntTransformer<? super S> transformer
+ ) {
+ return modelAspectAdapter(subject, aspectName, TransformerTools.adapt(transformer));
+ }
+
+
+ /**
+ * Construct an <code>int</code> 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.
+ *
+ * @param <S> the type of the subject
+ */
+ public static <S extends Model> PropertyValueModel<Integer> modelAspectAdapter_(
+ S subject,
+ String aspectName,
+ IntTransformer<? super S> transformer
+ ) {
+ return modelAspectAdapter_(subject, aspectName, TransformerTools.adapt(transformer));
+ }
+
+ /**
* Construct a boolean model property aspect adapter for the
* specified subject, aspect name, and predicate.
* <p>
@@ -1196,6 +1276,42 @@ public final class PropertyValueModelTools {
}
/**
+ * Construct an <code>int</code> model property aspect adapter for the
+ * specified subject model, 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>
+ * <code>Integer</code> value.
+ *
+ * @param <S> the type of the subject
+ */
+ public static <S extends Model, SM extends PropertyValueModel<? extends S>> PropertyValueModel<Integer> modelAspectAdapter(
+ SM subjectModel,
+ String aspectName,
+ IntTransformer<? super S> transformer
+ ) {
+ return modelAspectAdapter(subjectModel, aspectName, TransformerTools.adapt(transformer));
+ }
+
+ /**
+ * Construct an <code>int</code> model property aspect adapter for the
+ * specified subject model, aspect name, and transformer.
+ * <p>
+ * <strong>NB:</strong>
+ * The specified transformer must be able to handle a <code>null</code> subject.
+ *
+ * @param <S> the type of the subject
+ */
+ public static <S extends Model, SM extends PropertyValueModel<? extends S>> PropertyValueModel<Integer> modelAspectAdapter_(
+ SM subjectModel,
+ String aspectName,
+ IntTransformer<? super S> transformer
+ ) {
+ return modelAspectAdapter_(subjectModel, aspectName, TransformerTools.adapt(transformer));
+ }
+
+ /**
* Construct a boolean model property aspect adapter for the
* specified subject model, aspect name, and predicate.
* <p>
@@ -1345,6 +1461,48 @@ public final class PropertyValueModelTools {
// ********** modifiable aspect adapters **********
/**
+ * Construct an <code>int</code> modifiable property aspect adapter for the
+ * specified subject, aspect name, transformer, and closure.
+ * <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>
+ * <code>Integer</code> value.
+ * Likewise, if the subject is <code>null</code>, the specified closure will
+ * not be executed.
+ *
+ * @param <S> the type of the subject
+ */
+ public static <S extends Model> ModifiablePropertyValueModel<Integer> modifiableModelAspectAdapter(
+ S subject,
+ String aspectName,
+ IntTransformer<? super S> getTransformer,
+ IntSetClosure<? super S> setClosure
+ ) {
+ return modifiableModelAspectAdapter(subject, aspectName, TransformerTools.adapt(getTransformer), intSetBiClosureAdapter(setClosure));
+ }
+
+ /**
+ * Construct an <code>int</code> modifiable property aspect adapter for the
+ * specified subject, aspect name, transformer, and closure.
+ * <p>
+ * <strong>NB:</strong>
+ * The specified transformer must be able to handle a <code>null</code> subject.
+ * Likewise, the specified closure must be able to handle a <code>null</code>
+ * subject (i.e. first argument).
+ *
+ * @param <S> the type of the subject
+ */
+ public static <S extends Model> ModifiablePropertyValueModel<Integer> modifiableModelAspectAdapter_(
+ S subject,
+ String aspectName,
+ IntTransformer<? super S> getTransformer,
+ IntSetClosure<? super S> setClosure
+ ) {
+ return modifiableModelAspectAdapter_(subject, aspectName, TransformerTools.adapt(getTransformer), intSetBiClosureAdapter(setClosure));
+ }
+
+ /**
* Construct a boolean modifiable property aspect adapter for the
* specified subject, aspect name, predicate, and closure.
* <p>
@@ -1430,6 +1588,48 @@ public final class PropertyValueModelTools {
}
/**
+ * Construct an <code>int</code> modifiable property aspect adapter for the
+ * specified subject model, aspect name, transformer, and closure.
+ * <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>
+ * <code>Integer</code> value.
+ * Likewise, if the subject is <code>null</code>, the specified closure will
+ * not be executed.
+ *
+ * @param <S> the type of the subject
+ */
+ public static <S extends Model, SM extends PropertyValueModel<S>> ModifiablePropertyValueModel<Integer> modifiableModelAspectAdapter(
+ SM subjectModel,
+ String aspectName,
+ IntTransformer<? super S> getTransformer,
+ IntSetClosure<? super S> setClosure
+ ) {
+ return modifiableModelAspectAdapter(subjectModel, aspectName, TransformerTools.adapt(getTransformer), intSetBiClosureAdapter(setClosure));
+ }
+
+ /**
+ * Construct an <code>int</code> modifiable property aspect adapter for the
+ * specified subject model, aspect name, transformer, and closure.
+ * <p>
+ * <strong>NB:</strong>
+ * The specified transformer must be able to handle a <code>null</code> subject.
+ * Likewise, the specified closure must be able to handle a <code>null</code>
+ * subject (i.e. first argument).
+ *
+ * @param <S> the type of the subject
+ */
+ public static <S extends Model, SM extends PropertyValueModel<S>> ModifiablePropertyValueModel<Integer> modifiableModelAspectAdapter_(
+ SM subjectModel,
+ String aspectName,
+ IntTransformer<? super S> getTransformer,
+ IntSetClosure<? super S> setClosure
+ ) {
+ return modifiableModelAspectAdapter_(subjectModel, aspectName, TransformerTools.adapt(getTransformer), intSetBiClosureAdapter(setClosure));
+ }
+
+ /**
* Construct a boolean modifiable property aspect adapter for the
* specified subject model, aspect name, predicate, and closure.
* <p>
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerTools.java
index 7b2d5500f1..f4bcfb54f8 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerTools.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerTools.java
@@ -26,7 +26,9 @@ import org.eclipse.jpt.common.utility.internal.ClassTools;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.exception.DefaultExceptionHandler;
import org.eclipse.jpt.common.utility.internal.predicate.PredicateTools;
+import org.eclipse.jpt.common.utility.internal.transformer.int_.IntObjectTransformerAdapter;
import org.eclipse.jpt.common.utility.predicate.Predicate;
+import org.eclipse.jpt.common.utility.transformer.IntTransformer;
import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
import org.eclipse.jpt.common.utility.transformer.Transformer;
@@ -38,6 +40,15 @@ public final class TransformerTools {
// ********** adapters **********
/**
+ * Adapt the specified {@link IntTransformer} to the {@link Transformer} interface.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ */
+ public static <I> Transformer<I, Integer> adapt(IntTransformer<? super I> intTransformer) {
+ return new IntObjectTransformerAdapter<>(intTransformer);
+ }
+
+ /**
* Adapt the specified {@link Closure} to the {@link Transformer} interface.
* The returned transformer will always return <code>null</code>.
*
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntObjectTransformerAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntObjectTransformerAdapter.java
new file mode 100644
index 0000000000..9efd7a0f47
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntObjectTransformerAdapter.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.utility.internal.transformer.int_;
+
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.transformer.IntTransformer;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
+
+/**
+ * Adapt an <code>int</code> transformer to the standard object transformer
+ * interface.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ *
+ * @see IntTransformer
+ */
+public class IntObjectTransformerAdapter<I>
+ implements Transformer<I, Integer>
+{
+ private final IntTransformer<? super I> intTransformer;
+
+ public IntObjectTransformerAdapter(IntTransformer<? super I> intTransformer) {
+ super();
+ if (intTransformer == null) {
+ throw new NullPointerException();
+ }
+ this.intTransformer = intTransformer;
+ }
+
+ public Integer transform(I input) {
+ return Integer.valueOf(this.intTransformer.transform(input));
+ }
+
+ @Override
+ public String toString() {
+ return ObjectTools.toString(this, this.intTransformer);
+ }
+}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntTransformerAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntTransformerAdapter.java
new file mode 100644
index 0000000000..60aadc96a0
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntTransformerAdapter.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.utility.internal.transformer.int_;
+
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.transformer.IntTransformer;
+
+/**
+ * Convenience <code>int</code> transformer that returns zero.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ */
+public class IntTransformerAdapter<I>
+ implements IntTransformer<I>
+{
+ public int transform(I input) {
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return ObjectTools.toString(this);
+ }
+}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntegerIntTransformerAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntegerIntTransformerAdapter.java
new file mode 100644
index 0000000000..9fc012eeba
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntegerIntTransformerAdapter.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.utility.internal.transformer.int_;
+
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.transformer.IntTransformer;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
+
+/**
+ * Adapt an {@link Integer} transformer to the <code>int</code> transformer
+ * interface.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ *
+ * @see Transformer
+ */
+public class IntegerIntTransformerAdapter<I>
+ implements IntTransformer<I>
+{
+ private final Transformer<? super I, Integer> transformer;
+
+ public IntegerIntTransformerAdapter(Transformer<? super I, Integer> transformer) {
+ super();
+ if (transformer == null) {
+ throw new NullPointerException();
+ }
+ this.transformer = transformer;
+ }
+
+ public int transform(I input) {
+ return this.transformer.transform(input).intValue();
+ }
+
+ @Override
+ public String toString() {
+ return ObjectTools.toString(this, this.transformer);
+ }
+}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/BooleanSetClosure.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/BooleanSetClosure.java
index 4a16ff275c..f5094b44ed 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/BooleanSetClosure.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/BooleanSetClosure.java
@@ -10,8 +10,8 @@
package org.eclipse.jpt.common.utility.model;
/**
- * Simple interface for implementing a boolean "set" command that takes two
- * arguments, the model and the new value of the model's boolean attribute.
+ * Simple interface for implementing a <code>boolean</code> "set" command that takes two
+ * arguments, the model and the new value of the model's <code>boolean</code> attribute.
* The expectation is the closure will have side effects.
* <p>
* Provisional API: This interface is part of an interim API that is still
@@ -26,7 +26,7 @@ public interface BooleanSetClosure<M> {
/**
* The intent of this method is to set the value of the specified
- * model's attribute to the specified boolean value.
+ * model's attribute to the specified <code>boolean</code> value.
*/
void execute(M model, boolean value);
}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/IntSetClosure.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/IntSetClosure.java
new file mode 100644
index 0000000000..9f2d590820
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/IntSetClosure.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.utility.model;
+
+/**
+ * Simple interface for implementing an <code>int</code> "set" command that takes two
+ * arguments, the model and the new value of the model's <code>int</code> attribute.
+ * The expectation is the closure will have side effects.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @param <M> the type of the first object passed to the command
+ */
+public interface IntSetClosure<M> {
+
+ /**
+ * The intent of this method is to set the value of the specified
+ * model's attribute to the specified <code>int</code> value.
+ */
+ void execute(M model, int value);
+}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/transformer/IntTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/transformer/IntTransformer.java
new file mode 100644
index 0000000000..c7e42d50c9
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/transformer/IntTransformer.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2016 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.utility.transformer;
+
+/**
+ * Simple interface for transforming an object into an <code>int</code>.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ *
+ * @see org.eclipse.jpt.common.utility.transformer.Transformer
+ */
+public interface IntTransformer<I> {
+ /**
+ * Return the transformed <code>int</code>.
+ * The semantics of "transform" is determined by the
+ * contract between the client and the server.
+ */
+ int transform(I input);
+}

Back to the top