001package io.ebean.querybean.generator;
002
003/**
004 * Meta data for a property.
005 */
006public class PropertyMeta {
007
008  /**
009   * The property name.
010   */
011  private final String name;
012
013  /**
014   * The property type.
015   */
016  private final PropertyType type;
017
018  /**
019   * Construct given the property name and type.
020   */
021  PropertyMeta(String name, PropertyType type) {
022    this.name = name;
023    this.type = type;
024  }
025
026  String getName() {
027    return name;
028  }
029
030  /**
031   * Return true if this is an associated bean property (OneToMany, ManyToOne etc).
032   */
033  public boolean isAssociation() {
034    return type.isAssociation();
035  }
036
037  /**
038   * Return the type definition given the type short name and flag indicating if it is an associated bean type.
039   */
040  String getTypeDefn(String shortName, boolean assoc) {
041    return type.getTypeDefn(shortName, assoc);
042  }
043
044//  public void writeFieldDefn(Writer writer, String shortName, boolean assoc) throws IOException {
045//
046//    writer.append("  public ");
047//    writer.append(getTypeDefn(shortName, assoc));
048//    writer.append(" ").append(name).append(";");
049//  }
050//
051//  public void writeConstructorSimple(Writer writer, String shortName, boolean assoc) throws IOException {
052//
053//    if (!type.isAssociation()) {
054//      writer.append("    this.").append(name).append(" = new ");
055//      type.writeConstructor(writer, name, assoc);
056//    }
057//  }
058//
059//  public void writeConstructorAssoc(Writer writer, String shortName, boolean assoc) throws IOException {
060//    if (type.isAssociation()) {
061//      if (assoc) {
062//        writer.append("  ");
063//      }
064//      writer.append("    this.").append(name).append(" = new ");
065//      type.writeConstructor(writer, name, assoc);
066//    }
067//  }
068//
069//  public void writeFieldAliasDefn(Writer writer, String shortName) throws IOException {
070//
071//    writer.append("    public static ");
072//    writer.append(getTypeDefn(shortName, false));
073//    writer.append(" ").append(name).append(" = _alias.").append(name).append(";");
074//  }
075}