Exemplo n.º 1
0
  private void applyColumnValues(AnnotationInstance columnAnnotation) {
    // if the column annotation is null we don't have to do anything. Everything is already
    // defaulted.
    if (columnAnnotation == null) {
      return;
    }

    AnnotationValue nameValue = columnAnnotation.value("name");
    if (nameValue != null) {
      this.name = nameValue.asString();
    }

    AnnotationValue uniqueValue = columnAnnotation.value("unique");
    if (uniqueValue != null) {
      this.unique = nameValue.asBoolean();
    }

    AnnotationValue nullableValue = columnAnnotation.value("nullable");
    if (nullableValue != null) {
      this.nullable = nullableValue.asBoolean();
    }

    AnnotationValue insertableValue = columnAnnotation.value("insertable");
    if (insertableValue != null) {
      this.insertable = insertableValue.asBoolean();
    }

    AnnotationValue updatableValue = columnAnnotation.value("updatable");
    if (updatableValue != null) {
      this.updatable = updatableValue.asBoolean();
    }

    AnnotationValue columnDefinition = columnAnnotation.value("columnDefinition");
    if (columnDefinition != null) {
      this.columnDefinition = columnDefinition.asString();
    }

    AnnotationValue tableValue = columnAnnotation.value("table");
    if (tableValue != null) {
      this.table = tableValue.asString();
    }

    AnnotationValue lengthValue = columnAnnotation.value("length");
    if (lengthValue != null) {
      this.length = lengthValue.asInt();
    }

    AnnotationValue precisionValue = columnAnnotation.value("precision");
    if (precisionValue != null) {
      this.precision = precisionValue.asInt();
    }

    AnnotationValue scaleValue = columnAnnotation.value("scale");
    if (scaleValue != null) {
      this.scale = scaleValue.asInt();
    }
  }
Exemplo n.º 2
0
  private static Set<ModuleDependencyInfo> getDependencies(
      AnnotationValue dependencies, String module, String version, Overrides overrides) {
    AnnotationInstance[] deps = dependencies.asNestedArray();
    Set<ModuleDependencyInfo> result = new HashSet<ModuleDependencyInfo>(deps.length);
    for (AnnotationInstance dep : deps) {
      AnnotationValue depName = dep.value("name");
      AnnotationValue depVersion = dep.value("version");
      AnnotationValue export = dep.value("export");
      AnnotationValue optional = dep.value("optional");

      result.add(
          new ModuleDependencyInfo(
              depName.asString(),
              depVersion.asString(),
              (optional != null) && optional.asBoolean(),
              (export != null) && export.asBoolean()));
    }
    if (overrides != null)
      return overrides
          .applyOverrides(module, version, new ModuleInfo(null, result))
          .getDependencies();
    return result;
  }
Exemplo n.º 3
0
 private static boolean asBoolean(AnnotationInstance ai, String name) {
   final AnnotationValue av = ai.value(name);
   return (av != null) && av.asBoolean();
 }