X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=core%2Forg.argeo.suite.core%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fcore%2FSuiteTerm.java;fp=core%2Forg.argeo.suite.core%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fcore%2FSuiteTerm.java;h=0c03dc514826dae39dc2ed80cc10f782c2f37bfb;hp=0000000000000000000000000000000000000000;hb=418ea1efbf3f0d6b706603c6ff1c0fdd17314773;hpb=70010c4afc5799622fcad5b075740d94da074798 diff --git a/core/org.argeo.suite.core/src/org/argeo/suite/core/SuiteTerm.java b/core/org.argeo.suite.core/src/org/argeo/suite/core/SuiteTerm.java new file mode 100644 index 0000000..0c03dc5 --- /dev/null +++ b/core/org.argeo.suite.core/src/org/argeo/suite/core/SuiteTerm.java @@ -0,0 +1,55 @@ +package org.argeo.suite.core; + +import java.util.ArrayList; +import java.util.List; + +/** + * A single term. Helper to optimise {@link SuiteTermsManager} implementation. + */ +class SuiteTerm { + private final String name; + private final String relativePath; + private final SuiteTypology typology; + private final String id; + + private final SuiteTerm parentTerm; + private final List subTerms = new ArrayList<>(); + + SuiteTerm(SuiteTypology typology, String relativePath, SuiteTerm parentTerm) { + this.typology = typology; + this.parentTerm = parentTerm; + this.relativePath = relativePath; + int index = relativePath.lastIndexOf('/'); + if (index > 0) { + this.name = relativePath.substring(index); + } else { + this.name = relativePath; + } + id = typology.getName() + '/' + relativePath; + } + + public String getName() { + return name; + } + + public String getRelativePath() { + return relativePath; + } + + SuiteTypology getTypology() { + return typology; + } + + public String getId() { + return id; + } + + List getSubTerms() { + return subTerms; + } + + SuiteTerm getParentTerm() { + return parentTerm; + } + +}