<dependency>
<groupId>com.example</groupId>
<artifactId>targeting-framework</artifactId>
<version>1.0</version>
</dependency>
public enum ProductCategory {
FOOD, CLOTHING, ELECTRONICS;
}
@TargetingRule
public class UserPreferenceTargetingRule implements Targeting<User> {
@Override
public boolean matches(User user) {
}
}
@TargetingRule
public class RecommendationStrategy implements Targeting<Product> {
@TargetingValue("FOOD")
public boolean isFood(Product product) {
}
@TargetingValue("CLOTHING")
public boolean isClothing(Product product) {
}
@TargetingValue("ELECTRONICS")
public boolean isElectronics(Product product) {
}
}
public class RecommendationService {
@TargetingInject
private TargetingEngine<User> targetingEngine;
@TargetingInject
private TargetingEngine<Product> productTargetingEngine;
public List<Product> recommend(User user) {
List<Product> recommendedProducts = new ArrayList<>();
targetingEngine.process(user, recommendedProducts, RecommendationStrategy.class);
return recommendedProducts;
}
}