#75 Adding Timo to copyright.txt; Merging ClassUtils into NativeTypes

This commit is contained in:
Gunnar Morling 2014-05-08 00:52:18 +02:00
parent 565cc3b8d5
commit 534344a3df
6 changed files with 31 additions and 53 deletions

View File

@ -5,3 +5,4 @@ Andreas Gudian
Christian Schuster Christian Schuster
Gunnar Morling Gunnar Morling
Sjaak Derksen Sjaak Derksen
Timo Eckhardt

View File

@ -177,12 +177,11 @@
<version>${org.springframework.version}</version> <version>${org.springframework.version}</version>
</dependency> </dependency>
<!-- joda --> <!-- Joda-Time -->
<dependency> <dependency>
<groupId>joda-time</groupId> <groupId>joda-time</groupId>
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
<version>2.3</version> <version>2.3</version>
<scope>test</scope>
</dependency> </dependency>
<!-- Project modules --> <!-- Project modules -->

View File

@ -57,11 +57,7 @@
<artifactId>mapstruct</artifactId> <artifactId>mapstruct</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- joda -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<!-- Test --> <!-- Test -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -88,6 +84,13 @@
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- There is no compile dependency to Joda-Time; It's only required for testing the Joda conversions -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -18,19 +18,20 @@
*/ */
package org.mapstruct.ap.conversion; package org.mapstruct.ap.conversion;
import static org.mapstruct.ap.conversion.ReverseConversion.reverse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.lang.model.util.Elements; import javax.lang.model.util.Elements;
import org.mapstruct.ap.model.common.Type; import org.mapstruct.ap.model.common.Type;
import org.mapstruct.ap.model.common.TypeFactory; import org.mapstruct.ap.model.common.TypeFactory;
import org.mapstruct.ap.util.ClassUtils; import org.mapstruct.ap.util.NativeTypes;
import static org.mapstruct.ap.conversion.ReverseConversion.reverse;
/** /**
* Holds built-in {@link ConversionProvider}s such as from {@code int} to {@code String}. * 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() { private static boolean isJodaTimeAvailable() {
return ClassUtils.isTypeAvailable( JodaTimeConstants.DATE_TIME_FQN ); return NativeTypes.isTypeAvailable( JodaTimeConstants.DATE_TIME_FQN );
} }
/** /**

View File

@ -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;
}
}

View File

@ -77,4 +77,20 @@ public class NativeTypes {
return WRAPPER_TO_PRIMITIVE_TYPES.get( clazz ); 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;
}
} }