Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public Collection<String> getAdditionalCommandLineArguments(ProcessorTest.Proces
default:
}

Collection<String> result = new ArrayList<String>( additionalExcludes.size() );
Collection<String> result = new ArrayList<>(additionalExcludes.size());
for ( int i = 0; i < additionalExcludes.size(); i++ ) {
result.add( "-DadditionalExclude" + i + "=" + additionalExcludes.get( i ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void replaceInFile(File file, CharSequence target, CharSequence replacem
}

private GradleRunner getRunner(String... additionalArguments) {
List<String> fullArguments = new ArrayList<String>( compileArgs );
List<String> fullArguments = new ArrayList<>(compileArgs);
fullArguments.addAll( Arrays.asList( additionalArguments ) );
return runner.withArguments( fullArguments );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public String getToExpression(ConversionContext conversionContext) {
public String getFromExpression(ConversionContext conversionContext) {
if ( requiresDecimalFormat( conversionContext ) ) {
StringBuilder sb = new StringBuilder();
sb.append( "(" + bigDecimal( conversionContext ) + ") " );
sb.append( "(" ).append( bigDecimal( conversionContext ) ).append( ") " );
appendDecimalFormatter( sb, conversionContext );
sb.append( ".parse( <SOURCE> )" );
return sb.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public String getToExpression(ConversionContext conversionContext) {
public String getFromExpression(ConversionContext conversionContext) {
if ( requiresDecimalFormat( conversionContext ) ) {
StringBuilder sb = new StringBuilder();
sb.append( "( (" + bigDecimal( conversionContext ) + ") " );
sb.append( "( (" ).append( bigDecimal( conversionContext ) ).append( ") " );
appendDecimalFormatter( sb, conversionContext );
sb.append( ".parse( <SOURCE> )" );
sb.append( " ).toBigInteger()" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ public List<Annotation> getMethodAnnotations() {
ctx.getElementUtils(),
ctx.getTypeFactory(),
ctx.getMessager() );
List<Annotation> annotations = new ArrayList<>();
annotations.addAll( additionalAnnotationsBuilder.getProcessedAnnotations( method.getExecutable() ) );
return annotations;
return new ArrayList<>( additionalAnnotationsBuilder.getProcessedAnnotations( method.getExecutable() ) );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ else if ( !method.isUpdateMethod() ) {

Map<String, ReadAccessor> readAccessors = sourceParameter.getType().getPropertyReadAccessors();

for ( Entry<String, ReadAccessor> entry : readAccessors.entrySet() ) {
unprocessedSourceProperties.put( entry.getKey(), entry.getValue() );
}
unprocessedSourceProperties.putAll( readAccessors );
}

// get bean mapping (when specified as annotation )
Expand Down Expand Up @@ -499,7 +497,7 @@ private boolean isCorrectlySealed(Type mappingSourceType) {
new ArrayList<>( mappingSourceType.getPermittedSubclasses() );
method.getOptions().getSubclassMappings().forEach( subClassOption -> {
for (Iterator<? extends TypeMirror> iterator = unusedPermittedSubclasses.iterator();
iterator.hasNext(); ) {
iterator.hasNext(); ) {
if ( ctx.getTypeUtils().isSameType( iterator.next(), subClassOption.getSource() ) ) {
iterator.remove();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ else if ( mappingsKeyedByProperty.isEmpty() && nonNested.isEmpty() ) {
* @param hasNoMappings parameter indicating whether there were any extracted mappings for this target property
* @param sourceParameter the source parameter for which the grouping is being done
*
* @return a list with valid single target references
* @return a set with valid single target references
*/
private Set<MappingReference> extractSingleTargetReferencesToUseAndPopulateSourceParameterMappings(
Set<MappingReference> singleTargetReferences, Set<MappingReference> sourceParameterMappings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ private PropertyMapping(String name, String sourceBeanName, String targetWriteAc
this.targetType = targetType;

this.assignment = assignment;
this.dependsOn = dependsOn != null ? dependsOn : Collections.<String>emptySet();
this.dependsOn = dependsOn != null ? dependsOn : Collections.emptySet();
this.defaultValueAssignment = defaultValueAssignment;
this.constructorMapping = constructorMapping;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,8 @@ else if ( isJodaDateTimeSupposed( sourceType, targetType ) ) {
dateFormatValidator = new JodaTimeDateFormatValidator();
}
else {
dateFormatValidator = new DateFormatValidator() {
@Override
public DateFormatValidationResult validate(String dateFormat) {
return new DateFormatValidationResult( true, Message.GENERAL_UNSUPPORTED_DATE_FORMAT_CHECK,
sourceType, targetType );
}
};
dateFormatValidator = dateFormat -> new DateFormatValidationResult(
true, Message.GENERAL_UNSUPPORTED_DATE_FORMAT_CHECK, sourceType, targetType );
}
return dateFormatValidator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,9 @@ public PresenceCheckAccessor getPresenceChecker(String propertyName) {
*/
public Map<String, ReadAccessor> getPropertyReadAccessors() {
if ( readAccessors == null ) {
Map<String, ReadAccessor> modifiableGetters = new LinkedHashMap<>();

Map<String, ReadAccessor> recordAccessors = filters.recordAccessorsIn( getRecordComponents() );
modifiableGetters.putAll( recordAccessors );
Map<String, ReadAccessor> modifiableGetters = new LinkedHashMap<>(recordAccessors);

List<ReadAccessor> getterList = filters.getterMethodsIn( getAllMethods() );
for ( ReadAccessor getter : getterList ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
public class MappingContext {

private final List<String> invokedMethods = new ArrayList<String>();
private final List<String> invokedMethods = new ArrayList<>();

@BeforeMapping
public void beforeWithoutParameters() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ParentChildBuilderTest {
public void testParentChildBuilderMapper() {
final MutableParent parent = new MutableParent();
parent.setCount( 4 );
parent.setChildren( new ArrayList<MutableChild>() );
parent.setChildren( new ArrayList<>() );
parent.getChildren().add( new MutableChild( "Phineas" ) );
parent.getChildren().add( new MutableChild( "Ferb" ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class SimpleImmutablePerson {
this.job = builder.job;
this.city = builder.city;
this.address = builder.address;
this.children = new ArrayList<String>( builder.children );
this.children = new ArrayList<>(builder.children);
}

public static Builder builder() {
Expand Down Expand Up @@ -59,7 +59,7 @@ public static class Builder {
private String job;
private String city;
private String address;
private List<String> children = new ArrayList<String>();
private List<String> children = new ArrayList<>();

public Builder age(int age) {
this.age = age;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class BaseMapper {
@Qualified
public abstract Target sourceToTargetQualified(Source source);

private static final List<Invocation> INVOCATIONS = new ArrayList<Invocation>();
private static final List<Invocation> INVOCATIONS = new ArrayList<>();

@BeforeMapping
public void noArgsBeforeMapping() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void callbackMethodsForEnumMappingCalled() {
SourceEnum source = SourceEnum.B;
TargetEnum target = SourceTargetMapper.INSTANCE.toTargetEnum( source );

List<Invocation> invocations = new ArrayList<Invocation>();
List<Invocation> invocations = new ArrayList<>();
invocations.addAll( allBeforeMappingMethods( source, target, TargetEnum.class ) );
invocations.addAll( allAfterMappingMethods( source, target, TargetEnum.class ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author Andreas Gudian
*/
public class ClassContainingCallbacks {
private static final List<Invocation> INVOCATIONS = new ArrayList<Invocation>();
private static final List<Invocation> INVOCATIONS = new ArrayList<>();

@BeforeMapping
public void noArgsBeforeMapping() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ void updatingWithDefaultHandlingRaisesStackOverflowError() {
@ProcessorTest
void mappingWithContextCorrectlyResolvesCycles() {
final AtomicReference<Integer> contextLevel = new AtomicReference<>( null );
ContextListener contextListener = new ContextListener() {
@Override
public void methodCalled(Integer level, String method, Object source, Object target) {
contextLevel.set( level );
}
};
ContextListener contextListener = (level, method, source, target) -> contextLevel.set( level );

NodeMapperContext.addContextListener( contextListener );
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
* @author Pascal Grün
*/
public class NodeMapperContext {
private static final ThreadLocal<Integer> LEVEL = new ThreadLocal<Integer>();
private static final ThreadLocal<Map<Object, Object>> MAPPING = new ThreadLocal<Map<Object, Object>>();
private static final ThreadLocal<Integer> LEVEL = new ThreadLocal<>();
private static final ThreadLocal<Map<Object, Object>> MAPPING = new ThreadLocal<>();

/** Only for test-inspection */
private static final List<ContextListener> LISTENERS = new CopyOnWriteArrayList<ContextListener>();
private static final List<ContextListener> LISTENERS = new CopyOnWriteArrayList<>();

private NodeMapperContext() {
// Only allow static access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public class Target2 {

private List<Foo> attributes = new ArrayList<Foo>();
private List<Foo> attributes = new ArrayList<>();

public Foo addAttribute( Foo foo ) {
attributes.add( foo );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*
*/
public class NoSetterTarget {
private List<String> listValues = new ArrayList<String>();
private Map<String, String> mapValues = new HashMap<String, String>();
private List<String> listValues = new ArrayList<>();
private Map<String, String> mapValues = new HashMap<>();

public List<String> getListValues() {
return listValues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Set<String> getColours() {

public List<String> getStringListNoSetter() {
if ( stringListNoSetter == null ) {
stringListNoSetter = new ArrayList<String>();
stringListNoSetter = new ArrayList<>();
}
return stringListNoSetter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
package org.mapstruct.ap.test.nestedbeans;

import java.util.Objects;

public class HouseDto {

private String name;
Expand Down Expand Up @@ -58,10 +60,10 @@ public boolean equals(Object o) {
if ( year != houseDto.year ) {
return false;
}
if ( name != null ? !name.equals( houseDto.name ) : houseDto.name != null ) {
if ( !Objects.equals( name, houseDto.name ) ) {
return false;
}
return roof != null ? roof.equals( houseDto.roof ) : houseDto.roof == null;
return Objects.equals( roof, houseDto.roof );

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.mapstruct.ap.test.nestedbeans.maps;

import java.util.Map;
import java.util.Objects;

public class AntonymsDictionaryDto {
private Map<WordDto, WordDto> antonyms;
Expand Down Expand Up @@ -36,8 +37,7 @@ public boolean equals(Object o) {

AntonymsDictionaryDto antonymsDictionaryDto = (AntonymsDictionaryDto) o;

return antonyms != null ? antonyms.equals( antonymsDictionaryDto.antonyms ) :
antonymsDictionaryDto.antonyms == null;
return Objects.equals( antonyms, antonymsDictionaryDto.antonyms );

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void testShouldSelectResultTypeInCaseOfAmbiguityForIterable() {
})
public void testShouldSelectResultTypeInCaseOfAmbiguityForMap() {

Map<AppleDto, AppleDto> source = new HashMap<AppleDto, AppleDto>();
Map<AppleDto, AppleDto> source = new HashMap<>();
source.put( new AppleDto( "GoldenDelicious" ), new AppleDto( "AppleDto" ) );

Map<Apple, Apple> result = FruitFamilyMapper.INSTANCE.mapToGoldenDeliciousMap( source );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Target {
private int integerConstant;
private Long longWrapperConstant;
private Date dateConstant;
private List<String> nameConstants = new ArrayList<String>();
private List<String> nameConstants = new ArrayList<>();
private CountryEnum country;

public String getPropertyThatShouldBeMapped() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public AbstractCharSequenceAssert<?, String> content() {
return Assertions.assertThat( FileUtils.readFileToString( actual, StandardCharsets.UTF_8 ) );
}
catch ( IOException e ) {
failWithMessage( "Unable to read" + actual.toString() + ". Exception: " + e.getMessage() );
failWithMessage( "Unable to read" + actual + ". Exception: " + e.getMessage() );
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private static URI getUri(javax.tools.Diagnostic<? extends JavaFileObject> diagn

//Make the URI absolute in case it isn't (the case with JDK 6)
try {
return new URI( "file:" + uri.toString() );
return new URI( "file:" + uri );
}
catch ( URISyntaxException e ) {
throw new RuntimeException( e );
Expand Down Expand Up @@ -189,7 +189,7 @@ public boolean equals(Object obj) {
if ( kind != other.kind ) {
return false;
}
if ( line != other.line ) {
if ( !Objects.equals( line, other.line ) ) {
return false;
}
if ( !Objects.equals( message, other.message ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected List<DiagnosticDescriptor> filterExpectedDiagnostics(List<DiagnosticDe
// The JDK 8+ compilers report all ERROR diagnostics properly. Also when there are multiple per line.
return expectedDiagnostics;
}
List<DiagnosticDescriptor> filtered = new ArrayList<DiagnosticDescriptor>( expectedDiagnostics.size() );
List<DiagnosticDescriptor> filtered = new ArrayList<>(expectedDiagnostics.size());

// The JDK 8 compiler only reports the first message of kind ERROR that is reported for one source file line,
// so we filter out the surplus diagnostics. The input list is already sorted by file name and line number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class ModifiableURLClassLoader extends URLClassLoader {
tryRegisterAsParallelCapable();
}

private final ConcurrentMap<URL, URL> addedURLs = new ConcurrentHashMap<URL, URL>();
private final ConcurrentMap<URL, URL> addedURLs = new ConcurrentHashMap<>();

ModifiableURLClassLoader(ClassLoader parent) {
super( new URL[] { }, parent );
Expand Down