You're right Rickard. I'm constructing a company entity that looks
something like this (the Company interface is a simple one with just
the name while Employer and HumanResources handle different
responsibilities such as hire/fire and create/remove Positions):

@Mixins({ EmployerMixin.class  })
public interface CompanyEntity
        extends Company, Employer, HumanResources, EntityComposite {
}


I moved the implementing HumanResourcesMixin into the HumanResources
interface itself instead of being in the CompanyEntity above. Still no
dice and getting NPE when accessing listProperty variable below. It
seems like the HumanResourceState is not getting initialized?
Eventually I want to expose the positions at the HumanResources
interface also (e.g. the gui would need to know what positions are
existing in a company for  a lookup list).

@Mixins({HumanResources.HumanResourcesMixin.class,
HumanResources.HumanResourceState.class})
public interface HumanResources {

    interface HumanResourceState {
        @UseDefaults
        Property<List<Position>> positions();
    }

    Position createPosition(String name);

    void deletePosition(Position position);

    public class HumanResourcesMixin implements HumanResources {

        @Structure
        private ValueBuilderFactory vbf;

        @This HumanResourceState state;

        public Position createPosition(String name) {

            final ValueBuilder<Position> builder =
vbf.newValueBuilder(Position.class);
            final Position prototype = builder.prototype();
            prototype.title().set(name);

            final Position position = builder.newInstance();
            final Property<List<Position>> listProperty = state.positions();
            listProperty.get().add(position);
            return position;
        }

        public void deletePosition(Position position) {

        }
    }

}
Thanks again!

/Aye

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to