001 package de.deepamehta.core; 002 003 import de.deepamehta.core.model.ChildTopicsModel; 004 import de.deepamehta.core.model.SimpleValue; 005 import de.deepamehta.core.model.TopicModel; 006 007 import java.util.List; 008 009 010 011 public interface ChildTopics { 012 013 014 015 // === Accessors === 016 017 /** 018 * Accesses a single-valued child. 019 * Throws if there is no such child. 020 */ 021 Topic getTopic(String childTypeUri); 022 023 /** 024 * Accesses a multiple-valued child. 025 * Throws if there is no such child. 026 */ 027 List<Topic> getTopics(String childTypeUri); 028 029 // --- 030 031 Object get(String childTypeUri); 032 033 boolean has(String childTypeUri); 034 035 Iterable<String> childTypeUris(); 036 037 int size(); 038 039 // --- 040 041 ChildTopicsModel getModel(); 042 043 044 045 // === Convenience Accessors === 046 047 /** 048 * Convenience accessor for the *simple* value of a single-valued child. 049 * Throws if the child doesn't exist. 050 */ 051 String getString(String childTypeUri); 052 053 /** 054 * Convenience accessor for the *simple* value of a single-valued child. 055 * Throws if the child doesn't exist. 056 */ 057 int getInt(String childTypeUri); 058 059 /** 060 * Convenience accessor for the *simple* value of a single-valued child. 061 * Throws if the child doesn't exist. 062 */ 063 long getLong(String childTypeUri); 064 065 /** 066 * Convenience accessor for the *simple* value of a single-valued child. 067 * Throws if the child doesn't exist. 068 */ 069 double getDouble(String childTypeUri); 070 071 /** 072 * Convenience accessor for the *simple* value of a single-valued child. 073 * Throws if the child doesn't exist. 074 */ 075 boolean getBoolean(String childTypeUri); 076 077 /** 078 * Convenience accessor for the *simple* value of a single-valued child. 079 * Throws if the child doesn't exist. 080 */ 081 Object getObject(String childTypeUri); 082 083 // --- 084 085 /** 086 * Convenience accessor for the *composite* value of a single-valued child. 087 * Throws if the child doesn't exist. 088 */ 089 ChildTopics getChildTopics(String childTypeUri); 090 091 // Note: there are no convenience accessors for a multiple-valued child. 092 093 094 095 // === Manipulators === 096 097 /** 098 * Sets a child. 099 * Works for both, single-valued child and multiple-valued child (cardinality "many"). 100 */ 101 ChildTopics set(String childTypeUri, TopicModel value); 102 103 /** 104 * Convenience method to set the simple value of a child. 105 * Works for both, single-valued child and multiple-valued child (cardinality "many"). 106 * 107 * @param value The simple value. 108 * Either String, Integer, Long, Double, or Boolean. Primitive values are auto-boxed. 109 */ 110 ChildTopics set(String childTypeUri, Object value); 111 112 /** 113 * Convenience method to set the composite value of a child. 114 * Works for both, single-valued child and multiple-valued child (cardinality "many"). 115 */ 116 ChildTopics set(String childTypeUri, ChildTopicsModel value); 117 118 // --- 119 120 ChildTopics setRef(String childTypeUri, long refTopicId); 121 122 ChildTopics setRef(String childTypeUri, String refTopicUri); 123 124 // --- 125 126 ChildTopics remove(String childTypeUri, long topicId); 127 }