#109 Removing package cycle around Options class

This commit is contained in:
Gunnar Morling 2014-01-26 11:46:48 +01:00
parent 4d4f55a162
commit e072826c9d
11 changed files with 51 additions and 22 deletions

View File

@ -25,6 +25,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import java.util.Set; import java.util.Set;
import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.Processor; import javax.annotation.processing.Processor;
@ -40,14 +41,15 @@ import javax.tools.Diagnostic.Kind;
import net.java.dev.hickory.prism.GeneratePrism; import net.java.dev.hickory.prism.GeneratePrism;
import net.java.dev.hickory.prism.GeneratePrisms; import net.java.dev.hickory.prism.GeneratePrisms;
import org.mapstruct.IterableMapping; import org.mapstruct.IterableMapping;
import org.mapstruct.MapMapping; import org.mapstruct.MapMapping;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget; import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.ap.model.Options; import org.mapstruct.ap.option.Options;
import org.mapstruct.ap.model.ReportingPolicy; import org.mapstruct.ap.option.ReportingPolicy;
import org.mapstruct.ap.processor.DefaultModelElementProcessorContext; import org.mapstruct.ap.processor.DefaultModelElementProcessorContext;
import org.mapstruct.ap.processor.ModelElementProcessor; import org.mapstruct.ap.processor.ModelElementProcessor;
import org.mapstruct.ap.processor.ModelElementProcessor.ProcessorContext; import org.mapstruct.ap.processor.ModelElementProcessor.ProcessorContext;

View File

@ -23,6 +23,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import javax.annotation.Generated; import javax.annotation.Generated;
import javax.lang.model.element.ElementKind; import javax.lang.model.element.ElementKind;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
@ -48,11 +49,11 @@ public class Mapper extends ModelElement {
private final List<Annotation> annotations; private final List<Annotation> annotations;
private final List<MappingMethod> mappingMethods; private final List<MappingMethod> mappingMethods;
private final List<MapperReference> referencedMappers; private final List<MapperReference> referencedMappers;
private final Options options; private final boolean suppressGeneratorTimestamp;
private Mapper(TypeFactory typeFactory, String packageName, boolean superTypeIsInterface, String interfaceName, private Mapper(TypeFactory typeFactory, String packageName, boolean superTypeIsInterface, String interfaceName,
String implementationName, List<MappingMethod> mappingMethods, String implementationName, List<MappingMethod> mappingMethods,
List<MapperReference> referencedMappers, Options options) { List<MapperReference> referencedMappers, boolean suppressGeneratorTimestamp) {
this.packageName = packageName; this.packageName = packageName;
this.superTypeIsInterface = superTypeIsInterface; this.superTypeIsInterface = superTypeIsInterface;
this.interfaceName = interfaceName; this.interfaceName = interfaceName;
@ -60,7 +61,7 @@ public class Mapper extends ModelElement {
this.annotations = new ArrayList<Annotation>(); this.annotations = new ArrayList<Annotation>();
this.mappingMethods = mappingMethods; this.mappingMethods = mappingMethods;
this.referencedMappers = referencedMappers; this.referencedMappers = referencedMappers;
this.options = options; this.suppressGeneratorTimestamp = suppressGeneratorTimestamp;
this.typeFactory = typeFactory; this.typeFactory = typeFactory;
} }
@ -70,8 +71,8 @@ public class Mapper extends ModelElement {
private TypeElement element; private TypeElement element;
private List<MappingMethod> mappingMethods; private List<MappingMethod> mappingMethods;
private List<MapperReference> mapperReferences; private List<MapperReference> mapperReferences;
private Options options;
private Elements elementUtils; private Elements elementUtils;
private boolean suppressGeneratorTimestamp;
public Builder element(TypeElement element) { public Builder element(TypeElement element) {
this.element = element; this.element = element;
@ -88,8 +89,8 @@ public class Mapper extends ModelElement {
return this; return this;
} }
public Builder options(Options options) { public Builder suppressGeneratorTimestamp(boolean suppressGeneratorTimestamp) {
this.options = options; this.suppressGeneratorTimestamp = suppressGeneratorTimestamp;
return this; return this;
} }
@ -112,7 +113,7 @@ public class Mapper extends ModelElement {
element.getSimpleName() + IMPLEMENTATION_SUFFIX, element.getSimpleName() + IMPLEMENTATION_SUFFIX,
mappingMethods, mappingMethods,
mapperReferences, mapperReferences,
options suppressGeneratorTimestamp
); );
} }
} }
@ -208,8 +209,8 @@ public class Mapper extends ModelElement {
return referencedMappers; return referencedMappers;
} }
public Options getOptions() { public boolean isSuppressGeneratorTimestamp() {
return options; return suppressGeneratorTimestamp;
} }
public void addAnnotation(Annotation annotation) { public void addAnnotation(Annotation annotation) {

View File

@ -16,7 +16,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.model; package org.mapstruct.ap.option;
/** /**
* The options passed to the code generator. * The options passed to the code generator.

View File

@ -16,9 +16,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.util; package org.mapstruct.ap.option;
import org.mapstruct.ap.model.Options;
/** /**
* Helper class for dealing with {@link Options}. * Helper class for dealing with {@link Options}.

View File

@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.model; package org.mapstruct.ap.option;
import javax.tools.Diagnostic; import javax.tools.Diagnostic;
import javax.tools.Diagnostic.Kind; import javax.tools.Diagnostic.Kind;

View File

@ -0,0 +1,24 @@
/**
* 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.
*/
/**
* <p>
* Provides access to the options passed to the annotation processor.
* </p>
*/
package org.mapstruct.ap.option;

View File

@ -19,6 +19,7 @@
package org.mapstruct.ap.processor; package org.mapstruct.ap.processor;
import java.util.ListIterator; import java.util.ListIterator;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import org.mapstruct.ap.MapperPrism; import org.mapstruct.ap.MapperPrism;
@ -26,7 +27,7 @@ import org.mapstruct.ap.model.Annotation;
import org.mapstruct.ap.model.AnnotationMapperReference; import org.mapstruct.ap.model.AnnotationMapperReference;
import org.mapstruct.ap.model.Mapper; import org.mapstruct.ap.model.Mapper;
import org.mapstruct.ap.model.MapperReference; import org.mapstruct.ap.model.MapperReference;
import org.mapstruct.ap.util.OptionsHelper; import org.mapstruct.ap.option.OptionsHelper;
import org.mapstruct.ap.util.TypeFactory; import org.mapstruct.ap.util.TypeFactory;
/** /**

View File

@ -28,7 +28,7 @@ import javax.lang.model.util.Elements;
import javax.lang.model.util.Types; import javax.lang.model.util.Types;
import javax.tools.Diagnostic.Kind; import javax.tools.Diagnostic.Kind;
import org.mapstruct.ap.model.Options; import org.mapstruct.ap.option.Options;
import org.mapstruct.ap.util.TypeFactory; import org.mapstruct.ap.util.TypeFactory;
/** /**

View File

@ -27,6 +27,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.annotation.processing.Messager; import javax.annotation.processing.Messager;
import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
@ -51,14 +52,14 @@ import org.mapstruct.ap.model.Mapper;
import org.mapstruct.ap.model.MapperReference; import org.mapstruct.ap.model.MapperReference;
import org.mapstruct.ap.model.MappingMethod; import org.mapstruct.ap.model.MappingMethod;
import org.mapstruct.ap.model.MappingMethodReference; import org.mapstruct.ap.model.MappingMethodReference;
import org.mapstruct.ap.model.Options;
import org.mapstruct.ap.model.Parameter; import org.mapstruct.ap.model.Parameter;
import org.mapstruct.ap.model.PropertyMapping; import org.mapstruct.ap.model.PropertyMapping;
import org.mapstruct.ap.model.ReportingPolicy;
import org.mapstruct.ap.model.Type; import org.mapstruct.ap.model.Type;
import org.mapstruct.ap.model.TypeConversion; import org.mapstruct.ap.model.TypeConversion;
import org.mapstruct.ap.model.source.Mapping; import org.mapstruct.ap.model.source.Mapping;
import org.mapstruct.ap.model.source.Method; import org.mapstruct.ap.model.source.Method;
import org.mapstruct.ap.option.Options;
import org.mapstruct.ap.option.ReportingPolicy;
import org.mapstruct.ap.util.Executables; import org.mapstruct.ap.util.Executables;
import org.mapstruct.ap.util.Filters; import org.mapstruct.ap.util.Filters;
import org.mapstruct.ap.util.MethodMatcher; import org.mapstruct.ap.util.MethodMatcher;
@ -112,7 +113,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Metho
.element( element ) .element( element )
.mappingMethods( mappingMethods ) .mappingMethods( mappingMethods )
.mapperReferences( mapperReferences ) .mapperReferences( mapperReferences )
.options( options ) .suppressGeneratorTimestamp( options.isSuppressGeneratorTimestamp() )
.typeFactory( typeFactory ) .typeFactory( typeFactory )
.elementUtils( elementUtils ) .elementUtils( elementUtils )
.build(); .build();

View File

@ -25,7 +25,7 @@ import javax.lang.model.util.Elements;
import javax.lang.model.util.Types; import javax.lang.model.util.Types;
import javax.tools.Diagnostic.Kind; import javax.tools.Diagnostic.Kind;
import org.mapstruct.ap.model.Options; import org.mapstruct.ap.option.Options;
import org.mapstruct.ap.util.TypeFactory; import org.mapstruct.ap.util.TypeFactory;
/** /**

View File

@ -25,7 +25,7 @@ import ${importedType.fullyQualifiedName};
</#list> </#list>
@Generated( @Generated(
value = "org.mapstruct.ap.MappingProcessor"<#if options.suppressGeneratorTimestamp == false>, value = "org.mapstruct.ap.MappingProcessor"<#if suppressGeneratorTimestamp == false>,
date = "${.now?string("yyyy-MM-dd'T'HH:mm:ssZ")}"</#if> date = "${.now?string("yyyy-MM-dd'T'HH:mm:ssZ")}"</#if>
) )
<#list annotations as annotation> <#list annotations as annotation>