public SDDocumentType addType(SDDocumentType dt) {
        NewDocumentType.Name name = new NewDocumentType.Name(dt.getName());
        if (getType(name) != null)
            throw new IllegalArgumentException("Data type '" + name + "' has already been used.");
        if (name.getName().equals(docType.getName()))
            throw new IllegalArgumentException("Data type '" + name + "' can not have same name as its defining document.");
        ownedTypes.put(name, dt);
        return this;
    }
For adding structs defined in document scope

@param dt the struct to add
@return self, for chaining
config-model/src/main/java/com/yahoo/schema/document/SDDocumentType.java