Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2016-08-11 22:22:05 +0000
committerBrian Vosburgh2017-05-18 22:38:55 +0000
commit019e77e6da05bcdc3ef0703a0ef6dfdc15addaaf (patch)
treed182b83e7fb7615e1f204415e7f05ed187ef117d
parent0b31fe35f7a18de4d019322cee882946994a7f0c (diff)
downloadwebtools.dali-019e77e6da05bcdc3ef0703a0ef6dfdc15addaaf.tar.gz
webtools.dali-019e77e6da05bcdc3ef0703a0ef6dfdc15addaaf.tar.xz
webtools.dali-019e77e6da05bcdc3ef0703a0ef6dfdc15addaaf.zip
rework IntTransformers
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF11
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/IntTransformerAdapter.java (renamed from common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntTransformerAdapter.java)2
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/TransformerTools.java14
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntObjectTransformerAdapter.java45
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntegerIntTransformerAdapter.java45
5 files changed, 13 insertions, 104 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF
index 56f1df4976..e2b333bfbf 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF
@@ -297,17 +297,6 @@ Export-Package: org.eclipse.jpt.common.utility,
org.eclipse.jpt.jpa.gen,
org.eclipse.jpt.jpa.annotate,
org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.transformer.int_;
- x-friends:="org.eclipse.jpt.common.core,
- org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.core,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jpa.db,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.gen,
- org.eclipse.jpt.jpa.annotate,
- org.eclipse.jpt.jpa.ui",
org.eclipse.jpt.common.utility.io,
org.eclipse.jpt.common.utility.iterable,
org.eclipse.jpt.common.utility.model,
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntTransformerAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/IntTransformerAdapter.java
index 60aadc96a0..15095f0e1c 100644
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntTransformerAdapter.java
+++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/IntTransformerAdapter.java
@@ -7,7 +7,7 @@
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.transformer.int_;
+package org.eclipse.jpt.common.utility.internal.transformer;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.transformer.IntTransformer;
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 714ddd26aa..1ac353fe86 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
@@ -31,7 +31,6 @@ import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.exception.DefaultExceptionHandler;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.common.utility.internal.predicate.PredicateTools;
-import org.eclipse.jpt.common.utility.internal.transformer.int_.IntObjectTransformerAdapter;
import org.eclipse.jpt.common.utility.predicate.Predicate;
import org.eclipse.jpt.common.utility.transformer.IntTransformer;
import org.eclipse.jpt.common.utility.transformer.InterruptibleTransformer;
@@ -50,7 +49,18 @@ public final class TransformerTools {
* @param <I> input: the type of the object passed to the transformer
*/
public static <I> Transformer<I, Integer> adapt(IntTransformer<? super I> intTransformer) {
- return new IntObjectTransformerAdapter<>(intTransformer);
+ ObjectTools.assertNotNull(intTransformer);
+ return input -> Integer.valueOf(intTransformer.transform(input));
+ }
+
+ /**
+ * Adapt an {@link Integer} transformer to the {@link IntTransformer} interface.
+ *
+ * @param <I> input: the type of the object passed to the transformer
+ */
+ public static <I> IntTransformer<I> adapt(Transformer<? super I, Integer> transformer) {
+ ObjectTools.assertNotNull(transformer);
+ return input -> transformer.transform(input).intValue();
}
/**
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntObjectTransformerAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntObjectTransformerAdapter.java
deleted file mode 100644
index 9efd7a0f47..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntObjectTransformerAdapter.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.internal.transformer.int_;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.IntTransformer;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Adapt an <code>int</code> transformer to the standard object transformer
- * interface.
- *
- * @param <I> input: the type of the object passed to the transformer
- *
- * @see IntTransformer
- */
-public class IntObjectTransformerAdapter<I>
- implements Transformer<I, Integer>
-{
- private final IntTransformer<? super I> intTransformer;
-
- public IntObjectTransformerAdapter(IntTransformer<? super I> intTransformer) {
- super();
- if (intTransformer == null) {
- throw new NullPointerException();
- }
- this.intTransformer = intTransformer;
- }
-
- public Integer transform(I input) {
- return Integer.valueOf(this.intTransformer.transform(input));
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.intTransformer);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntegerIntTransformerAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntegerIntTransformerAdapter.java
deleted file mode 100644
index 9fc012eeba..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/transformer/int_/IntegerIntTransformerAdapter.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.internal.transformer.int_;
-
-import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.transformer.IntTransformer;
-import org.eclipse.jpt.common.utility.transformer.Transformer;
-
-/**
- * Adapt an {@link Integer} transformer to the <code>int</code> transformer
- * interface.
- *
- * @param <I> input: the type of the object passed to the transformer
- *
- * @see Transformer
- */
-public class IntegerIntTransformerAdapter<I>
- implements IntTransformer<I>
-{
- private final Transformer<? super I, Integer> transformer;
-
- public IntegerIntTransformerAdapter(Transformer<? super I, Integer> transformer) {
- super();
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- }
-
- public int transform(I input) {
- return this.transformer.transform(input).intValue();
- }
-
- @Override
- public String toString() {
- return ObjectTools.toString(this, this.transformer);
- }
-}

Back to the top