1- /**
1+ /*
22 * Copyright © Magento, Inc. All rights reserved.
33 * See COPYING.txt for license details.
44 */
5+
56package com .magento .idea .magento2plugin .project .validator ;
67
78import com .intellij .openapi .options .ConfigurationException ;
8- import com .magento .idea .magento2plugin .util .magento .MagentoVersionUtil ;
99import com .magento .idea .magento2plugin .bundles .ValidatorBundle ;
1010import com .magento .idea .magento2plugin .project .SettingsForm ;
1111import com .magento .idea .magento2plugin .util .RegExUtil ;
1212import com .magento .idea .magento2plugin .util .magento .MagentoBasePathUtil ;
13+ import com .magento .idea .magento2plugin .util .magento .MagentoVersionUtil ;
1314
1415public class SettingsFormValidator {
15- private static SettingsFormValidator INSTANCE = null ;
16- private SettingsForm form ;
17- private ValidatorBundle validatorBundle ;
18-
19- public static SettingsFormValidator getInstance (SettingsForm form ) {
20- if (null == INSTANCE ) {
21- INSTANCE = new SettingsFormValidator ();
22- }
23- INSTANCE .form = form ;
24- return INSTANCE ;
25- }
16+ private final SettingsForm form ;
17+ private final ValidatorBundle validatorBundle ;
2618
27- public SettingsFormValidator () {
19+ public SettingsFormValidator (
20+ final SettingsForm form
21+ ) {
22+ this .form = form ;
2823 this .validatorBundle = new ValidatorBundle ();
2924 }
3025
26+ /**
27+ * Validate form.
28+ *
29+ * @throws ConfigurationException
30+ */
3131 public void validate () throws ConfigurationException {
3232 if (!form .getSettings ().pluginEnabled ) {
3333 return ;
3434 }
3535
3636 if (!MagentoBasePathUtil .isMagentoFolderValid (form .getMagentoPath ())) {
37- throw new ConfigurationException (validatorBundle .message ("validator.package.validPath" ));
37+ throw new ConfigurationException (
38+ validatorBundle .message ("validator.package.validPath" )
39+ );
3840 }
3941
40- String magentoVersion = form .getMagentoVersion ();
42+ final String magentoVersion = form .getMagentoVersion ();
4143 if (magentoVersion .length () == 0 ) {
42- throw new ConfigurationException (validatorBundle .message ("validator.notEmpty" , "Magento Version" ));
44+ throw new ConfigurationException (
45+ validatorBundle .message ("validator.notEmpty" , "Magento Version" )
46+ );
4347 }
4448
45- if (!magentoVersion .matches (RegExUtil .MAGENTO_VERSION ) && !magentoVersion .equals (MagentoVersionUtil .DEFAULT_VERSION )) {
46- throw new ConfigurationException (validatorBundle .message ("validator.magentoVersionInvalid" ));
49+ if (!magentoVersion .matches (RegExUtil .MAGENTO_VERSION ) &&
50+ !magentoVersion .equals (MagentoVersionUtil .DEFAULT_VERSION )) {
51+ throw new ConfigurationException (
52+ validatorBundle .message ("validator.magentoVersionInvalid" )
53+ );
4754 }
4855 }
4956}
0 commit comments