From 534344a3df0f610d493e08adf708a4be704aae58 Mon Sep 17 00:00:00 2001 From: Gunnar Morling Date: Thu, 8 May 2014 00:52:18 +0200 Subject: [PATCH] #75 Adding Timo to copyright.txt; Merging ClassUtils into NativeTypes --- copyright.txt | 1 + parent/pom.xml | 3 +- processor/pom.xml | 13 +++--- .../mapstruct/ap/conversion/Conversions.java | 9 ++-- .../org/mapstruct/ap/util/ClassUtils.java | 42 ------------------- .../org/mapstruct/ap/util/NativeTypes.java | 16 +++++++ 6 files changed, 31 insertions(+), 53 deletions(-) delete mode 100644 processor/src/main/java/org/mapstruct/ap/util/ClassUtils.java diff --git a/copyright.txt b/copyright.txt index a25f06f67..c28556e13 100644 --- a/copyright.txt +++ b/copyright.txt @@ -5,3 +5,4 @@ Andreas Gudian Christian Schuster Gunnar Morling Sjaak Derksen +Timo Eckhardt diff --git a/parent/pom.xml b/parent/pom.xml index 8f6274d53..be3195f68 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -177,12 +177,11 @@ ${org.springframework.version} - + joda-time joda-time 2.3 - test diff --git a/processor/pom.xml b/processor/pom.xml index 87e8ea0df..0235b0e31 100644 --- a/processor/pom.xml +++ b/processor/pom.xml @@ -57,11 +57,7 @@ mapstruct provided - - - joda-time - joda-time - + junit @@ -88,6 +84,13 @@ commons-io test + + + + joda-time + joda-time + test + diff --git a/processor/src/main/java/org/mapstruct/ap/conversion/Conversions.java b/processor/src/main/java/org/mapstruct/ap/conversion/Conversions.java index 856947b4c..66cad9dee 100644 --- a/processor/src/main/java/org/mapstruct/ap/conversion/Conversions.java +++ b/processor/src/main/java/org/mapstruct/ap/conversion/Conversions.java @@ -18,19 +18,20 @@ */ package org.mapstruct.ap.conversion; +import static org.mapstruct.ap.conversion.ReverseConversion.reverse; + import java.math.BigDecimal; import java.math.BigInteger; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Map; + import javax.lang.model.util.Elements; import org.mapstruct.ap.model.common.Type; import org.mapstruct.ap.model.common.TypeFactory; -import org.mapstruct.ap.util.ClassUtils; - -import static org.mapstruct.ap.conversion.ReverseConversion.reverse; +import org.mapstruct.ap.util.NativeTypes; /** * Holds built-in {@link ConversionProvider}s such as from {@code int} to {@code String}. @@ -237,7 +238,7 @@ public class Conversions { } private static boolean isJodaTimeAvailable() { - return ClassUtils.isTypeAvailable( JodaTimeConstants.DATE_TIME_FQN ); + return NativeTypes.isTypeAvailable( JodaTimeConstants.DATE_TIME_FQN ); } /** diff --git a/processor/src/main/java/org/mapstruct/ap/util/ClassUtils.java b/processor/src/main/java/org/mapstruct/ap/util/ClassUtils.java deleted file mode 100644 index f4f4f9b98..000000000 --- a/processor/src/main/java/org/mapstruct/ap/util/ClassUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/) - * and/or other contributors as indicated by the @authors tag. See the - * copyright.txt file in the distribution for a full listing of all - * contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.mapstruct.ap.util; - -/** - * - */ -public final class ClassUtils { - - private ClassUtils() { } - /** - * Determines if the type with the given full qualified name is part of the classpath - * - * @param fullQualifiedClassName Name of the type to be checked for availability - * @return true if the type with the given full qualified name is part of the classpath. - */ - public static boolean isTypeAvailable(String fullQualifiedClassName) { - try { - Class.forName( fullQualifiedClassName ); - } - catch ( ClassNotFoundException e ) { - return false; - } - return true; - } -} diff --git a/processor/src/main/java/org/mapstruct/ap/util/NativeTypes.java b/processor/src/main/java/org/mapstruct/ap/util/NativeTypes.java index a6025e7e2..7b46450fc 100644 --- a/processor/src/main/java/org/mapstruct/ap/util/NativeTypes.java +++ b/processor/src/main/java/org/mapstruct/ap/util/NativeTypes.java @@ -77,4 +77,20 @@ public class NativeTypes { return WRAPPER_TO_PRIMITIVE_TYPES.get( clazz ); } + + /** + * Determines if the type with the given full qualified name is part of the classpath + * + * @param fullQualifiedClassName Name of the type to be checked for availability + * @return true if the type with the given full qualified name is part of the classpath. + */ + public static boolean isTypeAvailable(String fullQualifiedClassName) { + try { + Class.forName( fullQualifiedClassName, false, NativeTypes.class.getClassLoader() ); + } + catch ( ClassNotFoundException e ) { + return false; + } + return true; + } }