SelectionParameters { @Override public boolean equals(Object obj) { if ( this == obj ) { return true; } if ( obj == null ) { return false; } if ( getClass() != obj.getClass() ) { return false; } final SelectionParameters other = (SelectionParameters) obj; if ( !equals( this.qualifiers, other.qualifiers ) ) { return false; } if ( !Objects.equals( this.qualifyingNames, other.qualifyingNames ) ) { return false; } if ( !Objects.equals( this.sourceRHS, other.sourceRHS ) ) { return false; } return equals( this.resultType, other.resultType ); } SelectionParameters(List<TypeMirror> qualifiers, List<String> qualifyingNames, TypeMirror resultType,
        Types typeUtils); private  SelectionParameters(List<TypeMirror> qualifiers, List<String> qualifyingNames, TypeMirror resultType,
        Types typeUtils, SourceRHS sourceRHS); static SelectionParameters forInheritance(SelectionParameters selectionParameters); List<TypeMirror> getQualifiers(); List<String> getQualifyingNames(); TypeMirror getResultType(); SourceRHS getSourceRHS(); @Override int hashCode(); @Override boolean equals(Object obj); static SelectionParameters forSourceRHS(SourceRHS sourceRHS);  }
@Test public void testEqualsSameInstance() { List<String> qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); List<TypeMirror> qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); assertThat( params.equals( params ) ).as( "Self equals" ).isTrue(); }
@Test public void testEqualsWitNull() { List<String> qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); List<TypeMirror> qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); assertThat( params.equals( null ) ).as( "Equals with null" ).isFalse(); }
@Test public void testEqualsQualifiersOneNull() { List<String> qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); List<TypeMirror> qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); SelectionParameters params2 = new SelectionParameters( null, qualifyingNames, resultType, typeUtils ); assertThat( params.equals( params2 ) ).as( "Second null qualifiers" ).isFalse(); assertThat( params2.equals( params ) ).as( "First null qualifiers" ).isFalse(); }
@Test public void testEqualsQualifiersInDifferentOrder() { List<String> qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); List<TypeMirror> qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); List<TypeMirror> qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames, resultType, typeUtils ); assertThat( params.equals( params2 ) ).as( "Different order for qualifiers" ).isFalse(); assertThat( params2.equals( params ) ).as( "Different order for qualifiers" ).isFalse(); }
@Test public void testEqualsQualifyingNamesOneNull() { List<String> qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); List<TypeMirror> qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); List<TypeMirror> qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, null, resultType, typeUtils ); assertThat( params.equals( params2 ) ).as( "Second null qualifyingNames" ).isFalse(); assertThat( params2.equals( params ) ).as( "First null qualifyingNames" ).isFalse(); }
@Test public void testEqualsQualifyingNamesInDifferentOrder() { List<String> qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); List<TypeMirror> qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); List<String> qualifyingNames2 = Arrays.asList( "german", "language" ); List<TypeMirror> qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType, typeUtils ); assertThat( params.equals( params2 ) ).as( "Different order for qualifyingNames" ).isFalse(); assertThat( params2.equals( params ) ).as( "Different order for qualifyingNames" ).isFalse(); }
@Test public void testEqualsResultTypeOneNull() { List<String> qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); List<TypeMirror> qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); List<String> qualifyingNames2 = Arrays.asList( "language", "german" ); List<TypeMirror> qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, null, typeUtils ); assertThat( params.equals( params2 ) ).as( "Second null resultType" ).isFalse(); assertThat( params2.equals( params ) ).as( "First null resultType" ).isFalse(); }
@Test public void testAllEqual() { List<String> qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); List<TypeMirror> qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); List<String> qualifyingNames2 = Arrays.asList( "language", "german" ); TypeMirror resultType2 = new TestTypeMirror( "resultType" ); List<TypeMirror> qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType2, typeUtils ); assertThat( params.equals( params2 ) ).as( "All equal" ).isTrue(); assertThat( params2.equals( params ) ).as( "All equal" ).isTrue(); }
@Test public void testDifferentResultTypes() { List<String> qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); List<TypeMirror> qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); List<String> qualifyingNames2 = Arrays.asList( "language", "german" ); TypeMirror resultType2 = new TestTypeMirror( "otherResultType" ); List<TypeMirror> qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType2, typeUtils ); assertThat( params.equals( params2 ) ).as( "Different resultType" ).isFalse(); assertThat( params2.equals( params ) ).as( "Different resultType" ).isFalse(); }