001package systems.dmx.core.impl; 002 003import systems.dmx.core.TopicType; 004import systems.dmx.core.model.AssociationDefinitionModel; 005import systems.dmx.core.model.SimpleValue; 006import systems.dmx.core.model.TopicModel; 007import systems.dmx.core.model.TopicTypeModel; 008import systems.dmx.core.model.TypeModel; 009import systems.dmx.core.service.Directive; 010 011import java.util.List; 012 013 014 015/** 016 * Data that underlies a {@link TopicType}. 017 * 018 * @author <a href="mailto:jri@deepamehta.de">Jörg Richter</a> 019 */ 020class TopicTypeModelImpl extends TypeModelImpl implements TopicTypeModel { 021 022 // ---------------------------------------------------------------------------------------------------- Constructors 023 024 TopicTypeModelImpl(TypeModelImpl type) { 025 super(type); 026 } 027 028 // -------------------------------------------------------------------------------------------------- Public Methods 029 030 @Override 031 public TopicTypeModel addAssocDef(AssociationDefinitionModel assocDef) { 032 return (TopicTypeModel) super.addAssocDef(assocDef); 033 } 034 035 // --- 036 037 @Override 038 public TopicTypeModelImpl clone() { 039 try { 040 return (TopicTypeModelImpl) super.clone(); 041 } catch (Exception e) { 042 throw new RuntimeException("Cloning a TopicTypeModel failed", e); 043 } 044 } 045 046 // ----------------------------------------------------------------------------------------- Package Private Methods 047 048 @Override 049 String className() { 050 return "topic type"; 051 } 052 053 @Override 054 TopicTypeImpl instantiate() { 055 // Note: declaration and assignment is required for type inference to work (at least in Java 6) 056 TopicTypeModelImpl type = clone().filterReadableAssocDefs(); 057 return new TopicTypeImpl(type, pl); 058 } 059 060 061 062 // === Implementation of abstract TypeModelImpl methods === 063 064 @Override 065 List<TopicModelImpl> getAllInstances() { 066 return pl.fetchTopics("typeUri", new SimpleValue(uri)); 067 } 068 069 // --- 070 071 @Override 072 Directive getUpdateTypeDirective() { 073 return Directive.UPDATE_TOPIC_TYPE; 074 } 075 076 @Override 077 Directive getDeleteTypeDirective() { 078 return Directive.DELETE_TOPIC_TYPE; 079 } 080}