Package org.jboss.metatype.api.values

Examples of org.jboss.metatype.api.values.GenericValueSupport


         // Look for a ManagementObjectRef
         ManagementObjectRef ref = (ManagementObjectRef) property.getAnnotations().get(ManagementObjectRef.class.getName());
         String moName = (ref != null ? ref.name() : value.getClass().getName());
         String moNameType = (ref != null ? ref.type() : "");
         ManagedObject mo = initManagedObject((Serializable) value, moName, moNameType);
         return new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo);
      }
      else if (propertyType.isArray())
      {
         ArrayMetaType arrayType = ArrayMetaType.class.cast(propertyType);
         if (MANAGED_OBJECT_META_TYPE == arrayType.getElementType())
         {
            Collection<?> cvalue = getAsCollection(value);
            // todo - AJ: changed some generics by best guess
            ArrayMetaType moType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE);
            ArrayValueSupport moArrayValue = new ArrayValueSupport(moType);
            List<GenericValueSupport> tmp = new ArrayList<GenericValueSupport>();
            for(Object element : cvalue)
            {
               ManagedObject mo = initManagedObject((Serializable) element, null, null);
               tmp.add(new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo));
            }
            GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
            moArrayValue.setValue(tmp.toArray(mos));
            return moArrayValue;
         }
      }
      else if (propertyType.isCollection())
      {
         CollectionMetaType collectionType = CollectionMetaType.class.cast(propertyType);
         if (MANAGED_OBJECT_META_TYPE == collectionType.getElementType())
         {
            Collection<?> cvalue = getAsCollection(value);
            List<GenericValueSupport> tmp = new ArrayList<GenericValueSupport>();
            for(Object element : cvalue)
            {
               ManagedObject mo = initManagedObject((Serializable) element, null, null);
               tmp.add(new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo));
            }
            GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
            CollectionMetaType moType = new CollectionMetaType(propertyType.getClassName(), MANAGED_OBJECT_META_TYPE);
            return new CollectionValueSupport(moType, tmp.toArray(mos));
         }
View Full Code Here


/*     */       }
/* 714 */       ManagementObjectRef ref = (ManagementObjectRef)property.getAnnotations().get(ManagementObjectRef.class.getName());
/* 715 */       String moName = ref != null ? ref.name() : value.getClass().getName();
/* 716 */       String moNameType = ref != null ? ref.type() : "";
/* 717 */       ManagedObject mo = initManagedObject((Serializable)value, moName, moNameType);
/* 718 */       return new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo);
/*     */     }
/* 720 */     if (propertyType.isArray())
/*     */     {
/* 722 */       ArrayMetaType arrayType = (ArrayMetaType)ArrayMetaType.class.cast(propertyType);
/* 723 */       if (MANAGED_OBJECT_META_TYPE == arrayType.getElementType())
/*     */       {
/* 725 */         Collection cvalue = getAsCollection(value);
/*     */
/* 727 */         ArrayMetaType moType = new ArrayMetaType(1, MANAGED_OBJECT_META_TYPE);
/* 728 */         ArrayValueSupport moArrayValue = new ArrayValueSupport(moType);
/* 729 */         List tmp = new ArrayList();
/* 730 */         for (Iterator i$ = cvalue.iterator(); i$.hasNext(); ) { Object element = i$.next();
/*     */
/* 732 */           ManagedObject mo = initManagedObject((Serializable)element, null, null);
/* 733 */           tmp.add(new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo));
/*     */         }
/* 735 */         GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
/* 736 */         moArrayValue.setValue(tmp.toArray(mos));
/* 737 */         return moArrayValue;
/*     */       }
/*     */     }
/* 740 */     else if (propertyType.isCollection())
/*     */     {
/* 742 */       CollectionMetaType collectionType = (CollectionMetaType)CollectionMetaType.class.cast(propertyType);
/* 743 */       if (MANAGED_OBJECT_META_TYPE == collectionType.getElementType())
/*     */       {
/* 745 */         Collection cvalue = getAsCollection(value);
/* 746 */         List tmp = new ArrayList();
/* 747 */         for (Iterator i$ = cvalue.iterator(); i$.hasNext(); ) { Object element = i$.next();
/*     */
/* 749 */           ManagedObject mo = initManagedObject((Serializable)element, null, null);
/* 750 */           tmp.add(new GenericValueSupport(MANAGED_OBJECT_META_TYPE, mo));
/*     */         }
/* 752 */         GenericValueSupport[] mos = new GenericValueSupport[tmp.size()];
/* 753 */         CollectionMetaType moType = new CollectionMetaType(propertyType.getClassName(), MANAGED_OBJECT_META_TYPE);
/* 754 */         return new CollectionValueSupport(moType, (MetaValue[])tmp.toArray(mos));
/*     */       }
View Full Code Here

/*  197 */       return null;
/*      */     }
/*  199 */     if (!(value instanceof Serializable)) {
/*  200 */       throw new IllegalArgumentException("Not serializable: " + value.getClass().getName());
/*      */     }
/*  202 */     GenericValue result = new GenericValueSupport(type, (Serializable)value);
/*  203 */     mapping.put(value, result);
/*  204 */     return result;
/*      */   }
View Full Code Here

         return null;
     
      if (value instanceof Serializable == false)
         throw new IllegalArgumentException("Not serializable: " + value.getClass().getName());

      GenericValue result = new GenericValueSupport(type, (Serializable) value);
      mapping.put(value, result);
      return result;
   }
View Full Code Here

TOP

Related Classes of org.jboss.metatype.api.values.GenericValueSupport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.