Skip to content

MapStruct is mapping static properties #926

@davidkron

Description

@davidkron

Hello

I'm using MapStruct 1.1.0.CR1 with Gradle and have discovered, that the generated code also maps static properties, which seems like a bug.

Bean class:

 public class Test {

    private String normalProperty;
    private static String staticProperty;

    public String getNormalProperty() {
        return normalProperty;
    }

    public void setNormalProperty(String normalProperty) {
        this.normalProperty = normalProperty;
    }

    public static String getStaticProperty() {
        return staticProperty;
    }

    public static void setStaticProperty(String staticProperty) {
        Test.staticProperty = staticProperty;
    }
 }

Mapper interface:

 @Mapper
 interface TestMapper {

    Test copy(Test test);
 }

Generated code:

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2016-10-07T10:22:47+0200",
    comments = "version: 1.1.0.CR1, compiler: javac, environment: Java 1.8.0_102 (Oracle Corporation)"
)
class TestMapperImpl implements TestMapper {

    @Override
    public Test copy(Test test) {
        if ( test == null ) {
            return null;
        }

        Test test_ = new Test();

        test_.setNormalProperty( test.getNormalProperty() );
        test_.setStaticProperty( test.getStaticProperty() );

        return test_;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions