Beispiel #1
0
 protected boolean determineTraitStatus() {
   return typeDecl != null
           // if cls implements an interface and cls is never actually used, typeDecl will
           // reference the interface
           // rather than the actual class, but this may not reflect the actual traitability
           && typeDecl.getTypeClass() == cls
           && (typeDecl.getKind() == TypeDeclaration.Kind.TRAIT
               || typeDecl.getTypeClassDef().isTraitable()
               || typeDecl.getTypeClass().getAnnotation(Traitable.class) != null)
       || Thing.class.isAssignableFrom(cls)
       || cls.getAnnotation(Traitable.class) != null
       || TraitableBean.class.isAssignableFrom(cls);
 }
 protected boolean determineTraitStatus() {
   return typeDecl != null
           && (typeDecl.getKind() == TypeDeclaration.Kind.TRAIT
               || typeDecl.getTypeClassDef().isTraitable()
               || typeDecl.getTypeClass().getAnnotation(Traitable.class) != null)
       || Thing.class.isAssignableFrom(cls)
       || TraitableBean.class.isAssignableFrom(cls);
 }
  /** Merges all the missing FactFields from oldDefinition into newDeclaration. */
  protected void mergeTypeDeclarations(
      TypeDeclaration oldDeclaration, TypeDeclaration newDeclaration) {
    if (oldDeclaration == null) {
      return;
    }

    // add the missing fields (if any) to newDeclaration
    for (FieldDefinition oldFactField : oldDeclaration.getTypeClassDef().getFieldsDefinitions()) {
      FieldDefinition newFactField =
          newDeclaration.getTypeClassDef().getField(oldFactField.getName());
      if (newFactField == null) {
        newDeclaration.getTypeClassDef().addField(oldFactField);
      }
    }

    // copy the defined class
    newDeclaration.setTypeClass(oldDeclaration.getTypeClass());
  }