001package systems.dmx.core;
002
003import systems.dmx.core.model.ChildTopicsModel;
004import systems.dmx.core.model.TopicModel;
005
006import java.util.List;
007
008
009
010public interface ChildTopics extends Iterable<String> {
011
012
013
014    // === Accessors ===
015
016    /**
017     * Accesses a single-valued child.
018     * Throws if there is no such child.
019     */
020    RelatedTopic getTopic(String assocDefUri);
021
022    RelatedTopic getTopicOrNull(String assocDefUri);
023
024    /**
025     * Accesses a multiple-valued child.
026     * Throws if there is no such child. ### TODO: return empty list instead
027     */
028    List<RelatedTopic> getTopics(String assocDefUri);
029
030    List<RelatedTopic> getTopicsOrNull(String assocDefUri); // ### TODO: drop this method
031
032    // ---
033
034    Object get(String assocDefUri);
035
036    // ---
037
038    ChildTopicsModel getModel();
039
040
041
042    // === Convenience Accessors ===
043
044    /**
045     * Convenience accessor for the *simple* value of a single-valued child.
046     * Throws if the child doesn't exist.
047     */
048    String getString(String assocDefUri);
049
050    String getStringOrNull(String assocDefUri);
051
052    /**
053     * Convenience accessor for the *simple* value of a single-valued child.
054     * Throws if the child doesn't exist.
055     */
056    int getInt(String assocDefUri);
057
058    Integer getIntOrNull(String assocDefUri);
059
060    /**
061     * Convenience accessor for the *simple* value of a single-valued child.
062     * Throws if the child doesn't exist.
063     */
064    long getLong(String assocDefUri);
065
066    Long getLongOrNull(String assocDefUri);
067
068    /**
069     * Convenience accessor for the *simple* value of a single-valued child.
070     * Throws if the child doesn't exist.
071     */
072    double getDouble(String assocDefUri);
073
074    Double getDoubleOrNull(String assocDefUri);
075
076    /**
077     * Convenience accessor for the *simple* value of a single-valued child.
078     * Throws if the child doesn't exist.
079     */
080    boolean getBoolean(String assocDefUri);
081
082    Boolean getBooleanOrNull(String assocDefUri);
083
084    /**
085     * Convenience accessor for the *simple* value of a single-valued child.
086     * Throws if the child doesn't exist.
087     */
088    Object getObject(String assocDefUri);
089
090    Object getObjectOrNull(String assocDefUri);
091
092    // ---
093
094    /**
095     * Convenience accessor for the *composite* value of a single-valued child.
096     * Throws if the child doesn't exist.
097     */
098    ChildTopics getChildTopics(String assocDefUri);
099
100    // Note: there are no convenience accessors for a multiple-valued child.
101
102
103
104    // === Manipulators ===
105
106    // --- Single-valued Childs ---
107
108    /**
109     * Sets a child.
110     */
111    ChildTopics set(String assocDefUri, TopicModel value);
112
113    // ---
114
115    /**
116     * Convenience method to set the simple value of a child.
117     *
118     * @param   value   The simple value.
119     *                  Either String, Integer, Long, Double, or Boolean. Primitive values are auto-boxed.
120     */
121    ChildTopics set(String assocDefUri, Object value);
122
123    /**
124     * Convenience method to set the composite value of a child.
125     */
126    ChildTopics set(String assocDefUri, ChildTopicsModel value);
127
128    // ---
129
130    ChildTopics setRef(String assocDefUri, long refTopicId);
131
132    ChildTopics setRef(String assocDefUri, long refTopicId, ChildTopicsModel relatingAssocChildTopics);
133
134    ChildTopics setRef(String assocDefUri, String refTopicUri);
135
136    ChildTopics setRef(String assocDefUri, String refTopicUri, ChildTopicsModel relatingAssocChildTopics);
137
138    // ---
139
140    ChildTopics setDeletionRef(String assocDefUri, long refTopicId);
141
142    ChildTopics setDeletionRef(String assocDefUri, String refTopicUri);
143
144    // --- Multiple-valued Childs ---
145
146    ChildTopics add(String assocDefUri, TopicModel value);
147
148    // ---
149
150    ChildTopics add(String assocDefUri, Object value);
151
152    ChildTopics add(String assocDefUri, ChildTopicsModel value);
153
154    // ---
155
156    ChildTopics addRef(String assocDefUri, long refTopicId);
157
158    ChildTopics addRef(String assocDefUri, long refTopicId, ChildTopicsModel relatingAssocChildTopics);
159
160    ChildTopics addRef(String assocDefUri, String refTopicUri);
161
162    ChildTopics addRef(String assocDefUri, String refTopicUri, ChildTopicsModel relatingAssocChildTopics);
163
164    // ---
165
166    ChildTopics addDeletionRef(String assocDefUri, long refTopicId);
167
168    ChildTopics addDeletionRef(String assocDefUri, String refTopicUri);
169}