1515import java .util .List ;
1616import java .util .concurrent .Callable ;
1717
18+ /**
19+ * A Callable task for initializing a product with the given parameters.
20+ *
21+ * @param productNumber The number of the product to initialize.
22+ * @param productName The name of the product to initialize.
23+ * @param configPath The path to the configuration file for the product.
24+ * @param sourcePath The path to the source files for the product.
25+ * @param allFeatures The set of all features implemented by the product.
26+ * @param usedLanguage The primary language used in the product.
27+ * @return An InitResult object representing the result of the initialization
28+ * task.
29+ * @throws Exception If an error occurs during the initialization process.
30+ */
1831public class ProductInitializationTask implements Callable <ProductInitializationTask .InitResult > {
1932 private final int productNumber ;
2033 private final String productName ;
2134 private final File configPath ;
2235 private final File sourcePath ;
2336 private final EccoSet <Feature > allFeatures ;
24- private final ESupportedLanguages targetLanguage ;
37+ private final ESupportedLanguages usedLanguage ;
2538
26- public ProductInitializationTask (final int productNumber , final ProductPassport passport , final ESupportedLanguages targetLanguage ) {
39+ /**
40+ * Initializes a ProductInitializationTask with the given product number,
41+ * product passport, and target language.
42+ *
43+ * @param productNumber the product number to assign to the task
44+ * @param passport the product passport containing information about the
45+ * product
46+ * @param targetLanguage the target language for the task
47+ */
48+ public ProductInitializationTask (final int productNumber , final ProductPassport passport ,
49+ final ESupportedLanguages targetLanguage ) {
2750 this .productNumber = productNumber ;
2851 this .productName = passport .getName ();
2952 this .configPath = passport .getConfiguration ().toFile ();
3053 this .sourcePath = passport .getSourcesRoot ().toFile ();
3154 this .allFeatures = new EccoSet <>();
32- this .targetLanguage = targetLanguage ;
55+ this .usedLanguage = targetLanguage ;
3356 }
3457
58+ /**
59+ * Parses the sources and creates an InitResult with the created product.
60+ *
61+ * This method reads a configuration file specified by the configPath parameter,
62+ * parses the features listed in the file,
63+ * creates a product AST based on the target language specified, and returns an
64+ * InitResult object containing the parsed information.
65+ *
66+ * @return InitResult - an object containing the parsed information
67+ * @throws Exception - if an error occurs during parsing or creating the
68+ * InitResult object
69+ */
3570 @ Override
3671 public InitResult call () throws Exception {
3772 Logger .info ("Parsing variant " + productNumber + "..." );
@@ -52,7 +87,7 @@ public InitResult call() throws Exception {
5287 }
5388 final AbstractAST productAst ;
5489 try {
55- switch (targetLanguage ) {
90+ switch (usedLanguage ) {
5691 case C :
5792 productAst = new CAST (sourcePath );
5893 break ;
@@ -63,20 +98,45 @@ public InitResult call() throws Exception {
6398 productAst = new LineAST (sourcePath );
6499 break ;
65100 default :
66- throw new IllegalStateException ("Unexpected value: " + targetLanguage );
101+ throw new IllegalStateException ("Unexpected value: " + usedLanguage );
67102 }
68103 } catch (final Exception e ) {
69104 throw new RuntimeException ("Was not able to parse " + sourcePath , e );
70105 }
71106
72- return new InitResult (productNumber , allFeatures , new Product (productName , new EccoSet <>(), productAst , productFeatures ));
107+ return new InitResult (productNumber , allFeatures ,
108+ new Product (productName , new EccoSet <>(), productAst , productFeatures ));
73109 }
74110
111+ /**
112+ * Represents the result of initializing a product.
113+ * Contains the ID of the initialization, a set of all features, and the product
114+ * associated with the initialization.
115+ */
75116 public static class InitResult {
117+ /**
118+ * The ID of the initialization.
119+ */
76120 public final int id ;
121+
122+ /**
123+ * A set of all features associated with the initialization.
124+ */
77125 public final EccoSet <Feature > allFeatures ;
126+
127+ /**
128+ * The product associated with the initialization.
129+ */
78130 public final Product product ;
79131
132+ /**
133+ * Constructs a new InitResult with the specified ID, set of all features, and
134+ * product.
135+ *
136+ * @param id The ID of the initialization.
137+ * @param allFeatures A set of all features associated with the initialization.
138+ * @param product The product associated with the initialization.
139+ */
80140 public InitResult (final int id , final EccoSet <Feature > allFeatures , final Product product ) {
81141 this .id = id ;
82142 this .allFeatures = allFeatures ;
0 commit comments