Exemplo n.º 1
0
 public TypeBinding getTypeBinding(Field field) {
   Class itsType = field.getType();
   if (this.isIgnored(field)) {
     return new NoopTypeBinding(field);
   } else if (List.class.isAssignableFrom(itsType)) {
     Class listType = getTypeArgument(field);
     if (listType == null) {
       Logs.extreme()
           .debug(
               String.format(
                   "IGNORE: %-70s [type=%s] NO GENERIC TYPE FOR LIST\n",
                   field.getDeclaringClass().getCanonicalName() + "." + field.getName(),
                   listType));
       return new NoopTypeBinding(field);
     } else if (this.typeBindings.containsKey(listType.getCanonicalName())) {
       return new CollectionTypeBinding(
           field.getName(), this.typeBindings.get(listType.getCanonicalName()));
     } else if (BindingFileSearch.INSTANCE.MSG_DATA_CLASS.isAssignableFrom(listType)) {
       return new CollectionTypeBinding(
           field.getName(), new ObjectTypeBinding(field.getName(), listType));
     } else {
       Logs.extreme()
           .debug(
               String.format(
                   "IGNORE: %-70s [type=%s] LIST'S GENERIC TYPE DOES NOT CONFORM TO EucalyptusData\n",
                   field.getDeclaringClass().getCanonicalName() + "." + field.getName(),
                   listType.getCanonicalName()));
       return new NoopTypeBinding(field);
     }
   } else if (this.typeBindings.containsKey(itsType.getCanonicalName())) {
     TypeBinding t = this.typeBindings.get(itsType.getCanonicalName());
     try {
       t = this.typeBindings.get(itsType.getCanonicalName()).getClass().newInstance();
     } catch (Exception e) {
     }
     return t.value(field.getName());
   } else if (BindingFileSearch.INSTANCE.MSG_DATA_CLASS.isAssignableFrom(field.getType())) {
     return new ObjectTypeBinding(field);
   } else {
     Logs.extreme()
         .debug(
             String.format(
                 "IGNORE: %-70s [type=%s] TYPE DOES NOT CONFORM TO EucalyptusData\n",
                 field.getDeclaringClass().getCanonicalName() + "." + field.getName(),
                 field.getType().getCanonicalName()));
     return new NoopTypeBinding(field);
   }
 }
Exemplo n.º 2
0
 public String process() {
   if (this.type.getCanonicalName() == null) {
     //          new RuntimeException( "Ignoring anonymous class: " + this.type
     // ).printStackTrace( );
   } else {
     this.elem(Elem.mapping);
     if (this.abs) {
       this.attr("abstract", "true");
     } else {
       this.attr("name", this.type.getSimpleName())
           .attr("extends", this.type.getSuperclass().getCanonicalName());
     }
     this.attr("class", this.type.getCanonicalName());
     if (BindingFileSearch.INSTANCE.MSG_BASE_CLASS.isAssignableFrom(this.type.getSuperclass())
         || BindingFileSearch.INSTANCE.MSG_DATA_CLASS.isAssignableFrom(
             this.type.getSuperclass())) {
       this.elem(Elem.structure)
           .attr("map-as", this.type.getSuperclass().getCanonicalName())
           .end();
     }
     for (Field f : this.type.getDeclaredFields()) {
       if (!Ats.from(f).has(Transient.class) || Modifier.isTransient(f.getModifiers())) {
         TypeBinding tb = getTypeBinding(f);
         if (!(tb instanceof NoopTypeBinding)) {
           //                System.out.printf( "BOUND:  %-70s [type=%s:%s]\n",
           // f.getDeclaringClass( ).getCanonicalName( ) +"."+ f.getName( ), tb.getTypeName( ),
           // f.getType( ).getCanonicalName( ) );
           this.append(tb.toString());
         }
       }
     }
     this.end();
   }
   return this.toString();
 }