/** * Returns the corresponded DMDL model definition. * * @param model the thundergate model * @param extra extra attributes * @return the converted model * @throws IllegalArgumentException if some parameters were {@code null} * @since 0.2.3 */ public static AstModelDefinition<AstRecord> generate( TableModelDescription model, AstAttribute... extra) { if (model == null) { throw new IllegalArgumentException("model must not be null"); // $NON-NLS-1$ } if (extra == null) { throw new IllegalArgumentException("extra must not be null"); // $NON-NLS-1$ } List<AstAttribute> attrs = Lists.create(); attrs.add(AstBuilder.getAutoProjection()); attrs.add(AstBuilder.getNamespace(AstBuilder.toDmdlName(Constants.SOURCE_TABLE))); attrs.add(AstBuilder.getOriginalName(model.getReference().getSimpleName())); attrs.add(AstBuilder.getPrimaryKey(model)); Collections.addAll(attrs, extra); return new AstModelDefinition<>( null, ModelDefinitionKind.RECORD, AstBuilder.getDesciption("テーブル{0}", model.getReference().getSimpleName()), attrs, AstBuilder.toName(model.getReference()), new RecordModelGenerator(model).generateExpression()); }