@@ -111,7 +111,12 @@ open class FileTreeNode() {
111111 * get the real name replace with placeholder
112112 */
113113 fun getRealName (): String {
114- return name.replacePlaceholder(getPlaceholderInherit(), ! isDir)
114+ return getRealName(this .name)
115+ }
116+
117+ fun getRealName (fileName : String = this.name): String {
118+
119+ return fileName.replacePlaceholder(getPlaceholderInherit(), ! isDir)
115120 }
116121
117122 fun getFileTemplateInherit (): MutableMap <String , String >? {
@@ -130,21 +135,21 @@ open class FileTreeNode() {
130135 template = name
131136 }
132137
133- fun placeholder (name : String , value : String ) {
134- if (this .placeholders == null ) {
135- this .placeholders = mutableMapOf ()
136- }
137- placeholders!! [name] = value
138- }
139-
140- fun placeholders (placeholders : Map <String , String >) {
138+ fun addPlaceholders (placeholders : Map <String , String >) {
141139 if (this .placeholders == null ) {
142140 this .placeholders = mutableMapOf ()
143141 }
144142 this .placeholders!! .putAll(placeholders)
145143 }
146144
147- fun fileTemplates (placeholders : Map <String , String >) {
145+ // fun getAllPlaceholderInName(): Map<String, String> {
146+ // val result = mutableMapOf<String, String>()
147+ // traversal({ fileTreeNode: FileTreeNode, i: Int ->
148+ //
149+ // })
150+ // }
151+
152+ fun addFileTemplates (placeholders : Map <String , String >) {
148153 if (this .fileTemplates == null ) {
149154 this .fileTemplates = mutableMapOf ()
150155 }
@@ -190,31 +195,6 @@ open class FileTreeNode() {
190195 }
191196 }
192197
193- /* *
194- * merge all children of another node to this.
195- * all placeholders and file templates of target node
196- * will be copied to it's each children
197- */
198- fun include (other : FileTreeNode , override : Boolean = false) {
199- if (! isDir) return
200- other.children.forEach {
201- val clone = it.clone()
202- if (other.placeholders != null ) {
203- if (clone.placeholders == null ) {
204- clone.placeholders = mutableMapOf ()
205- }
206- clone.placeholders?.putAll(other.placeholders!! )
207- }
208- if (other.fileTemplates != null ) {
209- if (clone.fileTemplates == null ) {
210- clone.fileTemplates = mutableMapOf ()
211- }
212- clone.fileTemplates?.putAll(other.fileTemplates!! )
213- }
214- addChild(clone, override )
215- }
216- }
217-
218198 /* *
219199 * create directories tree from a list
220200 * the larger the index, the deeper the directory
@@ -257,6 +237,16 @@ open class FileTreeNode() {
257237 return this == parent
258238 }
259239
240+ fun getAllPlaceholders (): Map <String , String > {
241+ val result = mutableMapOf<String , String >()
242+ traversal({ fileTreeNode: FileTreeNode , _: Int ->
243+ if (fileTreeNode.placeholders != null ) {
244+ result.putAll(fileTreeNode.placeholders!! )
245+ }
246+ })
247+ return result
248+ }
249+
260250 fun getTreeGraph (): String {
261251 return getNodeGraph().toString()
262252 }
@@ -335,7 +325,7 @@ open class FileTreeNode() {
335325 }
336326 }
337327
338- protected fun getLabel (): String {
328+ private fun getLabel (): String {
339329 return " ${name} _$isDir "
340330 }
341331
0 commit comments