private FieldDeclaration createDeleteFlagValueField( EmitContext context, ModelDeclaration model, AstLiteral deleteFlagValue) { assert context != null; assert model != null; assert deleteFlagValue != null; ModelFactory f = context.getModelFactory(); Type type; Expression value; switch (deleteFlagValue.kind) { case BOOLEAN: type = context.resolve(boolean.class); value = Models.toLiteral(f, deleteFlagValue.toBooleanValue()); break; case INTEGER: type = context.resolve(int.class); value = Models.toLiteral(f, deleteFlagValue.toIntegerValue().intValue()); break; case STRING: type = context.resolve(Text.class); value = new TypeBuilder(f, context.resolve(Text.class)) .newObject(Models.toLiteral(f, deleteFlagValue.toStringValue())) .toExpression(); break; default: throw new AssertionError(deleteFlagValue); } return f.newFieldDeclaration( null, new AttributeBuilder(f).Private().Static().Final().toAttributes(), type, f.newSimpleName(FIELD_DELETE_FLAG_VALUE), value); }
private Generator(EmitContext context, ModelDeclaration model) { assert context != null; assert model != null; this.context = context; this.model = model; this.f = context.getModelFactory(); }
@Override public List<Annotation> getTypeAnnotations(EmitContext context, ModelDeclaration model) throws IOException { Type type = generate(context, model); ModelFactory f = context.getModelFactory(); return new AttributeBuilder(f) .annotation( context.resolve(ModelInputLocation.class), f.newClassLiteral(context.resolve(type))) .toAnnotations(); }
private SupportGenerator( EmitContext context, ModelDeclaration model, Configuration configuration) { assert context != null; assert model != null; assert configuration != null; this.context = context; this.model = model; this.conf = configuration; this.f = context.getModelFactory(); }
private DescriptionGenerator( EmitContext context, ModelDeclaration model, Name supportClassName, boolean importer) { assert context != null; assert model != null; assert supportClassName != null; this.context = context; this.model = model; this.f = context.getModelFactory(); this.importer = importer; this.supportClass = context.resolve(supportClassName); }
private MethodDeclaration createTimestampColumnMethod( EmitContext context, ModelDeclaration model, PropertySymbol timestamp) { assert context != null; assert model != null; assert timestamp != null; ModelFactory f = context.getModelFactory(); String name = OriginalNameEmitter.getOriginalName(timestamp.findDeclaration()); List<Statement> statements = Lists.create(); statements.add(new ExpressionBuilder(f, Models.toLiteral(f, name)).toReturnStatement()); return f.newMethodDeclaration( null, new AttributeBuilder(f).annotation(context.resolve(Override.class)).Public().toAttributes(), context.resolve(String.class), f.newSimpleName("__tgc__TimestampColumn"), Collections.<FormalParameterDeclaration>emptyList(), statements); }
private MethodDeclaration createModelVersionMethod( EmitContext context, ModelDeclaration model, CacheSupportTrait trait) { assert context != null; assert model != null; assert trait != null; ModelFactory f = context.getModelFactory(); List<Statement> statements = Lists.create(); statements.add( new ExpressionBuilder(f, Models.toLiteral(f, computeModelVersion(context, model, trait))) .toReturnStatement()); return f.newMethodDeclaration( null, new AttributeBuilder(f).annotation(context.resolve(Override.class)).Public().toAttributes(), context.resolve(long.class), f.newSimpleName("__tgc__DataModelVersion"), Collections.<FormalParameterDeclaration>emptyList(), statements); }
private MethodDeclaration createSystemIdMethod( EmitContext context, ModelDeclaration model, PropertySymbol sid) { assert context != null; assert model != null; assert sid != null; ModelFactory f = context.getModelFactory(); List<Statement> statements = Lists.create(); statements.add( new ExpressionBuilder(f, f.newThis()) .method(context.getValueGetterName(sid.findDeclaration())) .toReturnStatement()); return f.newMethodDeclaration( null, new AttributeBuilder(f).annotation(context.resolve(Override.class)).Public().toAttributes(), context.resolve(long.class), f.newSimpleName("__tgc__SystemId"), Collections.<FormalParameterDeclaration>emptyList(), statements); }
private MethodDeclaration createDeletedMethod( EmitContext context, ModelDeclaration model, PropertySymbol deleteFlagOrNull) { assert context != null; assert model != null; ModelFactory f = context.getModelFactory(); List<Statement> statements = Lists.create(); if (deleteFlagOrNull == null) { statements.add(new ExpressionBuilder(f, Models.toLiteral(f, false)).toReturnStatement()); } else { statements.add( new ExpressionBuilder(f, f.newThis()) .method(context.getOptionGetterName(deleteFlagOrNull.findDeclaration())) .method("has", f.newSimpleName(FIELD_DELETE_FLAG_VALUE)) .toReturnStatement()); } return f.newMethodDeclaration( null, new AttributeBuilder(f).annotation(context.resolve(Override.class)).Public().toAttributes(), context.resolve(boolean.class), f.newSimpleName("__tgc__Deleted"), Collections.<FormalParameterDeclaration>emptyList(), statements); }