Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
querdenker2k committed Jan 1, 2025
1 parent aa2b627 commit 9820b47
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private Map<String, Object> createActionModel(Thing thing) {
return freemarkerModel;
}

public static Class<?> replaceTypeIfNecessary(Class<?> type) {
private Class<?> replaceTypeIfNecessary(Class<?> type) {
if (type.isPrimitive() || "org.openhab.core.library.types".equals(type.getPackageName())
|| "org.openhab.core.types".equals(type.getPackageName())
|| type.getPackageName().startsWith("java.")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class JRuleConfig {
private static final String WORKING_DIR_PROPERTY = "org.openhab.automation.jrule.directory";
private static final String GENERATED_ITEM_PREFIX_PROPERTY = "org.openhab.automation.jrule.itemprefix";
private static final String GENERATED_ITEM_PACKAGE_PROPERTY = "org.openhab.automation.jrule.itempackage";
private static final String GENERATED_PERSISTENCE_PACKAGE_PROPERTY = "org.openhab.automation.jrule.persistencepackage";
private static final String GENERATED_THING_PACKAGE_PROPERTY = "org.openhab.automation.jrule.thingpackage";
private static final String EXECUTORS_MIN_PROPERTY = "org.openhab.automation.jrule.engine.executors.min";
private static final String EXECUTORS_MAX_PROPERTY = "org.openhab.automation.jrule.engine.executors.max";
Expand All @@ -64,7 +63,6 @@ public class JRuleConfig {
+ File.separator + "automation" + File.separator + "jrule";
private static final String DEFAULT_GENERATED_ITEM_PREFIX = "_";
private static final String DEFAULT_GENERATED_ITEM_PACKAGE = "org.openhab.automation.jrule.generated.items";
private static final String DEFAULT_GENERATED_PERSISTENCE_PACKAGE = "org.openhab.automation.jrule.generated.persistence";
private static final String DEFAULT_GENERATED_THING_PACKAGE = "org.openhab.automation.jrule.generated.things";
private static final String DEFAULT_GENERATED_ACTION_PACKAGE = "org.openhab.automation.jrule.generated.actions";

Expand Down Expand Up @@ -140,14 +138,6 @@ public String getItemsDirectory() {
return sb.toString();
}

public String getPersistenceDirectory() {
final StringBuilder sb = new StringBuilder(getWorkingDirectory());
sb.append(File.separator).append(GEN).append(File.separator);
final String p = JRuleUtil.packageNameToPath(getGeneratedPersistencePackage());
sb.append(p);
return sb.toString();
}

public String getThingsDirectory() {
final StringBuilder sb = new StringBuilder(getWorkingDirectory());
sb.append(File.separator).append(GEN).append(File.separator);
Expand Down Expand Up @@ -255,11 +245,6 @@ public String getGeneratedItemPackage() {
return getConfigPropertyOrDefaultValue(GENERATED_ITEM_PACKAGE_PROPERTY, DEFAULT_GENERATED_ITEM_PACKAGE);
}

public String getGeneratedPersistencePackage() {
return getConfigPropertyOrDefaultValue(GENERATED_PERSISTENCE_PACKAGE_PROPERTY,
DEFAULT_GENERATED_PERSISTENCE_PACKAGE);
}

public String getGeneratedThingPackage() {
return getConfigPropertyOrDefaultValue(GENERATED_THING_PACKAGE_PROPERTY, DEFAULT_GENERATED_THING_PACKAGE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@
*/
public abstract class JRuleAbstractClassGenerator {
protected final JRuleConfig jRuleConfig;
public static final Configuration freemarkerConfiguration;
protected final Configuration freemarkerConfiguration;

public JRuleAbstractClassGenerator(JRuleConfig jRuleConfig) {
this.jRuleConfig = jRuleConfig;

static {
// Create your Configuration instance, and specify if up to what FreeMarker
// version (here 2.3.29) do you want to apply the fixes that are not 100%
// backward-compatible. See the Configuration JavaDoc for details.
freemarkerConfiguration = new Configuration(Configuration.VERSION_2_3_31);

// Specify the source where the template files come from. Here I set a
// plain directory for it, but non-file-system sources are possible too:
freemarkerConfiguration.setClassForTemplateLoading(JRuleAbstractClassGenerator.class, "/templates");
freemarkerConfiguration.setClassForTemplateLoading(this.getClass(), "/templates");
// From here we will set the settings recommended for new projects. These
// aren't the defaults for backward compatibilty.

Expand All @@ -57,8 +59,4 @@ public abstract class JRuleAbstractClassGenerator {
// Do not fall back to higher scopes when reading a null loop variable:
freemarkerConfiguration.setFallbackOnNullLoopVariable(false);
}

public JRuleAbstractClassGenerator(JRuleConfig jRuleConfig) {
this.jRuleConfig = jRuleConfig;
}
}

0 comments on commit 9820b47

Please sign in to comment.