X-Git-Url: http://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=org.argeo.suite.core%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fcore%2FSuiteTerm.java;fp=org.argeo.suite.core%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fcore%2FSuiteTerm.java;h=0c03dc514826dae39dc2ed80cc10f782c2f37bfb;hp=0000000000000000000000000000000000000000;hb=678186f16393cdafbd5430adbad98359179c96bd;hpb=9dd16d64cc4ea274c33a4c1acaa289c46bf5251f diff --git a/org.argeo.suite.core/src/org/argeo/suite/core/SuiteTerm.java b/org.argeo.suite.core/src/org/argeo/suite/core/SuiteTerm.java new file mode 100644 index 0000000..0c03dc5 --- /dev/null +++ b/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; + } + +}