]> git.argeo.org Git - gpl/argeo-suite.git/blob - org.argeo.app.core/src/org/argeo/app/core/SuiteTerm.java
Instrument image utils
[gpl/argeo-suite.git] / org.argeo.app.core / src / org / argeo / app / core / SuiteTerm.java
1 package org.argeo.app.core;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.argeo.app.api.Term;
7
8 /**
9 * A single term. Helper to optimise {@link SuiteTermsManager} implementation.
10 */
11 class SuiteTerm implements Term {
12 private final String name;
13 private final String relativePath;
14 private final SuiteTypology typology;
15 private final String id;
16
17 private final SuiteTerm parentTerm;
18 private final List<SuiteTerm> subTerms = new ArrayList<>();
19
20 SuiteTerm(SuiteTypology typology, String relativePath, SuiteTerm parentTerm) {
21 this.typology = typology;
22 this.parentTerm = parentTerm;
23 this.relativePath = relativePath;
24 int index = relativePath.lastIndexOf('/');
25 if (index > 0) {
26 this.name = relativePath.substring(index + 1);
27 } else {
28 this.name = relativePath;
29 }
30 id = typology.getName() + '/' + relativePath;
31 }
32
33 @Override
34 public String getId() {
35 return id;
36 }
37
38 @Override
39 public String getName() {
40 return name;
41 }
42
43 public String getRelativePath() {
44 return relativePath;
45 }
46
47 @Override
48 public SuiteTypology getTypology() {
49 return typology;
50 }
51
52 @Override
53 public List<SuiteTerm> getSubTerms() {
54 return subTerms;
55 }
56
57 @Override
58 public SuiteTerm getParentTerm() {
59 return parentTerm;
60 }
61
62 }