protected String toString(String type) {

        StringBuilder definitionBuilder = new StringBuilder();
        if (annotations != null && annotations.size() > 0) {
            for (Annotation annotation : annotations) {
                definitionBuilder.append(annotation.toString());
            }
        }
        definitionBuilder.append("define ").append(type).append(" ").append(id).append(" (");
        boolean isFirst = true;
        for (Attribute attribute : attributeList) {
            if (!isFirst) {
                definitionBuilder.append(", ");
            } else {
                isFirst = false;
            }
            definitionBuilder.append(attribute.getName()).append(" ").
                    append(attribute.getType().toString().toLowerCase(Locale.getDefault()));
        }
        definitionBuilder.append(")");
        return definitionBuilder.toString();
    }
Abstract definition used for Streams, Tables and other common artifacts
modules/siddhi-query-api/src/main/java/io/siddhi/query/api/definition/AbstractDefinition.java