001package de.deepamehta.core; 002 003import de.deepamehta.core.model.ChildTopicsModel; 004import de.deepamehta.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 childTypeUri); 021 022 /** 023 * Accesses a multiple-valued child. 024 * Throws if there is no such child. 025 */ 026 List<RelatedTopic> getTopics(String childTypeUri); 027 028 // --- 029 030 Object get(String childTypeUri); 031 032 boolean has(String childTypeUri); 033 034 int size(); 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 childTypeUri); 049 050 /** 051 * Convenience accessor for the *simple* value of a single-valued child. 052 * Throws if the child doesn't exist. 053 */ 054 int getInt(String childTypeUri); 055 056 /** 057 * Convenience accessor for the *simple* value of a single-valued child. 058 * Throws if the child doesn't exist. 059 */ 060 long getLong(String childTypeUri); 061 062 /** 063 * Convenience accessor for the *simple* value of a single-valued child. 064 * Throws if the child doesn't exist. 065 */ 066 double getDouble(String childTypeUri); 067 068 /** 069 * Convenience accessor for the *simple* value of a single-valued child. 070 * Throws if the child doesn't exist. 071 */ 072 boolean getBoolean(String childTypeUri); 073 074 /** 075 * Convenience accessor for the *simple* value of a single-valued child. 076 * Throws if the child doesn't exist. 077 */ 078 Object getObject(String childTypeUri); 079 080 // --- 081 082 /** 083 * Convenience accessor for the *composite* value of a single-valued child. 084 * Throws if the child doesn't exist. 085 */ 086 ChildTopics getChildTopics(String childTypeUri); 087 088 // Note: there are no convenience accessors for a multiple-valued child. 089 090 091 092 // === Manipulators === 093 094 // --- Single-valued Childs --- 095 096 /** 097 * Sets a child. 098 */ 099 ChildTopics set(String childTypeUri, TopicModel value); 100 101 // --- 102 103 /** 104 * Convenience method to set the simple value of a child. 105 * 106 * @param value The simple value. 107 * Either String, Integer, Long, Double, or Boolean. Primitive values are auto-boxed. 108 */ 109 ChildTopics set(String childTypeUri, Object value); 110 111 /** 112 * Convenience method to set the composite value of a child. 113 */ 114 ChildTopics set(String childTypeUri, ChildTopicsModel value); 115 116 // --- 117 118 ChildTopics setRef(String childTypeUri, long refTopicId); 119 120 ChildTopics setRef(String childTypeUri, long refTopicId, ChildTopicsModel relatingAssocChildTopics); 121 122 ChildTopics setRef(String childTypeUri, String refTopicUri); 123 124 ChildTopics setRef(String childTypeUri, String refTopicUri, ChildTopicsModel relatingAssocChildTopics); 125 126 // --- 127 128 ChildTopics setDeletionRef(String childTypeUri, long refTopicId); 129 130 ChildTopics setDeletionRef(String childTypeUri, String refTopicUri); 131 132 // --- Multiple-valued Childs --- 133 134 ChildTopics add(String childTypeUri, TopicModel value); 135 136 // --- 137 138 ChildTopics add(String childTypeUri, Object value); 139 140 ChildTopics add(String childTypeUri, ChildTopicsModel value); 141 142 // --- 143 144 ChildTopics addRef(String childTypeUri, long refTopicId); 145 146 ChildTopics addRef(String childTypeUri, long refTopicId, ChildTopicsModel relatingAssocChildTopics); 147 148 ChildTopics addRef(String childTypeUri, String refTopicUri); 149 150 ChildTopics addRef(String childTypeUri, String refTopicUri, ChildTopicsModel relatingAssocChildTopics); 151 152 // --- 153 154 ChildTopics addDeletionRef(String childTypeUri, long refTopicId); 155 156 ChildTopics addDeletionRef(String childTypeUri, String refTopicUri); 157}