コード例 #1
0
  @Override
  public List<FieldDeclaration> getFields(EmitContext context, ModelDeclaration model)
      throws IOException {
    if (isTarget(model) == false) {
      return Collections.emptyList();
    }
    CacheSupportTrait trait = model.getTrait(CacheSupportTrait.class);
    assert trait != null;

    List<FieldDeclaration> results = Lists.create();
    if (trait.getDeleteFlagValue() != null) {
      results.add(createDeleteFlagValueField(context, model, trait.getDeleteFlagValue()));
    }
    return results;
  }
コード例 #2
0
  @Override
  public List<MethodDeclaration> getMethods(EmitContext context, ModelDeclaration model)
      throws IOException {
    if (isTarget(model) == false) {
      return Collections.emptyList();
    }
    CacheSupportTrait trait = model.getTrait(CacheSupportTrait.class);
    assert trait != null;

    List<MethodDeclaration> results = Lists.create();
    results.add(createModelVersionMethod(context, model, trait));
    results.add(createTimestampColumnMethod(context, model, trait.getTimestamp()));
    results.add(createSystemIdMethod(context, model, trait.getSid()));
    results.add(createDeletedMethod(context, model, trait.getDeleteFlag()));
    return results;
  }
コード例 #3
0
 private long computeModelVersion(
     EmitContext context, ModelDeclaration model, CacheSupportTrait trait) {
   assert context != null;
   assert model != null;
   assert trait != null;
   long hash = 1;
   final long prime = 31;
   hash = hash * prime + context.getQualifiedTypeName().toNameString().hashCode();
   hash = hash * prime + trait.getSid().getName().identifier.hashCode();
   hash = hash * prime + trait.getTimestamp().getName().identifier.hashCode();
   for (PropertyDeclaration property : model.getDeclaredProperties()) {
     hash = hash * prime + property.getName().identifier.hashCode();
     com.asakusafw.dmdl.semantics.Type type = property.getType();
     assert type instanceof BasicType;
     hash = hash * prime + ((BasicType) type).getKind().name().hashCode();
   }
   return hash;
 }