Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2016-08-11 22:08:50 +0000
committerBrian Vosburgh2017-05-18 22:38:51 +0000
commit0161947d4c7113e0a3339b1da18451b6383598c0 (patch)
tree9627eaf6b0043f212f0729af8fbd0ea445e16cc1
parent7a088a4e54a839e4e19daedafea946fd0d4bbee4 (diff)
downloadwebtools.dali-0161947d4c7113e0a3339b1da18451b6383598c0.tar.gz
webtools.dali-0161947d4c7113e0a3339b1da18451b6383598c0.tar.xz
webtools.dali-0161947d4c7113e0a3339b1da18451b6383598c0.zip
convert most utility Transformers to lambdas (in TransformerTools)
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ArrayTools.java11
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ObjectTools.java14
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/closure/TransformerClosure.java2
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/TransformerCommand.java2
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/factory/TransformerFactory.java2
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterable/IterableTools.java12
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CastingInterruptibleTransformerWrapper.java48
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CastingTransformerWrapper.java64
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CloneTransformer.java57
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ClosureTransformer.java53
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CommandTransformer.java53
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ConditionalInterruptibleTransformer.java58
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ConditionalTransformer.java62
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/DisabledTransformer.java56
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/DowncastingInterruptibleTransformerWrapper.java48
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/DowncastingTransformerWrapper.java67
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/FactoryTransformer.java51
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/FieldTransformer.java75
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/FilteringTransformer.java57
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InstantiationTransformer.java56
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleClosureTransformer.java45
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleCommandTransformer.java45
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleFactoryTransformer.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleTransformerChain.java49
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/IterableTransformerWrapper.java51
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ListLastElementTransformer.java54
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ListLastElementTransformer_.java54
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/MapTransformer.java51
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/MethodTransformer.java91
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NotBooleanTransformer.java55
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullCheckInterruptibleTransformerWrapper.java50
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullCheckTransformer.java47
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullCheckTransformerWrapper.java55
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullOutputTransformer.java56
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ObjectToStringTransformer.java56
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/PassThruTransformer.java54
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SafeInterruptibleTransformerWrapper.java64
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SafeTransformerWrapper.java68
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/StaticOutputTransformer.java47
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/StringToBooleanTransformer.java53
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/StringToIntegerTransformer.java50
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SwitchInterruptibleTransformer.java57
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SwitchTransformer.java66
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerAdapter.java2
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerCallable.java56
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerChain.java58
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerTools.java518
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/UpcastingInterruptibleTransformerWrapper.java47
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/UpcastingTransformerWrapper.java64
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/ChainIterableTests.java6
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/GraphIterableTests.java4
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/TransformationIterableTests.java8
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/TransformationListIterableTests.java6
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/ChainIteratorTests.java6
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/GraphIteratorTests.java6
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/TransformationIteratorTests.java6
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/TransformationListIteratorTests.java6
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/FilteringTransformerTests.java80
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/JptCommonUtilityTransformerTests.java4
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformerTests.java50
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformer_Tests.java63
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/NullCheckTransformerTests.java45
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/TransformerToolsTests.java94
63 files changed, 588 insertions, 2651 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ArrayTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ArrayTools.java
index dee8dce1cb..d6a8fcf7b1 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ArrayTools.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ArrayTools.java
@@ -907,6 +907,17 @@ public final class ArrayTools {
}
/**
+ * Throw a {@link NullPointerException} if the specified array is <code>null</code>
+ * or, if it is not <code>null</code>, contains a <code>null</code>.
+ * Convenient for argument checking.
+ */
+ public static void assertNeitherIsNorContainsNull(Object[] array) {
+ if (isOrContainsNull(array)) {
+ throw new NullPointerException();
+ }
+ }
+
+ /**
* Return whether the specified array contains a <code>null</code>.
*/
public static boolean containsNull(Object[] array) {
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ObjectTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ObjectTools.java
index 7727056e10..85d2d1a915 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ObjectTools.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ObjectTools.java
@@ -42,6 +42,20 @@ public final class ObjectTools {
public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
+ // ********** assertions **********
+
+ /**
+ * Return whether the specified objects are equal, with the appropriate
+ * <code>null</code> checks.
+ * @see Object#equals(Object)
+ */
+ public static void assertNotNull(Object object) {
+ if (object == null) {
+ throw new NullPointerException();
+ }
+ }
+
+
// ********** object comparison **********
/**
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/closure/TransformerClosure.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/closure/TransformerClosure.java
index a6ec35bd45..18ef819d12 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/closure/TransformerClosure.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/closure/TransformerClosure.java
@@ -22,7 +22,7 @@ import org.eclipse.jpt.common.utility.transformer.Transformer;
* @param <A> the type of the object passed to the closure and forwarded to the
* transformer
*
- * @see org.eclipse.jpt.common.utility.internal.transformer.ClosureTransformer
+ * @see org.eclipse.jpt.common.utility.internal.transformer.TransformerTools#adapt(Closure)
*/
public class TransformerClosure<A>
implements Closure<A>
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/TransformerCommand.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/TransformerCommand.java
index 2cc40d305a..41a26c6e2c 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/TransformerCommand.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/TransformerCommand.java
@@ -19,7 +19,7 @@ import org.eclipse.jpt.common.utility.transformer.Transformer;
* ignored. This really only useful for a transformer that accepts
* <code>null</code> input and has side-effects.
*
- * @see org.eclipse.jpt.common.utility.internal.transformer.CommandTransformer
+ * @see org.eclipse.jpt.common.utility.internal.transformer.TransformerTools#adapt(Command)
*/
public class TransformerCommand
implements Command
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/factory/TransformerFactory.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/factory/TransformerFactory.java
index fcd64fd8d4..d66e7fdec3 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/factory/TransformerFactory.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/factory/TransformerFactory.java
@@ -21,7 +21,7 @@ import org.eclipse.jpt.common.utility.transformer.Transformer;
*
* @param <T> the type of the object returned by the factory
*
- * @see org.eclipse.jpt.common.utility.internal.transformer.FactoryTransformer
+ * @see org.eclipse.jpt.common.utility.internal.transformer.TransformerTools#adapt(Factory)
*/
public class TransformerFactory<T>
implements Factory<T>
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterable/IterableTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterable/IterableTools.java
index a586c287a5..96742fc067 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterable/IterableTools.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterable/IterableTools.java
@@ -71,6 +71,18 @@ public final class IterableTools {
}
/**
+ * If the specified iterable is <code>null</code>
+ * or, if it is not <code>null</code>, contains a <code>null</code>,
+ * throw a {@link NullPointerException}.
+ * Convenient for argument checking.
+ */
+ public static void assertNeitherIsNorContainsNull(Iterable<?> iterable) {
+ if (isOrContainsNull(iterable)) {
+ throw new NullPointerException();
+ }
+ }
+
+ /**
* Return whether the specified iterable is <code>null</code>
* or, if it is not <code>null</code>, contains a <code>null</code>.
* Convenient for argument checking.
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CastingInterruptibleTransformerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CastingInterruptibleTransformerWrapper.java
deleted file mode 100644
index 1616041a7e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CastingInterruptibleTransformerWrapper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-
-/**
- * @see CastingTransformerWrapper
- */
-public class CastingInterruptibleTransformerWrapper<I, X, O>
- implements InterruptibleTransformer<I, O>
-{
- private final InterruptibleTransformer<? super I, ? extends X> transformer;
-
-
- public CastingInterruptibleTransformerWrapper(InterruptibleTransformer<? super I, ? extends X> transformer) {
- super();
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- }
-
- /**
- * Cast the output and hope for the best.
- */
- @SuppressWarnings("unchecked")
- public O transform(I input) throws InterruptedException {
- return (O) this.transformer.transform(input);
- }
-
- public InterruptibleTransformer<? super I, ? extends X> getTransformer() {
- return this.transformer;
- }
-
- @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/internal/transformer/CastingTransformerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CastingTransformerWrapper.java
deleted file mode 100644
index 6559198638..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CastingTransformerWrapper.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Wrap a transformer that takes an object of type <code>I</code> and returns
- * an object of type <code>X</code>, converting it into a transformer that
- * takes an object of type <code>I</code> and returns
- * an object of type <code>O</code>. <em>Assume</em> the wrapped
- * transformer returns only objects of type <code>O</code>. The result is a
- * {@link ClassCastException} if this assumption is false.
- *
- * @param <I> input: the type of the object passed to the transformer and
- * forwarded to the wrapped transformer
- * @param <X> intermediate: the type of object returned by the wrapped
- * transformer
- * @param <O> output: the type of object returned by the transformer - this
- * is the same object returned by the wrapped transformer, simply
- * cast to <code>O</code>
- *
- * @see DowncastingTransformerWrapper
- * @see UpcastingTransformerWrapper
- */
-public class CastingTransformerWrapper<I, X, O>
- implements Transformer<I, O>
-{
- private final Transformer<? super I, ? extends X> transformer;
-
-
- public CastingTransformerWrapper(Transformer<? super I, ? extends X> transformer) {
- super();
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- }
-
- /**
- * Cast the output and hope for the best.
- */
- @SuppressWarnings("unchecked")
- public O transform(I input) {
- return (O) this.transformer.transform(input);
- }
-
- public Transformer<? super I, ? extends X> getTransformer() {
- return this.transformer;
- }
-
- @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/internal/transformer/CloneTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CloneTransformer.java
deleted file mode 100644
index b663ed2ecc..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CloneTransformer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * A transformer that will clone (via reflection) the input.
- * @param <I> input: the type of the object passed to the transformer
- * (and returned by the transformer)
- * @see Cloneable
- * @see Object#clone()
- */
-public final class CloneTransformer<I extends Cloneable>
- implements Transformer<I, I>, Serializable
-{
- @SuppressWarnings("rawtypes")
- public static final Transformer INSTANCE = new CloneTransformer();
-
- @SuppressWarnings("unchecked")
- public static <I extends Cloneable> Transformer<I, I> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private CloneTransformer() {
- super();
- }
-
- /**
- * Clone the input via reflection.
- */
- @SuppressWarnings("unchecked")
- public I transform(I input) {
- return (I) ObjectTools.execute(input, "clone"); //$NON-NLS-1$
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ClosureTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ClosureTransformer.java
deleted file mode 100644
index 6a1ed53e8e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ClosureTransformer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.closure.Closure;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Adapt a {@link Closure} to the {@link Transformer} interface.
- * The transformer will always return <code>null</code>.
- *
- * @param <I> input: the type of the object passed to the transformer and
- * forwarded to the closure
- * @param <O> output: the type of the object returned by the transformer;
- * always <code>null</code>
- *
- * @see org.eclipse.jpt.common.utility.internal.closure.TransformerClosure
- */
-public class ClosureTransformer<I, O>
- implements Transformer<I, O>
-{
- private final Closure<? super I> closure;
-
- public ClosureTransformer(Closure<? super I> closure) {
- super();
- if (closure == null) {
- throw new NullPointerException();
- }
- this.closure = closure;
- }
-
- public O transform(I input) {
- this.closure.execute(input);
- return null;
- }
-
- public Closure<? super I> getClosure() {
- return this.closure;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.closure);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CommandTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CommandTransformer.java
deleted file mode 100644
index 2763deb48b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/CommandTransformer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Adapt a {@link Command} to the {@link Transformer} interface.
- * The transformer will always return <code>null</code>.
- *
- * @param <I> input: the type of the object passed to the transformer;
- * ignored
- * @param <O> output: the type of the object returned by the transformer;
- * always <code>null</code>
- *
- * @see org.eclipse.jpt.common.utility.internal.command.TransformerCommand
- */
-public class CommandTransformer<I, O>
- implements Transformer<I, O>
-{
- private final Command command;
-
- public CommandTransformer(Command command) {
- super();
- if (command == null) {
- throw new NullPointerException();
- }
- this.command = command;
- }
-
- public O transform(I input) {
- this.command.execute();
- return null;
- }
-
- public Command getCommand() {
- return this.command;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.command);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ConditionalInterruptibleTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ConditionalInterruptibleTransformer.java
deleted file mode 100644
index 3d28cc5b57..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ConditionalInterruptibleTransformer.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.predicate.Predicate;
-
-/**
- * @see ConditionalTransformer
- */
-public class ConditionalInterruptibleTransformer<I, O>
- implements InterruptibleTransformer<I, O>
-{
- private final Predicate<? super I> predicate;
- private final InterruptibleTransformer<? super I, ? extends O> trueTransformer;
- private final InterruptibleTransformer<? super I, ? extends O> falseTransformer;
-
- public ConditionalInterruptibleTransformer(Predicate<? super I> predicate, InterruptibleTransformer<? super I, ? extends O> trueTransformer, InterruptibleTransformer<? super I, ? extends O> falseTransformer) {
- super();
- if ((predicate == null) || (trueTransformer == null) || (falseTransformer == null)) {
- throw new NullPointerException();
- }
- this.predicate = predicate;
- this.trueTransformer = trueTransformer;
- this.falseTransformer = falseTransformer;
- }
-
- public O transform(I input) throws InterruptedException {
- return this.predicate.evaluate(input) ?
- this.trueTransformer.transform(input) :
- this.falseTransformer.transform(input);
- }
-
- public Predicate<? super I> getPredicate() {
- return this.predicate;
- }
-
- public InterruptibleTransformer<? super I, ? extends O> getTrueTransformer() {
- return this.trueTransformer;
- }
-
- public InterruptibleTransformer<? super I, ? extends O> getFalseTransformer() {
- return this.falseTransformer;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.predicate);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ConditionalTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ConditionalTransformer.java
deleted file mode 100644
index 6bf43e3a7d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ConditionalTransformer.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.predicate.Predicate;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Transformer that passes its input to a configured predicate to determine
- * which of its two transformers to execute.
- *
- * @param <I> input: the type of the object passed to the transformer
- * @param <O> output: the type of the object returned by the transformer
- */
-public class ConditionalTransformer<I, O>
- implements Transformer<I, O>
-{
- private final Predicate<? super I> predicate;
- private final Transformer<? super I, ? extends O> trueTransformer;
- private final Transformer<? super I, ? extends O> falseTransformer;
-
- public ConditionalTransformer(Predicate<? super I> predicate, Transformer<? super I, ? extends O> trueTransformer, Transformer<? super I, ? extends O> falseTransformer) {
- super();
- if ((predicate == null) || (trueTransformer == null) || (falseTransformer == null)) {
- throw new NullPointerException();
- }
- this.predicate = predicate;
- this.trueTransformer = trueTransformer;
- this.falseTransformer = falseTransformer;
- }
-
- public O transform(I input) {
- return this.predicate.evaluate(input) ?
- this.trueTransformer.transform(input) :
- this.falseTransformer.transform(input);
- }
-
- public Predicate<? super I> getPredicate() {
- return this.predicate;
- }
-
- public Transformer<? super I, ? extends O> getTrueTransformer() {
- return this.trueTransformer;
- }
-
- public Transformer<? super I, ? extends O> getFalseTransformer() {
- return this.falseTransformer;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.predicate);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/DisabledTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/DisabledTransformer.java
deleted file mode 100644
index de20acd729..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/DisabledTransformer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2013 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;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * A transformer that will throw an {@link UnsupportedOperationException exception}
- * if {@link #transform(Object)} is called. This is useful in situations
- * where a transformer is optional and the default transformer should
- * not be used.
- * @param <I> input: the type of the object passed to the transformer
- * @param <O> output: the type of the object (never) returned by the transformer
- */
-public final class DisabledTransformer<I, O>
- implements Transformer<I, O>, Serializable
-{
- @SuppressWarnings("rawtypes")
- public static final Transformer INSTANCE = new DisabledTransformer();
-
- @SuppressWarnings("unchecked")
- public static <I, O> Transformer<I, O> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private DisabledTransformer() {
- super();
- }
-
- /**
- * Throw an {@link UnsupportedOperationException exception}.
- */
- public O transform(I input) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/DowncastingInterruptibleTransformerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/DowncastingInterruptibleTransformerWrapper.java
deleted file mode 100644
index 4105f4bfb0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/DowncastingInterruptibleTransformerWrapper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-
-/**
- * @see DowncastingTransformerWrapper
- */
-public class DowncastingInterruptibleTransformerWrapper<I, X, O extends X>
- implements InterruptibleTransformer<I, O>
-{
- private final InterruptibleTransformer<? super I, ? extends X> transformer;
-
-
- public DowncastingInterruptibleTransformerWrapper(InterruptibleTransformer<? super I, ? extends X> transformer) {
- super();
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- }
-
- /**
- * Cast the output and hope for the best.
- */
- @SuppressWarnings("unchecked")
- public O transform(I input) throws InterruptedException {
- return (O) this.transformer.transform(input);
- }
-
- public InterruptibleTransformer<? super I, ? extends X> getTransformer() {
- return this.transformer;
- }
-
- @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/internal/transformer/DowncastingTransformerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/DowncastingTransformerWrapper.java
deleted file mode 100644
index 8bb2367d89..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/DowncastingTransformerWrapper.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Wrap a transformer that takes an object of type <code>I</code> and returns
- * an object of type <code>X</code>, converting it into a transformer that
- * takes an object of type <code>I</code> and returns
- * an object of type <code>O</code>. <em>Assume</em> the wrapped
- * transformer returns only objects of type <code>O</code>. The result is a
- * {@link ClassCastException} if this assumption is false.
- * <p>
- * This is like a {@link CastingTransformerWrapper} but with more restrictive type
- * parameters.
- *
- * @param <I> input: the type of the object passed to the transformer and
- * forwarded to the wrapped transformer
- * @param <X> intermediate: the type of object returned by the wrapped
- * transformer
- * @param <O> output: the type of object returned by the transformer - this
- * is the same object returned by the wrapped transformer, simply
- * cast to <code>O</code>
- *
- * @see CastingTransformerWrapper
- * @see UpcastingTransformerWrapper
- */
-public class DowncastingTransformerWrapper<I, X, O extends X>
- implements Transformer<I, O>
-{
- private final Transformer<? super I, ? extends X> transformer;
-
-
- public DowncastingTransformerWrapper(Transformer<? super I, ? extends X> transformer) {
- super();
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- }
-
- /**
- * Cast the output and hope for the best.
- */
- @SuppressWarnings("unchecked")
- public O transform(I input) {
- return (O) this.transformer.transform(input);
- }
-
- public Transformer<? super I, ? extends X> getTransformer() {
- return this.transformer;
- }
-
- @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/internal/transformer/FactoryTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/FactoryTransformer.java
deleted file mode 100644
index 42bc0a6d58..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/FactoryTransformer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.factory.Factory;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Adapt a {@link Factory} to the {@link Transformer} interface.
- *
- * @param <I> input: the type of the object passed to the transformer;
- * ignored
- * @param <O> output: the type of the object returned by the transformer;
- * as generated by the factory
- *
- * @see org.eclipse.jpt.common.utility.internal.factory.TransformerFactory
- */
-public class FactoryTransformer<I, O>
- implements Transformer<I, O>
-{
- private final Factory<? extends O> factory;
-
- public FactoryTransformer(Factory<? extends O> factory) {
- super();
- if (factory == null) {
- throw new NullPointerException();
- }
- this.factory = factory;
- }
-
- public O transform(I input) {
- return this.factory.create();
- }
-
- public Factory<? extends O> getFactory() {
- return this.factory;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.factory);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/FieldTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/FieldTransformer.java
deleted file mode 100644
index 130a5e11e9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/FieldTransformer.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * A transformer that uses Java reflection to transform an object into the
- * value of one of its fields. Checked exceptions are converted to
- * {@link RuntimeException}s.
- * <p>
- * <strong>NB:</strong> The actual field is determined at execution time,
- * not construction time. As a result, the transformer can be used to emulate
- * "duck typing".
- *
- * @param <I> input: the type of objects passed to the transformer
- * @param <O> output: the type of objects returned by the transformer
- *
- * @see MethodTransformer
- * @see Class#getDeclaredField(String)
- * @see java.lang.reflect.Field#get(Object)
- */
-public class FieldTransformer<I, O>
- implements Transformer<I, O>, Serializable
-{
- private final String fieldName;
-
- private static final long serialVersionUID = 1L;
-
-
- public FieldTransformer(String fieldName) {
- super();
- if (fieldName == null) {
- throw new NullPointerException();
- }
- this.fieldName = fieldName;
- }
-
- @SuppressWarnings("unchecked")
- public O transform(I input) {
- return (O) ObjectTools.get(input, this.fieldName);
- }
-
- public String getFieldName() {
- return this.fieldName;
- }
-
- @Override
- public boolean equals(Object o) {
- if ( ! (o instanceof FieldTransformer<?, ?>)) {
- return false;
- }
- FieldTransformer<?, ?> other = (FieldTransformer<?, ?>) o;
- return ObjectTools.equals(this.fieldName, other.fieldName);
- }
-
- @Override
- public int hashCode() {
- return this.fieldName.hashCode();
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.fieldName);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/FilteringTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/FilteringTransformer.java
deleted file mode 100644
index 6e7c243bf4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/FilteringTransformer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.predicate.Predicate;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Tranformer that "filters" its input.
- * If the input is a member of the set defined by the transformer's filter,
- * the transformer simply returns the input;
- * otherwise, the transformer will return the default output.
- *
- * @param <I> input: the type of the object passed to and
- * returned by the transformer
- */
-public class FilteringTransformer<I>
- implements Transformer<I, I>
-{
- private final Predicate<? super I> filter;
- private final I defaultOutput;
-
-
- public FilteringTransformer(Predicate<? super I> filter, I defaultOutput) {
- super();
- if (filter == null) {
- throw new NullPointerException();
- }
- this.filter = filter;
- this.defaultOutput = defaultOutput;
- }
-
- public I transform(I input) {
- return this.filter.evaluate(input) ? input : this.defaultOutput;
- }
-
- public Predicate<? super I> getFilter() {
- return this.filter;
- }
-
- public I getDefaultOutput() {
- return this.defaultOutput;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.filter);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InstantiationTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InstantiationTransformer.java
deleted file mode 100644
index be5576db48..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InstantiationTransformer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.ClassTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Transform a {@link Class} into an instance by calling
- * {@link Class#newInstance()}. Checked exceptions are converted to
- * {@link RuntimeException}s.
- *
- * @param <O> output: the type of the object returned by the transformer (and
- * the class, or superclass of the class, passed to the transformer)
- *
- * @see Class#newInstance()
- */
-public final class InstantiationTransformer<O>
- implements Transformer<Class<? extends O>, O>, Serializable
-{
- @SuppressWarnings("rawtypes")
- public static final Transformer INSTANCE = new InstantiationTransformer();
-
- @SuppressWarnings("unchecked")
- public static <O> Transformer<Class<? extends O>, O> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private InstantiationTransformer() {
- super();
- }
-
- public O transform(Class<? extends O> input) {
- return ClassTools.newInstance(input);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleClosureTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleClosureTransformer.java
deleted file mode 100644
index b5f0aa18c4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleClosureTransformer.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.closure.InterruptibleClosure;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-
-/**
- * @see ClosureTransformer
- */
-public class InterruptibleClosureTransformer<I, O>
- implements InterruptibleTransformer<I, O>
-{
- private final InterruptibleClosure<? super I> closure;
-
- public InterruptibleClosureTransformer(InterruptibleClosure<? super I> closure) {
- super();
- if (closure == null) {
- throw new NullPointerException();
- }
- this.closure = closure;
- }
-
- public O transform(I input) throws InterruptedException {
- this.closure.execute(input);
- return null;
- }
-
- public InterruptibleClosure<? super I> getClosure() {
- return this.closure;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.closure);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleCommandTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleCommandTransformer.java
deleted file mode 100644
index 64bde4d9ff..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleCommandTransformer.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.command.InterruptibleCommand;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-
-/**
- * @see CommandTransformer
- */
-public class InterruptibleCommandTransformer<I, O>
- implements InterruptibleTransformer<I, O>
-{
- private final InterruptibleCommand command;
-
- public InterruptibleCommandTransformer(InterruptibleCommand command) {
- super();
- if (command == null) {
- throw new NullPointerException();
- }
- this.command = command;
- }
-
- public O transform(I input) throws InterruptedException {
- this.command.execute();
- return null;
- }
-
- public InterruptibleCommand getCommand() {
- return this.command;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.command);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleFactoryTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleFactoryTransformer.java
deleted file mode 100644
index 8d0f3610c4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleFactoryTransformer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.factory.InterruptibleFactory;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-
-/**
- * @see FactoryTransformer
- */
-public class InterruptibleFactoryTransformer<I, O>
- implements InterruptibleTransformer<I, O>
-{
- private final InterruptibleFactory<? extends O> factory;
-
- public InterruptibleFactoryTransformer(InterruptibleFactory<? extends O> factory) {
- super();
- if (factory == null) {
- throw new NullPointerException();
- }
- this.factory = factory;
- }
-
- public O transform(I input) throws InterruptedException {
- return this.factory.create();
- }
-
- public InterruptibleFactory<? extends O> getFactory() {
- return this.factory;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.factory);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleTransformerChain.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleTransformerChain.java
deleted file mode 100644
index c87aa32e9e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/InterruptibleTransformerChain.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-
-/**
- * @see TransformerChain
- */
-public class InterruptibleTransformerChain<I, O>
- implements InterruptibleTransformer<I, O>
-{
- private final Iterable<InterruptibleTransformer<?, ?>> transformers;
-
- public InterruptibleTransformerChain(Iterable<InterruptibleTransformer<?, ?>> transformers) {
- super();
- if (IterableTools.isOrContainsNull(transformers)) {
- throw new NullPointerException();
- }
- this.transformers = transformers;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public O transform(I input) throws InterruptedException {
- Object result = input;
- for (InterruptibleTransformer transformer : this.transformers) {
- result = transformer.transform(result);
- }
- return (O) result;
- }
-
- public Iterable<InterruptibleTransformer<?, ?>> getTransformers() {
- return this.transformers;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.transformers);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/IterableTransformerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/IterableTransformerWrapper.java
deleted file mode 100644
index 3b22cc1b4a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/IterableTransformerWrapper.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Wrap a transformer that converts an input object into an <em>iterable</em>
- * of objects of the same type as the input object, converting that transformer
- * into one that converts the same object into an <em>iterator</em>
- * of objects of the same type as the input object.
- *
- * @param <I> input: the type of the object passed to the transformer; also the
- * type of object returned by the output iterator
- */
-public class IterableTransformerWrapper<I>
- implements Transformer<I, Iterator<? extends I>>
-{
- private final Transformer<? super I, ? extends Iterable<? extends I>> transformer;
-
-
- public IterableTransformerWrapper(Transformer<? super I, ? extends Iterable<? extends I>> transformer) {
- super();
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- }
-
- public Iterator<? extends I> transform(I input) {
- return this.transformer.transform(input).iterator();
- }
-
- public Transformer<? super I, ? extends Iterable<? extends I>> getTransformer() {
- return this.transformer;
- }
-
- @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/internal/transformer/ListLastElementTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ListLastElementTransformer.java
deleted file mode 100644
index ed48ffba09..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ListLastElementTransformer.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import java.io.Serializable;
-import java.util.List;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Transformer that transforms a list into its last element.
- * If the list is empty, the transformer returns <code>null</code>.
- *
- * @param <E> the type of elements held by the list
- *
- * @see ListLastElementTransformer_
- */
-public final class ListLastElementTransformer<E>
- implements Transformer<List<? extends E>, E>, Serializable
-{
- @SuppressWarnings("rawtypes")
- public static final Transformer INSTANCE = new ListLastElementTransformer();
-
- @SuppressWarnings("unchecked")
- public static <E> Transformer<List<? extends E>, E> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private ListLastElementTransformer() {
- super();
- }
-
- public E transform(List<? extends E> list) {
- return list.isEmpty() ? null : list.get(list.size() - 1);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ListLastElementTransformer_.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ListLastElementTransformer_.java
deleted file mode 100644
index 86b32bef69..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ListLastElementTransformer_.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import java.io.Serializable;
-import java.util.List;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Transformer that transforms a list into its last element.
- * If the list is empty, the transformer throws an {@link IndexOutOfBoundsException}.
- *
- * @param <E> the type of elements held by the list
- *
- * @see ListLastElementTransformer
- */
-public final class ListLastElementTransformer_<E>
- implements Transformer<List<? extends E>, E>, Serializable
-{
- @SuppressWarnings("rawtypes")
- public static final Transformer INSTANCE = new ListLastElementTransformer_();
-
- @SuppressWarnings("unchecked")
- public static <E> Transformer<List<? extends E>, E> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private ListLastElementTransformer_() {
- super();
- }
-
- public E transform(List<? extends E> list) {
- return list.get(list.size() - 1);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/MapTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/MapTransformer.java
deleted file mode 100644
index 80111a3d8c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/MapTransformer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import java.util.Map;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * A transformer that will map the input to an output via a client-configured
- * map.
- *
- * @param <I> input: the type of the object passed to the transformer
- * (i.e. the type of the map's keys)
- * @param <O> output: the type of the object returned by the transformer
- * (i.e. the type of the map's values)
- */
-public class MapTransformer<I, O>
- implements Transformer<I, O>
-{
- private final Map<? super I, ? extends O> map;
-
-
- public MapTransformer(Map<? super I, ? extends O> map) {
- super();
- if (map == null) {
- throw new NullPointerException();
- }
- this.map = map;
- }
-
- public O transform(I input) {
- return this.map.get(input);
- }
-
- public Map<? super I, ? extends O> getMap() {
- return this.map;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.map);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/MethodTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/MethodTransformer.java
deleted file mode 100644
index 67c0f14957..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/MethodTransformer.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import java.io.Serializable;
-import java.util.Arrays;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.ClassTools;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * A transformer that uses Java reflection to transform an object into the
- * value returned of one of its methods.
- * <p>
- * <strong>NB:</strong> The actual method is determined at execution time,
- * not construction time. As a result, the transformer can be used to emulate
- * "duck typing".
- *
- * @param <I> input: the type of objects passed to the transformer
- * @param <O> output: the type of objects returned by the transformer
- *
- * @see FieldTransformer
- * @see Class#getDeclaredMethod(String, Class...)
- * @see java.lang.reflect.Method#invoke(Object, Object...)
- */
-public class MethodTransformer<I, O>
- implements Transformer<I, O>, Serializable
-{
- private final String methodName;
- private final Class<?>[] parameterTypes;
- private final Object[] arguments;
-
- private static final long serialVersionUID = 1L;
-
-
- public MethodTransformer(String methodName, Class<?>[] parameterTypes, Object[] arguments) {
- super();
- if ((methodName == null) || ArrayTools.isOrContainsNull(parameterTypes) || (arguments == null)) {
- throw new NullPointerException();
- }
- this.methodName = methodName;
- this.parameterTypes = parameterTypes;
- this.arguments = arguments;
- }
-
- @SuppressWarnings("unchecked")
- public O transform(I input) {
- return (O) ObjectTools.execute(input, this.methodName, this.parameterTypes, this.arguments);
- }
-
- public String getMethodName() {
- return this.methodName;
- }
-
- public Class<?>[] getParameterTypes() {
- return this.parameterTypes;
- }
-
- public Object[] getArguments() {
- return this.arguments;
- }
-
- @Override
- public boolean equals(Object o) {
- if ( ! (o instanceof MethodTransformer<?, ?>)) {
- return false;
- }
- MethodTransformer<?, ?> other = (MethodTransformer<?, ?>) o;
- return ObjectTools.equals(this.methodName, other.methodName) &&
- Arrays.equals(this.parameterTypes, other.parameterTypes) &&
- Arrays.equals(this.arguments, other.arguments);
- }
-
- @Override
- public int hashCode() {
- return this.methodName.hashCode() ^ Arrays.hashCode(this.parameterTypes) ^ Arrays.hashCode(this.arguments);
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, ClassTools.buildMethodSignature(this.methodName, this.parameterTypes));
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NotBooleanTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NotBooleanTransformer.java
deleted file mode 100644
index f49da717bc..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NotBooleanTransformer.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 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;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.BooleanTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * A <code>NotBooleanTransformer</code> will transform a
- * {@link Boolean} to its NOT value:<ul>
- * <li>If the original {@link Boolean} is {@link Boolean#TRUE},
- * the transformer will return {@link Boolean#FALSE}.
- * <li>If the original {@link Boolean} is {@link Boolean#FALSE},
- * the transformer will return {@link Boolean#TRUE}.
- * <li>If the original {@link Boolean} is <code>null</code>,
- * the transformer will return <code>null</code>.
- * </ul>
- */
-public final class NotBooleanTransformer
- implements Transformer<Boolean, Boolean>, Serializable
-{
- public static final Transformer<Boolean, Boolean> INSTANCE = new NotBooleanTransformer();
-
- public static Transformer<Boolean, Boolean> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private NotBooleanTransformer() {
- super();
- }
-
- public Boolean transform(Boolean b) {
- return (b == null) ? null : BooleanTools.not(b);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullCheckInterruptibleTransformerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullCheckInterruptibleTransformerWrapper.java
deleted file mode 100644
index 3153f86f06..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullCheckInterruptibleTransformerWrapper.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-
-/**
- * @see NullCheckTransformerWrapper
- */
-public class NullCheckInterruptibleTransformerWrapper<I, O>
- implements InterruptibleTransformer<I, O>
-{
- private final InterruptibleTransformer<? super I, ? extends O> transformer;
- private final O nullOutput;
-
-
- public NullCheckInterruptibleTransformerWrapper(InterruptibleTransformer<? super I, ? extends O> transformer, O nullOutput) {
- super();
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- this.nullOutput = nullOutput;
- }
-
- public O transform(I input) throws InterruptedException {
- return (input == null) ? this.nullOutput : this.transformer.transform(input);
- }
-
- public InterruptibleTransformer<? super I, ? extends O> getTransformer() {
- return this.transformer;
- }
-
- public O getNullOutput() {
- return this.nullOutput;
- }
-
- @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/internal/transformer/NullCheckTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullCheckTransformer.java
deleted file mode 100644
index e427ece3e1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullCheckTransformer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Tranformer that checks for <code>null</code> input.
- * If the input is <code>null</code>,
- * the transformer will return the configured output value;
- * otherwise, it will simply return the input.
- *
- * @param <I> input: the type of the object passed to and
- * returned by the transformer
- */
-public class NullCheckTransformer<I>
- implements Transformer<I, I>
-{
- private final I nullOutput;
-
-
- public NullCheckTransformer(I nullOutput) {
- super();
- this.nullOutput = nullOutput;
- }
-
- public I transform(I input) {
- return (input != null) ? input : this.nullOutput;
- }
-
- public I getNullOutput() {
- return this.nullOutput;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.nullOutput);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullCheckTransformerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullCheckTransformerWrapper.java
deleted file mode 100644
index ac965fbc89..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullCheckTransformerWrapper.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Tranformer wrapper that checks for <code>null</code> input before forwarding
- * the input to the wrapped transformer. If the input is <code>null</code>,
- * the transformer will return the configured output value.
- *
- * @param <I> input: the type of the object passed to the transformer
- * @param <O> output: the type of the object returned by the transformer
- */
-public class NullCheckTransformerWrapper<I, O>
- implements Transformer<I, O>
-{
- private final Transformer<? super I, ? extends O> transformer;
- private final O nullOutput;
-
-
- public NullCheckTransformerWrapper(Transformer<? super I, ? extends O> transformer, O nullOutput) {
- super();
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- this.nullOutput = nullOutput;
- }
-
- public O transform(I input) {
- return (input == null) ? this.nullOutput : this.transformer.transform(input);
- }
-
- public Transformer<? super I, ? extends O> getTransformer() {
- return this.transformer;
- }
-
- public O getNullOutput() {
- return this.nullOutput;
- }
-
- @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/internal/transformer/NullOutputTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullOutputTransformer.java
deleted file mode 100644
index e7ec6af68b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/NullOutputTransformer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * 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.internal.transformer;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * A transformer that will transform every input into <code>null</code>.
- *
- * @param <I> input: the type of the object passed to the transformer
- * @param <O> output: the type of the object returned by the transformer
- *
- * @see TransformerAdapter
- */
-public final class NullOutputTransformer<I, O>
- implements Transformer<I, O>, Serializable
-{
- @SuppressWarnings("rawtypes")
- public static final Transformer INSTANCE = new NullOutputTransformer();
-
- @SuppressWarnings("unchecked")
- public static <I, O> Transformer<I, O> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private NullOutputTransformer() {
- super();
- }
-
- /**
- * Return <code>null</code>.
- */
- public O transform(I input) {
- return null;
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ObjectToStringTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ObjectToStringTransformer.java
deleted file mode 100644
index a2e74bdcb0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/ObjectToStringTransformer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Transform a non-<code>null</code> object into the string returned by its
- * {@link Object#toString()} method. A <code>null</code> input will trigger
- * a {@link NullPointerException}.
- *
- * @param <I> input: the type of the object passed to the transformer
- */
-public final class ObjectToStringTransformer<I>
- implements Transformer<I, String>, Serializable
-{
- @SuppressWarnings("rawtypes")
- public static final Transformer INSTANCE = new ObjectToStringTransformer();
-
- @SuppressWarnings("unchecked")
- public static <I> Transformer<I, String> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private ObjectToStringTransformer() {
- super();
- }
-
- /**
- * Return the specified input's {@link Object#toString() string
- * representation}.
- */
- public String transform(I input) {
- return input.toString();
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/PassThruTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/PassThruTransformer.java
deleted file mode 100644
index d378a12897..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/PassThruTransformer.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * A transformer that will perform no transformation at all;
- * it will simply return the input.
- *
- * @param <I> input: the type of the object passed to the transformer
- */
-public final class PassThruTransformer<I>
- implements Transformer<I, I>, Serializable
-{
- @SuppressWarnings("rawtypes")
- public static final Transformer INSTANCE = new PassThruTransformer();
-
- @SuppressWarnings("unchecked")
- public static <I> Transformer<I, I> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private PassThruTransformer() {
- super();
- }
-
- /**
- * Return the specified input, unchanged.
- */
- public I transform(I input) {
- return input;
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SafeInterruptibleTransformerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SafeInterruptibleTransformerWrapper.java
deleted file mode 100644
index 3687e1020c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SafeInterruptibleTransformerWrapper.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.exception.ExceptionHandler;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-
-/**
- * @see SafeTransformerWrapper
- */
-public class SafeInterruptibleTransformerWrapper<I, O>
- implements InterruptibleTransformer<I, O>
-{
- private final InterruptibleTransformer<? super I, ? extends O> transformer;
- private final ExceptionHandler exceptionHandler;
- private final O exceptionOutput;
-
-
- public SafeInterruptibleTransformerWrapper(InterruptibleTransformer<? super I, ? extends O> transformer, ExceptionHandler exceptionHandler, O exceptionOutput) {
- super();
- if ((transformer == null) || (exceptionHandler == null)) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- this.exceptionHandler = exceptionHandler;
- this.exceptionOutput = exceptionOutput;
- }
-
- public O transform(I input) throws InterruptedException {
- try {
- return this.transformer.transform(input);
- } catch (InterruptedException ex) {
- throw ex;
- } catch (Throwable ex) {
- this.exceptionHandler.handleException(ex);
- return this.exceptionOutput;
- }
- }
-
- public InterruptibleTransformer<? super I, ? extends O> getTransformer() {
- return this.transformer;
- }
-
- public ExceptionHandler getExceptionHandler() {
- return this.exceptionHandler;
- }
-
- public O getExceptionOutput() {
- return this.exceptionOutput;
- }
-
- @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/internal/transformer/SafeTransformerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SafeTransformerWrapper.java
deleted file mode 100644
index 8da4278775..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SafeTransformerWrapper.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.exception.ExceptionHandler;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Transformer wrapper that will handle any exceptions thrown by the wrapped
- * transformer with an {@link ExceptionHandler exception handler}. If the
- * wrapped transformer throws an exception, the safe transformer will handle
- * the exception and return a client-configured output.
- *
- * @param <I> input: the type of the object passed to the transformer
- * @param <O> output: the type of the object returned by the transformer
- */
-public class SafeTransformerWrapper<I, O>
- implements Transformer<I, O>
-{
- private final Transformer<? super I, ? extends O> transformer;
- private final ExceptionHandler exceptionHandler;
- private final O exceptionOutput;
-
-
- public SafeTransformerWrapper(Transformer<? super I, ? extends O> transformer, ExceptionHandler exceptionHandler, O exceptionOutput) {
- super();
- if ((transformer == null) || (exceptionHandler == null)) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- this.exceptionHandler = exceptionHandler;
- this.exceptionOutput = exceptionOutput;
- }
-
- public O transform(I input) {
- try {
- return this.transformer.transform(input);
- } catch (Throwable ex) {
- this.exceptionHandler.handleException(ex);
- return this.exceptionOutput;
- }
- }
-
- public Transformer<? super I, ? extends O> getTransformer() {
- return this.transformer;
- }
-
- public ExceptionHandler getExceptionHandler() {
- return this.exceptionHandler;
- }
-
- public O getExceptionOutput() {
- return this.exceptionOutput;
- }
-
- @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/internal/transformer/StaticOutputTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/StaticOutputTransformer.java
deleted file mode 100644
index 152daf70c8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/StaticOutputTransformer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Transform any object, except <code>null</code>, into a single
- * client-specified object. Any <code>null</code> object will be
- * transformed into <code>null</code>.
- *
- * @param <I> input: the type of the object passed to the transformer
- * @param <O> output: the type of the object returned by the transformer
- * @see NullOutputTransformer
- */
-public class StaticOutputTransformer<I, O>
- implements Transformer<I, O>
-{
- private final O output;
-
-
- public StaticOutputTransformer(O output) {
- super();
- this.output = output;
- }
-
- public O transform(I input) {
- return this.output;
- }
-
- public O getOutput() {
- return this.output;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.output);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/StringToBooleanTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/StringToBooleanTransformer.java
deleted file mode 100644
index 1c35d258e5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/StringToBooleanTransformer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Transform a {@link String} into a {@link Boolean} (i.e. transform
- * a string equal to <code>"true"</code> (ignoring case) into
- * {@link Boolean#TRUE}; transform all other
- * strings into {@link Boolean#FALSE}).
- * @see Boolean#valueOf(String)
- */
-public final class StringToBooleanTransformer
- implements Transformer<String, Boolean>, Serializable
-{
- public static final Transformer<String, Boolean> INSTANCE = new StringToBooleanTransformer();
-
- public static Transformer<String, Boolean> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private StringToBooleanTransformer() {
- super();
- }
-
- /**
- * @see Boolean#valueOf(String)
- */
- public Boolean transform(String string) {
- return Boolean.valueOf(string);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/StringToIntegerTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/StringToIntegerTransformer.java
deleted file mode 100644
index 11f4e6bc8d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/StringToIntegerTransformer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Transform a {@link String} into an {@link Integer} if possible.
- * @see Integer#valueOf(String)
- */
-public final class StringToIntegerTransformer
- implements Transformer<String, Integer>, Serializable
-{
- public static final Transformer<String, Integer> INSTANCE = new StringToIntegerTransformer();
-
- public static Transformer<String, Integer> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private StringToIntegerTransformer() {
- super();
- }
-
- /**
- * @see Integer#valueOf(String)
- */
- public Integer transform(String string) {
- return Integer.valueOf(string);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SwitchInterruptibleTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SwitchInterruptibleTransformer.java
deleted file mode 100644
index fa23b0b797..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SwitchInterruptibleTransformer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.Association;
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.common.utility.predicate.Predicate;
-
-/**
- * @see SwitchTransformer
- */
-public class SwitchInterruptibleTransformer<I, O>
- implements InterruptibleTransformer<I, O>
-{
- private final Iterable<Association<Predicate<? super I>, InterruptibleTransformer<? super I, ? extends O>>> transformers;
- private final InterruptibleTransformer<? super I, ? extends O> defaultInterruptibleTransformer;
-
- public SwitchInterruptibleTransformer(Iterable<Association<Predicate<? super I>, InterruptibleTransformer<? super I, ? extends O>>> transformers, InterruptibleTransformer<? super I, ? extends O> defaultInterruptibleTransformer) {
- super();
- if (IterableTools.isOrContainsNull(transformers) || (defaultInterruptibleTransformer == null)) {
- throw new NullPointerException();
- }
- this.transformers = transformers;
- this.defaultInterruptibleTransformer = defaultInterruptibleTransformer;
- }
-
- public O transform(I input) throws InterruptedException {
- for (Association<Predicate<? super I>, InterruptibleTransformer<? super I, ? extends O>> association : this.transformers) {
- if (association.getKey().evaluate(input)) {
- return association.getValue().transform(input); // execute only one transformer
- }
- }
- return this.defaultInterruptibleTransformer.transform(input);
- }
-
- public Iterable<Association<Predicate<? super I>, InterruptibleTransformer<? super I, ? extends O>>> getTransformers() {
- return this.transformers;
- }
-
- public InterruptibleTransformer<? super I, ? extends O> getDefaultInterruptibleTransformer() {
- return this.defaultInterruptibleTransformer;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.transformers);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SwitchTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SwitchTransformer.java
deleted file mode 100644
index 3d04ecd17f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/SwitchTransformer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.Association;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.common.utility.predicate.Predicate;
-
-/**
- * Transformer that loops over a configured set of predicate/transformer pairs,
- * passing its input to each predicate to determine
- * which of the transformers to execute. Only the first transformer whose predicate
- * evaluates to <code>true</code> is executed, even if other, following,
- * predicates would evaluate to <code>true</code>.
- * If none of the predicates evaluates to <code>true</code>, the default transformer
- * is executed.
- *
- * @param <I> input: the type of the object passed to the transformer
- * @param <O> output: the type of the object returned by the transformer
- */
-public class SwitchTransformer<I, O>
- implements Transformer<I, O>
-{
- private final Iterable<Association<Predicate<? super I>, Transformer<? super I, ? extends O>>> transformers;
- private final Transformer<? super I, ? extends O> defaultTransformer;
-
- public SwitchTransformer(Iterable<Association<Predicate<? super I>, Transformer<? super I, ? extends O>>> transformers, Transformer<? super I, ? extends O> defaultTransformer) {
- super();
- if (IterableTools.isOrContainsNull(transformers) || (defaultTransformer == null)) {
- throw new NullPointerException();
- }
- this.transformers = transformers;
- this.defaultTransformer = defaultTransformer;
- }
-
- public O transform(I input) {
- for (Association<Predicate<? super I>, Transformer<? super I, ? extends O>> association : this.transformers) {
- if (association.getKey().evaluate(input)) {
- return association.getValue().transform(input); // execute only one transformer
- }
- }
- return this.defaultTransformer.transform(input);
- }
-
- public Iterable<Association<Predicate<? super I>, Transformer<? super I, ? extends O>>> getTransformers() {
- return this.transformers;
- }
-
- public Transformer<? super I, ? extends O> getDefaultTransformer() {
- return this.defaultTransformer;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.transformers);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerAdapter.java
index 25dfc7e0c7..d1446639ab 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerAdapter.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerAdapter.java
@@ -19,7 +19,7 @@ import org.eclipse.jpt.common.utility.transformer.Transformer;
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
*
- * @see NullOutputTransformer
+ * @see TransformerTools#nullOutputTransformer()
*/
public class TransformerAdapter<I, O>
implements Transformer<I, O>
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerCallable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerCallable.java
deleted file mode 100644
index d1b863617d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerCallable.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import java.util.concurrent.Callable;
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-
-/**
- * Adapter class that adapts a {@link InterruptibleTransformer transformer}
- * and an appropriate input to the {@Callable} interface.
- *
- * @param <I> input: the type of the object passed to the transformer
- * @param <O> output: the type of the object returned by the transformer
- * (and the callable)
- */
-public class TransformerCallable<I, O>
- implements Callable<O>
-{
- private final InterruptibleTransformer<? super I, ? extends O> transformer;
- private final I input;
-
-
- public TransformerCallable(InterruptibleTransformer<? super I, ? extends O> transformer, I input) {
- super();
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- this.input = input;
- }
-
- public O call() throws InterruptedException {
- return this.transformer.transform(this.input);
- }
-
- public InterruptibleTransformer<? super I, ? extends O> getTransformer() {
- return this.transformer;
- }
-
- public I getInput() {
- return this.input;
- }
-
- @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/internal/transformer/TransformerChain.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerChain.java
deleted file mode 100644
index 0c052a2f25..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerChain.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * A chain of transformers. Pass the chain's input to the first
- * transformer; take that transformer's output and pass it to the following
- * transformer in the chain; etc. The output from the final transformer is
- * returned as the chain's output.
- * <p>
- * <strong>NB:</strong> The transformer's generic types are for convenience only
- * and cannot be enforced on the transformers in the chain.
- *
- * @param <I> input: the type of the object passed to the transformer
- * @param <O> output: the type of the object returned by the transformer
- */
-public class TransformerChain<I, O>
- implements Transformer<I, O>
-{
- private final Iterable<Transformer<?, ?>> transformers;
-
- public TransformerChain(Iterable<Transformer<?, ?>> transformers) {
- super();
- if (IterableTools.isOrContainsNull(transformers)) {
- throw new NullPointerException();
- }
- this.transformers = transformers;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public O transform(I input) {
- Object result = input;
- for (Transformer transformer : this.transformers) {
- result = transformer.transform(result);
- }
- return (O) result;
- }
-
- public Iterable<Transformer<?, ?>> getTransformers() {
- return this.transformers;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.transformers);
- }
-}
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 1d2402777c..714ddd26aa 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
@@ -18,10 +18,14 @@ import java.util.concurrent.FutureTask;
import java.util.concurrent.RunnableFuture;
import org.eclipse.jpt.common.utility.Association;
import org.eclipse.jpt.common.utility.closure.Closure;
+import org.eclipse.jpt.common.utility.closure.InterruptibleClosure;
import org.eclipse.jpt.common.utility.command.Command;
+import org.eclipse.jpt.common.utility.command.InterruptibleCommand;
import org.eclipse.jpt.common.utility.exception.ExceptionHandler;
import org.eclipse.jpt.common.utility.factory.Factory;
+import org.eclipse.jpt.common.utility.factory.InterruptibleFactory;
import org.eclipse.jpt.common.utility.internal.ArrayTools;
+import org.eclipse.jpt.common.utility.internal.BooleanTools;
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;
@@ -57,7 +61,44 @@ public final class TransformerTools {
* @param <O> output: the type of the object returned by the transformer
*/
public static <I, O> Transformer<I, O> adapt(Closure<? super I> closure) {
- return new ClosureTransformer<>(closure);
+ ObjectTools.assertNotNull(closure);
+ return input -> {
+ closure.execute(input);
+ return null;
+ };
+ }
+
+ /**
+ * Adapt the specified {@link InterruptibleClosure} to the
+ * {@link InterruptibleTransformer} interface.
+ * The returned transformer will always return <code>null</code>.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ */
+ public static <I, O> InterruptibleTransformer<I, O> adapt(InterruptibleClosure<? super I> closure) {
+ ObjectTools.assertNotNull(closure);
+ return input -> {
+ closure.execute(input);
+ return null;
+ };
+ }
+
+ /**
+ * Adapt the specified {@link InterruptibleCommand} to the
+ * {@link InterruptibleTransformer} interface.
+ * The returned transformer will always return <code>null</code> and its
+ * input will be ignored.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ */
+ public static <I, O> InterruptibleTransformer<I, O> adapt(InterruptibleCommand command) {
+ ObjectTools.assertNotNull(command);
+ return input -> {
+ command.execute();
+ return null;
+ };
}
/**
@@ -69,7 +110,11 @@ public final class TransformerTools {
* @param <O> output: the type of the object returned by the transformer
*/
public static <I, O> Transformer<I, O> adapt(Command command) {
- return new CommandTransformer<>(command);
+ ObjectTools.assertNotNull(command);
+ return input -> {
+ command.execute();
+ return null;
+ };
}
/**
@@ -81,7 +126,22 @@ public final class TransformerTools {
* @param <O> output: the type of the object returned by the transformer
*/
public static <I, O> Transformer<I, O> adapt(Factory<? extends O> factory) {
- return new FactoryTransformer<>(factory);
+ ObjectTools.assertNotNull(factory);
+ return input -> factory.create();
+ }
+
+ /**
+ * Adapt the specified {@link InterruptibleFactory} to the
+ * {@link InterruptibleTransformer} interface.
+ * The returned transformer will return the factory's output and its
+ * input will be ignored.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ */
+ public static <I, O> InterruptibleTransformer<I, O> adapt(InterruptibleFactory<? extends O> factory) {
+ ObjectTools.assertNotNull(factory);
+ return input -> factory.create();
}
/**
@@ -109,8 +169,9 @@ public final class TransformerTools {
* @param <O> output: the type of the object returned by the transformer
* (and callable)
*/
- public static <I, O> TransformerCallable<I, O> callable(InterruptibleTransformer<? super I, ? extends O> transformer, I input) {
- return new TransformerCallable<>(transformer, input);
+ public static <I, O> Callable<O> callable(InterruptibleTransformer<? super I, ? extends O> transformer, I input) {
+ ObjectTools.assertNotNull(transformer);
+ return () -> transformer.transform(input);
}
@@ -127,7 +188,6 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
*
- * @see ObjectToStringTransformer
* @see String#valueOf(Object)
* @see #objectToStringTransformer()
* @see #objectToStringTransformer(String)
@@ -146,7 +206,6 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
*
- * @see ObjectToStringTransformer
* @see Object#toString()
* @see #objectToStringTransformer(String)
* @see #objectToStringTransformer_()
@@ -164,7 +223,6 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
*
- * @see ObjectToStringTransformer
* @see Object#toString()
* @see #objectToStringTransformer()
* @see #objectToStringTransformer_()
@@ -183,14 +241,13 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
*
- * @see ObjectToStringTransformer
* @see Object#toString()
* @see #objectToStringTransformer()
* @see #objectToStringTransformer(String)
* @see #stringFromObjectTransformer()
*/
public static <I> Transformer<I, String> objectToStringTransformer_() {
- return ObjectToStringTransformer.instance();
+ return input -> input.toString();
}
@@ -206,7 +263,6 @@ public final class TransformerTools {
* <li>If the original {@link Boolean} is <code>null</code>,
* the transformer will return the specified value.
* </ul>
- * @see NotBooleanTransformer
* @see #notBooleanTransformer()
*/
public static Transformer<Boolean, Boolean> notBooleanTransformer(Boolean nullBoolean) {
@@ -223,11 +279,10 @@ public final class TransformerTools {
* <li>If the original {@link Boolean} is <code>null</code>,
* the transformer will return <code>null</code>.
* </ul>
- * @see NotBooleanTransformer
* @see #notBooleanTransformer(Boolean)
*/
public static Transformer<Boolean, Boolean> notBooleanTransformer() {
- return NotBooleanTransformer.instance();
+ return b -> (b == null) ? null : BooleanTools.not(b);
}
/**
@@ -320,6 +375,7 @@ public final class TransformerTools {
* @see #adapt(Predicate, Boolean)
*/
public static <I> Transformer<I, Boolean> adapt(Predicate<? super I> predicate) {
+ ObjectTools.assertNotNull(predicate);
return input -> Boolean.valueOf(predicate.evaluate(input));
}
@@ -333,7 +389,6 @@ public final class TransformerTools {
* <strong>NB:</strong> The transformer will return <code>null</code>
* if it is passed a <code>null</code> input.
*
- * @see StringToBooleanTransformer
* @see Boolean#valueOf(String)
* @see #stringToBooleanTransformer(Boolean)
* @see #stringToBooleanTransformer_()
@@ -347,7 +402,6 @@ public final class TransformerTools {
* {@link Boolean}. The transformer will return the specified value
* if it is passed a <code>null</code> input.
*
- * @see StringToBooleanTransformer
* @see Boolean#valueOf(String)
* @see #stringToBooleanTransformer()
* @see #stringToBooleanTransformer_()
@@ -363,13 +417,12 @@ public final class TransformerTools {
* <strong>NB:</strong> The transformer will return {@link Boolean#FALSE}
* if it is passed a <code>null</code> input.
*
- * @see StringToBooleanTransformer
* @see Boolean#valueOf(String)
* @see #stringToBooleanTransformer(Boolean)
* @see #stringToBooleanTransformer()
*/
public static Transformer<String, Boolean> stringToBooleanTransformer_() {
- return StringToBooleanTransformer.instance();
+ return string -> Boolean.valueOf(string);
}
/**
@@ -379,7 +432,6 @@ public final class TransformerTools {
* <strong>NB:</strong> The transformer will return <code>null</code>
* if it is passed a <code>null</code> input.
*
- * @see StringToIntegerTransformer
* @see Integer#valueOf(String)
* @see #stringToIntegerTransformer(Integer)
* @see #stringToIntegerTransformer_()
@@ -393,7 +445,6 @@ public final class TransformerTools {
* {@link Integer}. The transformer will return the specified value
* if it is passed a <code>null</code> input.
*
- * @see StringToIntegerTransformer
* @see Integer#valueOf(String)
* @see #stringToIntegerTransformer()
* @see #stringToIntegerTransformer_()
@@ -409,13 +460,12 @@ public final class TransformerTools {
* <strong>NB:</strong> The transformer will throw a
* {@link NumberFormatException} if it is passed a <code>null</code> input.
*
- * @see StringToIntegerTransformer
* @see Integer#valueOf(String)
* @see #stringToIntegerTransformer()
* @see #stringToIntegerTransformer(Integer)
*/
public static Transformer<String, Integer> stringToIntegerTransformer_() {
- return StringToIntegerTransformer.instance();
+ return string -> Integer.valueOf(string);
}
@@ -544,9 +594,11 @@ public final class TransformerTools {
* If the list is empty, the transformer returns <code>null</code>.
*
* @param <E> the type of elements held by the list
+ *
+ * @see #listLastElementTransformer_()
*/
public static <E> Transformer<List<? extends E>, E> listLastElementTransformer() {
- return ListLastElementTransformer.instance();
+ return list -> list.isEmpty() ? null : list.get(list.size() - 1);
}
/**
@@ -554,9 +606,11 @@ public final class TransformerTools {
* If the list is empty, the transformer throws an {@link IndexOutOfBoundsException}.
*
* @param <E> the type of elements held by the list
+ *
+ * @see #listLastElementTransformer()
*/
public static <E> Transformer<List<? extends E>, E> listLastElementTransformer_() {
- return ListLastElementTransformer_.instance();
+ return list -> list.get(list.size() - 1);
}
@@ -616,7 +670,7 @@ public final class TransformerTools {
* @see ThreadLocalTransformer
*/
public static <I, O> ThreadLocalTransformer<I, O> threadLocalTransformer() {
- return threadLocalTransformer(NullOutputTransformer.<I, O>instance());
+ return threadLocalTransformer(nullOutputTransformer());
}
/**
@@ -673,11 +727,10 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer; also the
* type of object returned by the output iterator
- *
- * @see IterableTransformerWrapper
*/
public static <I> Transformer<I, Iterator<? extends I>> toIterator(Transformer<? super I, ? extends Iterable<? extends I>> transformer) {
- return new IterableTransformerWrapper<>(transformer);
+ ObjectTools.assertNotNull(transformer);
+ return input -> transformer.transform(input).iterator();
}
/**
@@ -689,12 +742,11 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to and
* returned by the transformer
*
- * @see NullCheckTransformer
* @see #nullCheck(Transformer)
* @see #nullCheck(Transformer, Object)
*/
public static <I> Transformer<I, I> nullCheck(I nullOutput) {
- return new NullCheckTransformer<>(nullOutput);
+ return input -> (input != null) ? input : nullOutput;
}
/**
@@ -706,7 +758,6 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
*
- * @see NullCheckTransformerWrapper
* @see #nullCheck(Transformer, Object)
* @see #nullCheck(Object)
*/
@@ -723,12 +774,45 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
*
- * @see NullCheckTransformerWrapper
* @see #nullCheck(Transformer)
* @see #nullCheck(Object)
*/
public static <I, O> Transformer<I, O> nullCheck(Transformer<? super I, ? extends O> transformer, O nullOutput) {
- return new NullCheckTransformerWrapper<>(transformer, nullOutput);
+ ObjectTools.assertNotNull(transformer);
+ return input -> (input == null) ? nullOutput : transformer.transform(input);
+ }
+
+ /**
+ * Return a transformer that wraps the specified transformer and checks
+ * for <code>null</code> input before forwarding the input to the specified
+ * transformer. If the input is <code>null</code>, the transformer will
+ * return <code>null</code>.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ *
+ * @see #nullCheck(InterruptibleTransformer, Object)
+ * @see #nullCheck(Object)
+ */
+ public static <I, O> InterruptibleTransformer<I, O> nullCheck(InterruptibleTransformer<? super I, ? extends O> transformer) {
+ return nullCheck(transformer, null);
+ }
+
+ /**
+ * Return a transformer that wraps the specified transformer and checks
+ * for <code>null</code> input before forwarding the input to the specified
+ * transformer. If the input is <code>null</code>, the transformer will
+ * return the specified output value.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ *
+ * @see #nullCheck(InterruptibleTransformer)
+ * @see #nullCheck(Object)
+ */
+ public static <I, O> InterruptibleTransformer<I, O> nullCheck(InterruptibleTransformer<? super I, ? extends O> transformer, O nullOutput) {
+ ObjectTools.assertNotNull(transformer);
+ return input -> (input == null) ? nullOutput : transformer.transform(input);
}
/**
@@ -758,12 +842,13 @@ public final class TransformerTools {
* is the same object returned by the wrapped transformer, simply
* cast to <code>O</code>
*
- * @see CastingTransformerWrapper
* @see #upcast(Transformer)
* @see #downcast(Transformer)
*/
+ @SuppressWarnings("unchecked")
public static <I, X, O> Transformer<I, O> cast(Transformer<? super I, ? extends X> transformer) {
- return new CastingTransformerWrapper<I, X, O>(transformer);
+ ObjectTools.assertNotNull(transformer);
+ return input -> (O) transformer.transform(input);
}
/**
@@ -776,12 +861,13 @@ public final class TransformerTools {
* is the same object returned by the wrapped transformer, simply
* cast to <code>O</code>
*
- * @see DowncastingTransformerWrapper
* @see #cast(Transformer)
* @see #upcast(Transformer)
*/
+ @SuppressWarnings("unchecked")
public static <I, X, O extends X> Transformer<I, O> downcast(Transformer<? super I, ? extends X> transformer) {
- return new DowncastingTransformerWrapper<>(transformer);
+ ObjectTools.assertNotNull(transformer);
+ return input -> (O) transformer.transform(input);
}
/**
@@ -794,12 +880,68 @@ public final class TransformerTools {
* @param <X> intermediate: the type of object returned by the wrapped
* transformer
*
- * @see UpcastingTransformerWrapper
* @see #cast(Transformer)
* @see #downcast(Transformer)
*/
public static <I, O, X extends O> Transformer<I, O> upcast(Transformer<? super I, ? extends X> transformer) {
- return new UpcastingTransformerWrapper<I, O, X>(transformer);
+ ObjectTools.assertNotNull(transformer);
+ return input -> (O) transformer.transform(input);
+ }
+
+ /**
+ * Return a transformer that simply casts the specified transformer's return type.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <X> intermediate: the type of object returned by the wrapped
+ * transformer
+ * @param <O> output: the type of object returned by the transformer - this
+ * is the same object returned by the wrapped transformer, simply
+ * cast to <code>O</code>
+ *
+ * @see #upcast(InterruptibleTransformer)
+ * @see #downcast(InterruptibleTransformer)
+ */
+ @SuppressWarnings("unchecked")
+ public static <I, X, O> InterruptibleTransformer<I, O> cast(InterruptibleTransformer<? super I, ? extends X> transformer) {
+ ObjectTools.assertNotNull(transformer);
+ return input -> (O) transformer.transform(input);
+ }
+
+ /**
+ * Return a transformer that simply downcasts the specified transformer's return type.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <X> intermediate: the type of object returned by the wrapped
+ * transformer
+ * @param <O> output: the type of object returned by the transformer - this
+ * is the same object returned by the wrapped transformer, simply
+ * cast to <code>O</code>
+ *
+ * @see #cast(InterruptibleTransformer)
+ * @see #upcast(InterruptibleTransformer)
+ */
+ @SuppressWarnings("unchecked")
+ public static <I, X, O extends X> InterruptibleTransformer<I, O> downcast(InterruptibleTransformer<? super I, ? extends X> transformer) {
+ ObjectTools.assertNotNull(transformer);
+ return input -> (O) transformer.transform(input);
+ }
+
+ /**
+ * Return a transformer that simply upcasts the specified transformer's return type.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of object returned by the transformer - this
+ * is the same object returned by the wrapped transformer, simply
+ * cast to <code>O</code>
+ * @param <X> intermediate: the type of object returned by the wrapped
+ * transformer
+ *
+ * @see #cast(InterruptibleTransformer)
+ * @see #downcast(InterruptibleTransformer)
+ */
+ public static <I, O, X extends O> InterruptibleTransformer<I, O> upcast(InterruptibleTransformer<? super I, ? extends X> transformer) {
+ ObjectTools.assertNotNull(transformer);
+ return input -> (O) transformer.transform(input);
}
@@ -815,7 +957,9 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
*
- * @see SafeTransformerWrapper
+ * @see #safe(Transformer, Object)
+ * @see #safe(Transformer, ExceptionHandler)
+ * @see #safe(Transformer, ExceptionHandler, Object)
* @see DefaultExceptionHandler
*/
public static <I, O> Transformer<I, O> safe(Transformer<? super I, ? extends O> transformer) {
@@ -832,7 +976,9 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
*
- * @see SafeTransformerWrapper
+ * @see #safe(Transformer)
+ * @see #safe(Transformer, ExceptionHandler)
+ * @see #safe(Transformer, ExceptionHandler, Object)
* @see DefaultExceptionHandler
*/
public static <I, O> Transformer<I, O> safe(Transformer<? super I, ? extends O> transformer, O exceptionOutput) {
@@ -848,7 +994,9 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
*
- * @see SafeTransformerWrapper
+ * @see #safe(Transformer)
+ * @see #safe(Transformer, Object)
+ * @see #safe(Transformer, ExceptionHandler, Object)
*/
public static <I, O> Transformer<I, O> safe(Transformer<? super I, ? extends O> transformer, ExceptionHandler exceptionHandler) {
return safe(transformer, exceptionHandler, null);
@@ -863,10 +1011,107 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
*
- * @see SafeTransformerWrapper
+ * @see #safe(Transformer)
+ * @see #safe(Transformer, Object)
+ * @see #safe(Transformer, ExceptionHandler)
+ * @see #safe(InterruptibleTransformer, ExceptionHandler, Object)
*/
public static <I, O> Transformer<I, O> safe(Transformer<? super I, ? extends O> transformer, ExceptionHandler exceptionHandler, O exceptionOutput) {
- return new SafeTransformerWrapper<>(transformer, exceptionHandler, exceptionOutput);
+ ObjectTools.assertNotNull(transformer);
+ ObjectTools.assertNotNull(exceptionHandler);
+ return input -> {
+ try {
+ return transformer.transform(input);
+ } catch (Throwable ex) {
+ exceptionHandler.handleException(ex);
+ return exceptionOutput;
+ }
+ };
+ }
+
+ /**
+ * Return a transformer that wraps the specified transformer and handles
+ * any exceptions thrown during the transformation. If an exception is
+ * thrown, the exception's stack trace will be printed to {@link System#err
+ * the "standard" error output stream} and <code>null</code> will be
+ * returned.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ *
+ * @see #safe(InterruptibleTransformer, Object)
+ * @see #safe(InterruptibleTransformer, ExceptionHandler)
+ * @see #safe(InterruptibleTransformer, ExceptionHandler, Object)
+ * @see DefaultExceptionHandler
+ */
+ public static <I, O> InterruptibleTransformer<I, O> safe(InterruptibleTransformer<? super I, ? extends O> transformer) {
+ return safe(transformer, DefaultExceptionHandler.instance(), null);
+ }
+
+ /**
+ * Return a transformer that wraps the specified transformer and handles
+ * any exceptions thrown during the transformation. If an exception is
+ * thrown, the exception's stack trace will be printed to {@link System#err
+ * the "standard" error output stream}
+ * and specified output will be returned.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ *
+ * @see #safe(InterruptibleTransformer)
+ * @see #safe(InterruptibleTransformer, ExceptionHandler)
+ * @see #safe(InterruptibleTransformer, ExceptionHandler, Object)
+ * @see DefaultExceptionHandler
+ */
+ public static <I, O> InterruptibleTransformer<I, O> safe(InterruptibleTransformer<? super I, ? extends O> transformer, O exceptionOutput) {
+ return safe(transformer, DefaultExceptionHandler.instance(), exceptionOutput);
+ }
+
+ /**
+ * Return a transformer that wraps the specified transformer and handles
+ * any exceptions thrown during the transformation. If an exception is
+ * thrown, the exception will be passed to the specified exception handler
+ * and <code>null</code> will be returned.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ *
+ * @see #safe(InterruptibleTransformer)
+ * @see #safe(InterruptibleTransformer, Object)
+ * @see #safe(InterruptibleTransformer, ExceptionHandler, Object)
+ */
+ public static <I, O> InterruptibleTransformer<I, O> safe(InterruptibleTransformer<? super I, ? extends O> transformer, ExceptionHandler exceptionHandler) {
+ return safe(transformer, exceptionHandler, null);
+ }
+
+ /**
+ * Return a transformer that wraps the specified transformer and handles
+ * any exceptions (other than {@link InterruptedException}) thrown
+ * during the transformation. If an exception is
+ * thrown, the exception will be passed to the specified exception handler
+ * and specified output will be returned.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ *
+ * @see #safe(InterruptibleTransformer)
+ * @see #safe(InterruptibleTransformer, Object)
+ * @see #safe(InterruptibleTransformer, ExceptionHandler)
+ * @see #safe(Transformer, ExceptionHandler, Object)
+ */
+ public static <I, O> InterruptibleTransformer<I, O> safe(InterruptibleTransformer<? super I, ? extends O> transformer, ExceptionHandler exceptionHandler, O exceptionOutput) {
+ ObjectTools.assertNotNull(transformer);
+ ObjectTools.assertNotNull(exceptionHandler);
+ return input -> {
+ try {
+ return transformer.transform(input);
+ } catch (InterruptedException ex) {
+ throw ex;
+ } catch (Throwable ex) {
+ exceptionHandler.handleException(ex);
+ return exceptionOutput;
+ }
+ };
}
@@ -879,11 +1124,10 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to the transformer
* (and returned by the transformer)
*
- * @see PassThruTransformer
* @see #passThruTransformer(Object)
*/
public static <I> Transformer<I, I> passThruTransformer() {
- return PassThruTransformer.instance();
+ return input -> input;
}
/**
@@ -895,7 +1139,6 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to the transformer
* (and returned by the transformer)
*
- * @see PassThruTransformer
* @see #passThruTransformer()
*/
public static <I> Transformer<I, I> passThruTransformer(I nullOutput) {
@@ -928,7 +1171,8 @@ public final class TransformerTools {
* returned by the transformer
*/
public static <I> Transformer<I, I> filteringTransformer(Predicate<? super I> filter, I defaultOutput) {
- return new FilteringTransformer<>(filter, defaultOutput);
+ ObjectTools.assertNotNull(filter);
+ return input -> filter.evaluate(input) ? input : defaultOutput;
}
@@ -939,11 +1183,10 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* (and returned by the transformer)
- *
- * @see CloneTransformer
*/
+ @SuppressWarnings("unchecked")
public static <I extends Cloneable> Transformer<I, I> cloneTransformer() {
- return CloneTransformer.instance();
+ return input -> (I) ObjectTools.execute(input, "clone"); //$NON-NLS-1$
}
/**
@@ -953,11 +1196,9 @@ public final class TransformerTools {
*
* @param <O> output: the type of the object returned by the transformer (and
* the class, or superclass of the class, passed to the transformer)
- *
- * @see InstantiationTransformer
*/
public static <O> Transformer<Class<? extends O>, O> instantiationTransformer() {
- return InstantiationTransformer.instance();
+ return input -> ClassTools.newInstance(input);
}
/**
@@ -970,11 +1211,10 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
- *
- * @see FieldTransformer
*/
+ @SuppressWarnings("unchecked")
public static <I, O> Transformer<I, O> get(String fieldName) {
- return new FieldTransformer<>(fieldName);
+ return input -> (O) ObjectTools.get(input, fieldName);
}
/**
@@ -988,8 +1228,6 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
- *
- * @see MethodTransformer
*/
public static <I, O> Transformer<I, O> execute(String methodName) {
return execute(methodName, ClassTools.EMPTY_ARRAY, ObjectTools.EMPTY_OBJECT_ARRAY);
@@ -1006,8 +1244,6 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
- *
- * @see MethodTransformer
*/
public static <I, O> Transformer<I, O> execute(String methodName, Class<?> parameterType, Object argument) {
return execute(methodName, new Class<?>[] { parameterType }, new Object[] { argument });
@@ -1024,11 +1260,13 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
- *
- * @see MethodTransformer
*/
+ @SuppressWarnings("unchecked")
public static <I, O> Transformer<I, O> execute(String methodName, Class<?>[] parameterTypes, Object[] arguments) {
- return new MethodTransformer<>(methodName, parameterTypes, arguments);
+ ObjectTools.assertNotNull(methodName);
+ ArrayTools.assertNeitherIsNorContainsNull(parameterTypes);
+ ObjectTools.assertNotNull(arguments);
+ return input -> (O) ObjectTools.execute(input, methodName, parameterTypes, arguments);
}
@@ -1052,11 +1290,48 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
- *
- * @see TransformerChain
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public static <I, O> Transformer<I, O> chain(Iterable<Transformer<?, ?>> transformers) {
- return new TransformerChain<>(transformers);
+ ObjectTools.assertNotNull(transformers);
+ return input -> {
+ Object result = input;
+ for (Transformer transformer : transformers) {
+ result = transformer.transform(result);
+ }
+ return (O) result;
+ };
+ }
+
+ /**
+ * @see #chain(Iterable)
+ */
+ public static <I, O> InterruptibleTransformer<I, O> chain(@SuppressWarnings("rawtypes") InterruptibleTransformer... transformers) {
+ return interuptibleChain(ArrayTools.<InterruptibleTransformer<?, ?>>iterable(transformers));
+ }
+
+ /**
+ * Chain the specified transformers. Pass the chain's input to the first
+ * transformer; take that transformer's output and pass it to the following
+ * transformer in the chain; etc. The output from the final transformer is
+ * returned as the chain's output.
+ * <p>
+ * <strong>NB:</strong> The transformer's generic types are for convenience only
+ * and cannot be enforced on the transformers in the chain.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public static <I, O> InterruptibleTransformer<I, O> interuptibleChain(Iterable<InterruptibleTransformer<?, ?>> transformers) {
+ ObjectTools.assertNotNull(transformers);
+ return input -> {
+ Object result = input;
+ for (InterruptibleTransformer transformer : transformers) {
+ result = transformer.transform(result);
+ }
+ return (O) result;
+ };
}
@@ -1070,11 +1345,9 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
- *
- * @see ClosureTransformer
*/
public static <I, O> Transformer<I, O> conditionalTransformer(Predicate<? super I> predicate, Transformer<? super I, ? extends O> transformer) {
- return conditionalTransformer(predicate, transformer, NullOutputTransformer.<I, O>instance());
+ return conditionalTransformer(predicate, transformer, nullOutputTransformer());
}
/**
@@ -1083,11 +1356,30 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
- *
- * @see ClosureTransformer
*/
public static <I, O> Transformer<I, O> conditionalTransformer(Predicate<? super I> predicate, Transformer<? super I, ? extends O> trueTransformer, Transformer<? super I, ? extends O> falseTransformer) {
- return new ConditionalTransformer<>(predicate, trueTransformer, falseTransformer);
+ ObjectTools.assertNotNull(predicate);
+ ObjectTools.assertNotNull(trueTransformer);
+ ObjectTools.assertNotNull(falseTransformer);
+ return input -> predicate.evaluate(input) ?
+ trueTransformer.transform(input) :
+ falseTransformer.transform(input);
+ }
+
+ /**
+ * Return a transformer that passes its input to the specified predicate to
+ * determine which of the two specified transformers to execute.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ */
+ public static <I, O> InterruptibleTransformer<I, O> conditionalTransformer(Predicate<? super I> predicate, InterruptibleTransformer<? super I, ? extends O> trueTransformer, InterruptibleTransformer<? super I, ? extends O> falseTransformer) {
+ ObjectTools.assertNotNull(predicate);
+ ObjectTools.assertNotNull(trueTransformer);
+ ObjectTools.assertNotNull(falseTransformer);
+ return input -> predicate.evaluate(input) ?
+ trueTransformer.transform(input) :
+ falseTransformer.transform(input);
}
@@ -1112,11 +1404,9 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
- *
- * @see SwitchTransformer
*/
public static <I, O> Transformer<I, O> switchTransformer(Iterable<Association<Predicate<? super I>, Transformer<? super I, ? extends O>>> transformers) {
- return switchTransformer(transformers, NullOutputTransformer.<I, O>instance());
+ return switchTransformer(transformers, nullOutputTransformer());
}
/**
@@ -1130,11 +1420,67 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
- *
- * @see SwitchTransformer
*/
public static <I, O> Transformer<I, O> switchTransformer(Iterable<Association<Predicate<? super I>, Transformer<? super I, ? extends O>>> transformers, Transformer<? super I, ? extends O> defaultTransformer) {
- return new SwitchTransformer<>(transformers, defaultTransformer);
+ IterableTools.assertNeitherIsNorContainsNull(transformers);
+ ObjectTools.assertNotNull(defaultTransformer);
+ return input -> {
+ for (Association<Predicate<? super I>, Transformer<? super I, ? extends O>> association : transformers) {
+ if (association.getKey().evaluate(input)) {
+ return association.getValue().transform(input); // execute only one transformer
+ }
+ }
+ return defaultTransformer.transform(input);
+ };
+ }
+
+ /**
+ * @see #switchTransformer(Iterable)
+ */
+ @SafeVarargs
+ public static <I, O> InterruptibleTransformer<I, O> interruptibleSwitchTransformer(Association<Predicate<? super I>, InterruptibleTransformer<? super I, ? extends O>>... transformers) {
+ return interruptibleSwitchTransformer(ArrayTools.iterable(transformers));
+ }
+
+ /**
+ * Return a transformer that loops over the specified set of
+ * predicate/transformer pairs, passing its input to each predicate to
+ * determine which of the transformers to execute. Only the first
+ * transformer whose predicate evaluates to <code>true</code> is executed,
+ * even if other, following, predicates would evaluate to <code>true</code>.
+ * If none of the predicates evaluates to <code>true</code>, the transformer
+ * returns <code>null</code>.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ */
+ public static <I, O> InterruptibleTransformer<I, O> interruptibleSwitchTransformer(Iterable<Association<Predicate<? super I>, InterruptibleTransformer<? super I, ? extends O>>> transformers) {
+ return interruptibleSwitchTransformer(transformers, nullOutputTransformer());
+ }
+
+ /**
+ * Return a transformer that loops over the specified set of
+ * predicate/transformer pairs, passing its input to each predicate to
+ * determine which of the transformers to execute. Only the first
+ * transformer whose predicate evaluates to <code>true</code> is executed,
+ * even if other, following, predicates would evaluate to <code>true</code>.
+ * If none of the predicates evaluates to <code>true</code>, the default transformer
+ * is executed.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ * @param <O> output: the type of the object returned by the transformer
+ */
+ public static <I, O> InterruptibleTransformer<I, O> interruptibleSwitchTransformer(Iterable<Association<Predicate<? super I>, InterruptibleTransformer<? super I, ? extends O>>> transformers, InterruptibleTransformer<? super I, ? extends O> defaultTransformer) {
+ IterableTools.assertNeitherIsNorContainsNull(transformers);
+ ObjectTools.assertNotNull(defaultTransformer);
+ return input -> {
+ for (Association<Predicate<? super I>, InterruptibleTransformer<? super I, ? extends O>> association : transformers) {
+ if (association.getKey().evaluate(input)) {
+ return association.getValue().transform(input); // execute only one transformer
+ }
+ }
+ return defaultTransformer.transform(input);
+ };
}
@@ -1148,11 +1494,9 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
- *
- * @see DisabledTransformer
*/
public static <I, O> Transformer<I, O> disabledTransformer() {
- return DisabledTransformer.instance();
+ return input -> {throw new UnsupportedOperationException();};
}
@@ -1164,11 +1508,10 @@ public final class TransformerTools {
*
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
- *
- * @see MapTransformer
*/
public static <I, O> Transformer<I, O> mapTransformer(Map<? super I, ? extends O> map) {
- return new MapTransformer<>(map);
+ ObjectTools.assertNotNull(map);
+ return input -> map.get(input);
}
@@ -1180,10 +1523,10 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
*
- * @see NullOutputTransformer
+ * @see #staticOutputTransformer(Object)
*/
public static <I, O> Transformer<I, O> nullOutputTransformer() {
- return NullOutputTransformer.instance();
+ return input -> null;
}
/**
@@ -1193,11 +1536,10 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to the transformer
* @param <O> output: the type of the object returned by the transformer
*
- * @see StaticOutputTransformer
* @see #nullOutputTransformer()
*/
public static <I, O> Transformer<I, O> staticOutputTransformer(O output) {
- return new StaticOutputTransformer<>(output);
+ return input -> output;
}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/UpcastingInterruptibleTransformerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/UpcastingInterruptibleTransformerWrapper.java
deleted file mode 100644
index 08f4de61d3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/UpcastingInterruptibleTransformerWrapper.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
-
-/**
- * @see UpcastingTransformerWrapper
- */
-public class UpcastingInterruptibleTransformerWrapper<I, O, X extends O>
- implements InterruptibleTransformer<I, O>
-{
- private final InterruptibleTransformer<? super I, ? extends X> transformer;
-
- public UpcastingInterruptibleTransformerWrapper(InterruptibleTransformer<? super I, ? extends X> transformer) {
- super();
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- }
-
- /**
- * No need for casting as the type is guaranteed by the generic type
- * argument.
- */
- public O transform(I input) throws InterruptedException {
- return this.transformer.transform(input);
- }
-
- public InterruptibleTransformer<? super I, ? extends X> getTransformer() {
- return this.transformer;
- }
-
- @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/internal/transformer/UpcastingTransformerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/UpcastingTransformerWrapper.java
deleted file mode 100644
index e091b151e3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/UpcastingTransformerWrapper.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 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;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Wrap a transformer that takes an object of type <code>I</code> and returns
- * an object of type <code>X</code>, converting it into a transformer that
- * takes an object of type <code>I</code> and returns
- * an object of type <code>O</code>.
- * <p>
- * This is like a {@link CastingTransformerWrapper} but with more restrictive type
- * parameters.
- *
- * @param <I> input: the type of the object passed to the transformer and
- * forwarded to the wrapped transformer
- * @param <O> output: the type of object returned by the transformer - this
- * is the same object returned by the wrapped transformer, simply
- * cast to <code>O</code>
- * @param <X> intermediate: the type of object returned by the wrapped
- * transformer
- *
- * @see CastingTransformerWrapper
- * @see DowncastingTransformerWrapper
- */
-public class UpcastingTransformerWrapper<I, O, X extends O>
- implements Transformer<I, O>
-{
- private final Transformer<? super I, ? extends X> transformer;
-
- public UpcastingTransformerWrapper(Transformer<? super I, ? extends X> transformer) {
- super();
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- }
-
- /**
- * No need for casting as the type is guaranteed by the generic type
- * argument.
- */
- public O transform(I input) {
- return this.transformer.transform(input);
- }
-
- public Transformer<? super I, ? extends X> getTransformer() {
- return this.transformer;
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.transformer);
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/ChainIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/ChainIterableTests.java
index 14dab6ed0d..e5701b906f 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/ChainIterableTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/ChainIterableTests.java
@@ -13,10 +13,10 @@ import java.util.AbstractCollection;
import java.util.AbstractList;
import java.util.Iterator;
import java.util.Vector;
-import junit.framework.TestCase;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.common.utility.internal.transformer.DisabledTransformer;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
public class ChainIterableTests
@@ -37,7 +37,7 @@ public class ChainIterableTests
}
public void testException() {
- Iterable<Class<?>> iterable = IterableTools.chainIterable(Vector.class, DisabledTransformer.<Class<?>, Class<?>>instance());
+ Iterable<Class<?>> iterable = IterableTools.chainIterable(Vector.class, TransformerTools.disabledTransformer());
Iterator<Class<?>> iterator = iterable.iterator();
boolean exCaught = false;
try {
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/GraphIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/GraphIterableTests.java
index 89c0f7c987..0600bd0cf8 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/GraphIterableTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/GraphIterableTests.java
@@ -14,8 +14,8 @@ import java.util.Collection;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.collection.ListTools;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.common.utility.internal.transformer.DisabledTransformer;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
import org.eclipse.jpt.common.utility.tests.internal.TestTools;
import org.eclipse.jpt.common.utility.transformer.Transformer;
import junit.framework.TestCase;
@@ -64,7 +64,7 @@ public class GraphIterableTests
public void testBogusTransformer() {
boolean exCaught = false;
try {
- for (GraphNode gn : IterableTools.graphIterable(this.buildGraphRoot(), DisabledTransformer.<GraphNode, Iterable<? extends GraphNode>>instance())) {
+ for (GraphNode gn : IterableTools.graphIterable(this.buildGraphRoot(), TransformerTools.disabledTransformer())) {
assertTrue(this.nodes.contains(gn));
}
fail();
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/TransformationIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/TransformationIterableTests.java
index 5a762f0fa5..e100a3f5d9 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/TransformationIterableTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/TransformationIterableTests.java
@@ -11,13 +11,11 @@ package org.eclipse.jpt.common.utility.tests.internal.iterable;
import java.util.ArrayList;
import java.util.Collection;
-
-import junit.framework.TestCase;
-
import org.eclipse.jpt.common.utility.internal.iterable.TransformationIterable;
-import org.eclipse.jpt.common.utility.internal.transformer.DisabledTransformer;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
public class TransformationIterableTests
@@ -61,7 +59,7 @@ public class TransformationIterableTests
}
public void testMissingTransformer() {
- Iterable<Integer> iterable = new TransformationIterable<String, Integer>(this.buildNestedIterable(), DisabledTransformer.<String, Integer>instance());
+ Iterable<Integer> iterable = new TransformationIterable<String, Integer>(this.buildNestedIterable(), TransformerTools.disabledTransformer());
boolean exCaught = false;
try {
int i = 1;
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/TransformationListIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/TransformationListIterableTests.java
index b7b7e1b330..22ea47fd6d 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/TransformationListIterableTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterable/TransformationListIterableTests.java
@@ -11,11 +11,11 @@ package org.eclipse.jpt.common.utility.tests.internal.iterable;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.common.utility.internal.transformer.DisabledTransformer;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
public class TransformationListIterableTests
@@ -59,7 +59,7 @@ public class TransformationListIterableTests
}
public void testMissingTransformer() {
- Iterable<Integer> iterable = IterableTools.transform(this.buildNestedList(), DisabledTransformer.<String, Integer>instance());
+ Iterable<Integer> iterable = IterableTools.transform(this.buildNestedList(), TransformerTools.disabledTransformer());
boolean exCaught = false;
try {
int i = 1;
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/ChainIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/ChainIteratorTests.java
index e75062ce84..61b1849f19 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/ChainIteratorTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/ChainIteratorTests.java
@@ -14,11 +14,11 @@ import java.util.AbstractList;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Vector;
-import junit.framework.TestCase;
import org.eclipse.jpt.common.utility.internal.iterator.ChainIterator;
-import org.eclipse.jpt.common.utility.internal.transformer.DisabledTransformer;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
public class ChainIteratorTests
@@ -85,7 +85,7 @@ public class ChainIteratorTests
public void testInvalidChainIterator() {
// missing method override
- Iterator<Class<?>> iterator = new ChainIterator<Class<?>>(Vector.class, DisabledTransformer.<Class<?>, Class<?>>instance());
+ Iterator<Class<?>> iterator = new ChainIterator<Class<?>>(Vector.class, TransformerTools.disabledTransformer());
boolean exCaught = false;
try {
Class<?> c = iterator.next();
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/GraphIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/GraphIteratorTests.java
index 27792741fe..4d9ea011f2 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/GraphIteratorTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/GraphIteratorTests.java
@@ -13,12 +13,12 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import junit.framework.TestCase;
import org.eclipse.jpt.common.utility.internal.collection.ListTools;
import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
-import org.eclipse.jpt.common.utility.internal.transformer.DisabledTransformer;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
import org.eclipse.jpt.common.utility.tests.internal.TestTools;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
public class GraphIteratorTests
@@ -80,7 +80,7 @@ public class GraphIteratorTests
boolean exCaught = false;
try {
// missing method override
- Iterator<GraphNode> iterator = IteratorTools.graphIterator(this.buildGraphRoot(), DisabledTransformer.<GraphNode, Iterator<? extends GraphNode>>instance());
+ Iterator<GraphNode> iterator = IteratorTools.graphIterator(this.buildGraphRoot(), TransformerTools.disabledTransformer());
GraphNode gn = iterator.next();
fail("invalid graph node: " + gn);
} catch (UnsupportedOperationException ex) {
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/TransformationIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/TransformationIteratorTests.java
index ee5f914ae6..8916063a5f 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/TransformationIteratorTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/TransformationIteratorTests.java
@@ -14,11 +14,11 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import junit.framework.TestCase;
import org.eclipse.jpt.common.utility.internal.iterator.TransformationIterator;
-import org.eclipse.jpt.common.utility.internal.transformer.DisabledTransformer;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
public class TransformationIteratorTests
@@ -159,7 +159,7 @@ public class TransformationIteratorTests
public void testInvalidTransformationIterator() {
// missing method override
- Iterator<Integer> iterator = new TransformationIterator<String, Integer>(this.buildCollection().iterator(), DisabledTransformer.<String, Integer>instance());
+ Iterator<Integer> iterator = new TransformationIterator<String, Integer>(this.buildCollection().iterator(), TransformerTools.disabledTransformer());
boolean exCaught = false;
try {
Integer integer = iterator.next();
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/TransformationListIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/TransformationListIteratorTests.java
index a7ecbe292a..72f56bedfd 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/TransformationListIteratorTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterator/TransformationListIteratorTests.java
@@ -15,11 +15,11 @@ import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
-import junit.framework.TestCase;
import org.eclipse.jpt.common.utility.internal.iterator.TransformationListIterator;
-import org.eclipse.jpt.common.utility.internal.transformer.DisabledTransformer;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
import org.eclipse.jpt.common.utility.transformer.Transformer;
+import junit.framework.TestCase;
@SuppressWarnings("nls")
public class TransformationListIteratorTests
@@ -244,7 +244,7 @@ public class TransformationListIteratorTests
public void testInvalidTransformationListIterator() {
// missing method override
- Iterator<Integer> iterator = new TransformationListIterator<String, Integer>(this.buildList().listIterator(), DisabledTransformer.<String, Integer>instance());
+ Iterator<Integer> iterator = new TransformationListIterator<String, Integer>(this.buildList().listIterator(), TransformerTools.disabledTransformer());
boolean exCaught = false;
try {
Integer integer = iterator.next();
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/FilteringTransformerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/FilteringTransformerTests.java
deleted file mode 100644
index 9f5c198a46..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/FilteringTransformerTests.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * 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.tests.internal.transformer;
-
-import org.eclipse.jpt.common.utility.internal.predicate.PredicateAdapter;
-import org.eclipse.jpt.common.utility.internal.predicate.PredicateTools;
-import org.eclipse.jpt.common.utility.internal.transformer.FilteringTransformer;
-import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
-import org.eclipse.jpt.common.utility.predicate.Predicate;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-import junit.framework.TestCase;
-
-@SuppressWarnings("nls")
-public class FilteringTransformerTests
- extends TestCase
-{
- public FilteringTransformerTests(String name) {
- super(name);
- }
-
- public void testTransform() {
- Predicate<String> nonNullFilter = new Filter(3);
- Predicate<String> filter = PredicateTools.nullCheck(nonNullFilter, false);
- Transformer<String, String> transformer = TransformerTools.filteringTransformer(filter);
-
- assertEquals("foo", transformer.transform("foo"));
- assertEquals("bar", transformer.transform("bar"));
- assertNull(transformer.transform("barbar"));
- assertNull(transformer.transform("b"));
- assertNull(transformer.transform(""));
- assertNull(transformer.transform(null));
- }
-
- public void testToString() {
- Predicate<String> nonNullFilter = new Filter(3);
- Predicate<String> filter = PredicateTools.nullCheck(nonNullFilter, false);
- Transformer<String, String> transformer = TransformerTools.filteringTransformer(filter);
- assertTrue(transformer.toString().indexOf("Filtering") != -1);
- }
-
- public void testGetters() {
- Predicate<String> nonNullFilter = new Filter(3);
- Predicate<String> filter = PredicateTools.nullCheck(nonNullFilter, false);
- FilteringTransformer<String> transformer = (FilteringTransformer<String>) TransformerTools.filteringTransformer(filter);
- assertSame(filter, transformer.getFilter());
- assertNull(transformer.getDefaultOutput());
- }
-
- public void testCtor_NPE() {
- boolean exCaught = false;
- try {
- Transformer<String, String> transformer = TransformerTools.filteringTransformer(null);
- fail("bogus: " + transformer);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public static class Filter
- extends PredicateAdapter<String>
- {
- public final int length;
- public Filter(int length) {
- super();
- this.length =length;
- }
- @Override
- public boolean evaluate(String variable) {
- return variable.length() == this.length;
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/JptCommonUtilityTransformerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/JptCommonUtilityTransformerTests.java
index bb05362276..71b1eb225b 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/JptCommonUtilityTransformerTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/JptCommonUtilityTransformerTests.java
@@ -20,10 +20,6 @@ public class JptCommonUtilityTransformerTests {
public static Test suite() {
TestSuite suite = new TestSuite(JptCommonUtilityTransformerTests.class.getPackage().getName());
- suite.addTestSuite(FilteringTransformerTests.class);
- suite.addTestSuite(ListLastElementTransformerTests.class);
- suite.addTestSuite(ListLastElementTransformer_Tests.class);
- suite.addTestSuite(NullCheckTransformerTests.class);
suite.addTestSuite(TransformerToolsTests.class);
suite.addTestSuite(XMLStringDecoderTests.class);
suite.addTestSuite(XMLStringEncoderTests.class);
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformerTests.java
deleted file mode 100644
index af971881a2..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformerTests.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * 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.tests.internal.transformer;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-import junit.framework.TestCase;
-
-@SuppressWarnings("nls")
-public class ListLastElementTransformerTests
- extends TestCase
-{
- public ListLastElementTransformerTests(String name) {
- super(name);
- }
-
- public void testEvaluate() {
- List<String> list = new ArrayList<>();
- Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer();
- assertNull(transformer.transform(list));
- list.add("foo");
- assertEquals("foo", transformer.transform(list));
- list.add("bar");
- assertEquals("bar", transformer.transform(list));
- list.remove("foo");
- assertEquals("bar", transformer.transform(list));
- list.remove("bar");
- assertNull(transformer.transform(list));
- }
-
- public void testToString() {
- Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer();
- assertEquals("ListLastElementTransformer", transformer.toString());
- }
-
- public void testSerialization() throws Exception {
- Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer();
- assertSame(transformer, TestTools.serialize(transformer));
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformer_Tests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformer_Tests.java
deleted file mode 100644
index d68eb01a52..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/ListLastElementTransformer_Tests.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * 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.tests.internal.transformer;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-import junit.framework.TestCase;
-
-@SuppressWarnings("nls")
-public class ListLastElementTransformer_Tests
- extends TestCase
-{
- public ListLastElementTransformer_Tests(String name) {
- super(name);
- }
-
- public void testEvaluate() {
- List<String> list = new ArrayList<>();
- Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer_();
- boolean exCaught = false;
- try {
- String bogus = transformer.transform(list);
- fail("bogus output: " + bogus);
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- list.add("foo");
- assertEquals("foo", transformer.transform(list));
- list.add("bar");
- assertEquals("bar", transformer.transform(list));
- list.remove("foo");
- assertEquals("bar", transformer.transform(list));
- list.remove("bar");
- exCaught = false;
- try {
- String bogus = transformer.transform(list);
- fail("bogus output: " + bogus);
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- }
-
- public void testToString() {
- Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer_();
- assertEquals("ListLastElementTransformer_", transformer.toString());
- }
-
- public void testSerialization() throws Exception {
- Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer_();
- assertSame(transformer, TestTools.serialize(transformer));
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/NullCheckTransformerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/NullCheckTransformerTests.java
deleted file mode 100644
index 23ac45c18b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/NullCheckTransformerTests.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * 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.tests.internal.transformer;
-
-import org.eclipse.jpt.common.utility.internal.transformer.NullCheckTransformer;
-import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-import junit.framework.TestCase;
-
-@SuppressWarnings("nls")
-public class NullCheckTransformerTests
- extends TestCase
-{
- public NullCheckTransformerTests(String name) {
- super(name);
- }
-
- public void testTransform() {
- Transformer<String, String> transformer = TransformerTools.nullCheck("");
-
- assertEquals("foo", transformer.transform("foo"));
- assertEquals("bar", transformer.transform("bar"));
- assertEquals("barbar", transformer.transform("barbar"));
- assertEquals("b", transformer.transform("b"));
- assertEquals("", transformer.transform(""));
- assertEquals("", transformer.transform(null));
- }
-
- public void testToString() {
- Transformer<String, String> transformer = TransformerTools.nullCheck("");
- assertTrue(transformer.toString().indexOf("NullCheck") != -1);
- }
-
- public void testGetters() {
- NullCheckTransformer<String> transformer = (NullCheckTransformer<String>) TransformerTools.nullCheck("");
- assertEquals("", transformer.getNullOutput());
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/TransformerToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/TransformerToolsTests.java
index 61377af2b4..9aa1f3bb7e 100644
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/TransformerToolsTests.java
+++ b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/transformer/TransformerToolsTests.java
@@ -11,8 +11,12 @@ package org.eclipse.jpt.common.utility.tests.internal.transformer;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.NoSuchElementException;
+import org.eclipse.jpt.common.utility.internal.predicate.PredicateAdapter;
+import org.eclipse.jpt.common.utility.internal.predicate.PredicateTools;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerTools;
+import org.eclipse.jpt.common.utility.predicate.Predicate;
import org.eclipse.jpt.common.utility.transformer.Transformer;
import junit.framework.TestCase;
@@ -24,6 +28,55 @@ public class TransformerToolsTests
super(name);
}
+ public void testNullCheck() {
+ Transformer<String, String> transformer = TransformerTools.nullCheck("");
+
+ assertEquals("foo", transformer.transform("foo"));
+ assertEquals("bar", transformer.transform("bar"));
+ assertEquals("barbar", transformer.transform("barbar"));
+ assertEquals("b", transformer.transform("b"));
+ assertEquals("", transformer.transform(""));
+ assertEquals("", transformer.transform(null));
+ }
+
+ public void testFilteringTransformer() {
+ Predicate<String> nonNullFilter = new Filter(3);
+ Predicate<String> filter = PredicateTools.nullCheck(nonNullFilter, false);
+ Transformer<String, String> transformer = TransformerTools.filteringTransformer(filter);
+
+ assertEquals("foo", transformer.transform("foo"));
+ assertEquals("bar", transformer.transform("bar"));
+ assertNull(transformer.transform("barbar"));
+ assertNull(transformer.transform("b"));
+ assertNull(transformer.transform(""));
+ assertNull(transformer.transform(null));
+ }
+
+ public void testFilteringTransformer_NPE() {
+ boolean exCaught = false;
+ try {
+ Transformer<String, String> transformer = TransformerTools.filteringTransformer(null);
+ fail("bogus: " + transformer);
+ } catch (NullPointerException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ }
+
+ public static class Filter
+ extends PredicateAdapter<String>
+ {
+ public final int length;
+ public Filter(int length) {
+ super();
+ this.length =length;
+ }
+ @Override
+ public boolean evaluate(String variable) {
+ return variable.length() == this.length;
+ }
+ }
+
public void testCollectionFirstElementTransformer() {
Collection<String> list = new ArrayList<>();
Transformer<Collection<? extends String>, String> transformer = TransformerTools.collectionFirstElementTransformer();
@@ -179,4 +232,45 @@ public class TransformerToolsTests
}
assertTrue(exCaught);
}
+
+ public void testListLastElementTransformer_() {
+ List<String> list = new ArrayList<>();
+ Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer_();
+ boolean exCaught = false;
+ try {
+ String bogus = transformer.transform(list);
+ fail("bogus output: " + bogus);
+ } catch (IndexOutOfBoundsException ex) {
+ exCaught = true;
+ }
+ assertTrue(exCaught);
+ list.add("foo");
+ assertEquals("foo", transformer.transform(list));
+ list.add("bar");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("foo");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("bar");
+ exCaught = false;
+ try {
+ String bogus = transformer.transform(list);
+ fail("bogus output: " + bogus);
+ } catch (IndexOutOfBoundsException ex) {
+ exCaught = true;
+ }
+ }
+
+ public void testListLastElementTransformer() {
+ List<String> list = new ArrayList<>();
+ Transformer<List<? extends String>, String> transformer = TransformerTools.listLastElementTransformer();
+ assertNull(transformer.transform(list));
+ list.add("foo");
+ assertEquals("foo", transformer.transform(list));
+ list.add("bar");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("foo");
+ assertEquals("bar", transformer.transform(list));
+ list.remove("bar");
+ assertNull(transformer.transform(list));
+ }
}

Back to the top