Skip to content

Commit c1a4b5b

Browse files
authored
Merge pull request #164 from divyagar/master
fix: Removed repeated section in loadModel and loadModelFromText in Model.java
2 parents f2af272 + 0f8c1a1 commit c1a4b5b

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/main/java/org/casbin/jcasbin/model/Model.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ private void loadSection(Model model, Config cfg, String sec) {
107107
}
108108
}
109109

110+
/*
111+
* Helper function for loadModel and loadModelFromText
112+
*
113+
* @param config the configuration parser
114+
*/
115+
private void loadSections(Config cfg) {
116+
loadSection(this, cfg, "r");
117+
loadSection(this, cfg, "p");
118+
loadSection(this, cfg, "e");
119+
loadSection(this, cfg, "m");
120+
121+
loadSection(this, cfg, "g");
122+
}
123+
110124
/**
111125
* loadModel loads the model from model CONF file.
112126
*
@@ -115,12 +129,7 @@ private void loadSection(Model model, Config cfg, String sec) {
115129
public void loadModel(String path) {
116130
Config cfg = Config.newConfig(path);
117131

118-
loadSection(this, cfg, "r");
119-
loadSection(this, cfg, "p");
120-
loadSection(this, cfg, "e");
121-
loadSection(this, cfg, "m");
122-
123-
loadSection(this, cfg, "g");
132+
loadSections(cfg);
124133
}
125134

126135
/**
@@ -131,12 +140,7 @@ public void loadModel(String path) {
131140
public void loadModelFromText(String text) {
132141
Config cfg = Config.newConfigFromText(text);
133142

134-
loadSection(this, cfg, "r");
135-
loadSection(this, cfg, "p");
136-
loadSection(this, cfg, "e");
137-
loadSection(this, cfg, "m");
138-
139-
loadSection(this, cfg, "g");
143+
loadSections(cfg);
140144
}
141145

142146
/**

0 commit comments

Comments
 (0)