@@ -87,73 +87,61 @@ class IndentWriter
8787end
8888
8989class Attribute
90- attr_reader :name , :entity , :type
9190 def initialize ( name , entity : nil , type : nil )
9291 @name = name
9392 @entity = entity
9493 @type = type
9594 end
96- def render_property ( io )
97- if attribute_class =~ /^Numeric/
98- io . puts "#{ $options. access_modifier } private(set) lazy var #{ @name } : #{ attribute_class } = { #{ attribute_class } (\" #{ @name } \" , parent: self, type: #{ attribute_type } ) }()"
99- else
100- io . puts "#{ $options. access_modifier } private(set) lazy var #{ @name } : #{ attribute_class } = { #{ attribute_class } (\" #{ @name } \" , parent: self) }()"
101- end
102- end
103- def attribute_type
104- case @type
105- when 'Binary' then '.BinaryDataAttributeType'
106- when 'Boolean' then '.BooleanAttributeType'
107- when 'Date' then '.DateAttributeType'
108- when 'Decimal' then '.DecimalAttributeType'
109- when 'Double' then '.DoubleAttributeType'
110- when 'Float' then '.FloatAttributeType'
111- when 'Integer 16' then '.Integer16AttributeType'
112- when 'Integer 32' then '.Integer32AttributeType'
113- when 'Integer 64' then '.Integer64AttributeType'
114- when 'String' then '.StringAttributeType'
115- else 'nil'
116- end
117- end
118- def attribute_class
119- prefix = ""
120- unless @type . nil?
121- type_downcased = @type . downcase
122- if [ "integer" , "float" , "double" , "decimal" ] . any? { |type | type_downcased . include? type }
123- prefix = "Numeric"
124- elsif type_downcased == "binary"
125- prefix = "Data"
95+
96+ def attribute_class_name
97+ prefix = ''
98+ if @type
99+ case @type
100+ when 'Binary' then 'DateAttribute'
101+ when 'Boolean' then 'BooleanAttribute'
102+ when 'Date' then 'DateAttribute'
103+ when 'Decimal' then 'DecimalAttribute'
104+ when 'Double' then 'DoubleAttribute'
105+ when 'Float' then 'FloatAttribute'
106+ when 'Integer 16' then 'Integer16Attribute'
107+ when 'Integer 32' then 'Integer32Attribute'
108+ when 'Integer 64' then 'Integer64Attribute'
109+ when 'String' then 'StringAttribute'
126110 else
127- prefix = @type
111+ raise @type
128112 end
129113 else
130- prefix = "#{ @entity || 'Key' } "
114+ "#{ @entity } #{ $options . suffix } "
131115 end
132- "#{ prefix } #{ $options. suffix } "
116+ end
117+
118+ def render ( io )
119+ io . puts "#{ $options. access_modifier } private(set) lazy var #{ @name } : #{ attribute_class_name } = { #{ attribute_class_name } (key: \" #{ @name } \" , parent: self) }()"
133120 end
134121end
135122
136123class Entity
137- attr_reader :name
124+ attr_reader :name , :entity_class_name
138125 def initialize ( name )
139126 @name = name
140127 @attributes = [ ]
128+ @entity_class_name = "#{ @name } #{ $options. suffix } "
141129 end
142130 def <<( attribute )
143131 @attributes << attribute
144132 end
145133 def render ( io )
146- io . puts "#{ $options. access_modifier } class #{ @name } #{ $options . suffix } : EntityAttribute, Aggregable {"
134+ io . puts "#{ $options. access_modifier } final class #{ @entity_class_name } : EntityAttribute, Subqueryable {"
147135 io . indent do
148136 @attributes . each do |attribute |
149- attribute . render_property ( io )
137+ attribute . render ( io )
150138 end
151139 end
152140 io . puts "}"
153141 io . puts ""
154- io . puts "extension #{ @name } : EntityType {"
142+ io . puts "extension #{ @name } : Entity {"
155143 io . indent do
156- io . puts "#{ $options. access_modifier } typealias EntityAttributeType = #{ @name } #{ $options . suffix } "
144+ io . puts "#{ $options. access_modifier } typealias CDQIAttribute = #{ @entity_class_name } "
157145 end
158146 io . puts "}"
159147 io . puts ""
0 commit comments