Skip to content

Possability to add more than one blueprint of one class #29

@shaddysignal

Description

@shaddysignal

Example:

@Blueprint(Car.class)
public class CarBlueprint {

    @Default
    String make = "car make";

    @Default
    String manufacturer = "car manufacturer";

    @Default
    Integer mileage = 100;
}

@Blueprint(Car.class)
public class CoolCarBlueprint {

    @Default
    String make = "cool brand";

    @Default
    String manufacturer = "cool brand ltd";

    @Default
    Integer mileage = 0;
}

@Blueprint(Car.class, alias = "bad")
public class BadCarBlueprint {

   @Default
   String make = "bad brand";

   @Default
   String manufacturer = "bad brand ltd";

   @Default
   Integer mileage = 500;
}

ModelFactory modelFactory = new ModelFactory();
modelFactory.registerBlueprint(CarBlueprint.class);
modelFactory.registerBlueprint("cool", CoolCarBlueprint.class,);
modelFactory.registerBlueprint(BadCarBlueprint.class);
Car car = modelFactory.createModel(Car.class); // -> Default car
Car coolCar = modelFactory.createModel("cool", Car.class); // -> Cool car
Car badCar = modelFactory.createModel("bad", Car.class); // -> Bad car

That will allow to create single factory for multiple cases, when we need to create different instances of one class. Also, it seems that @Mapped, @MappedList, @MappedSet, @Blueprint and addPolicy should also be modified for new functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions