Package org.jboss.metatype.api.values

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


      MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestAnnotation.class.getName(), TestAnnotation.class.getName());
      compositeType.addItem("something", "something", SimpleMetaType.STRING);
      compositeType.freeze();

      String[] compositeNames = { "something" };
      CompositeValue expected = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") });
     
      TestAnnotation annotation = getClass().getAnnotation(TestAnnotation.class);
      MetaValue result = createMetaValue(annotation);
      CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
      getLog().debug("Annotation Value: " + actual);
View Full Code Here


      MutableCompositeMetaType compositeType = new MutableCompositeMetaType(TestSimpleComposite.class.getName(), TestSimpleComposite.class.getName());
      compositeType.addItem("something", "something", SimpleMetaType.STRING);
      compositeType.freeze();

      String[] compositeNames = { "something" };
      CompositeValue expected = new CompositeValueSupport(compositeType, compositeNames, new MetaValue[] { SimpleValueSupport.wrap("Hello") });
     
      MetaValue result = createMetaValue(new TestSimpleComposite("Hello"));
      CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
      getLog().debug("Composite Value: " + actual);
      assertEquals(expected, actual);
View Full Code Here

      compositeType.addItem("other", "other", compositeType);
      Set<String> keys = Collections.singleton("id");
      compositeType.setKeys(keys);
      compositeType.freeze();

      CompositeValueSupport expected = new CompositeValueSupport(compositeType);
      expected.set("id", SimpleValueSupport.wrap("Hello"));
      expected.set("other", expected);
     
      TestRecursiveComposite object = new TestRecursiveComposite("Hello");
      object.setOther(object);
      MetaValue result = createMetaValue(object);
      CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
View Full Code Here

      compositeType.addItem("id", "id", SimpleMetaType.STRING);
      Set<String> keys = Collections.singleton("id");
      compositeType.setKeys(keys);
      compositeType.freeze();

      CompositeValueSupport expected = new CompositeValueSupport(compositeType);
      expected.set("id", SimpleValueSupport.wrap("Hello"));
     
      TestIgnoredCompositeItem object = new TestIgnoredCompositeItem();
      object.setId("Hello");
      object.setIgnored("Ignored?");
      MetaValue result = createMetaValue(object);
View Full Code Here

      compositeType.addItem("renamed", "renamed", SimpleMetaType.STRING);
      Set<String> keys = Collections.singleton("id");
      compositeType.setKeys(keys);
      compositeType.freeze();

      CompositeValueSupport expected = new CompositeValueSupport(compositeType);
      expected.set("id", SimpleValueSupport.wrap("Hello"));
      expected.set("renamed", SimpleValueSupport.wrap("Renamed"));
     
      TestRenamedCompositeItem object = new TestRenamedCompositeItem();
      object.setId("Hello");
      object.setValue("Renamed");
      MetaValue result = createMetaValue(object);
View Full Code Here

         }
         mapping.put(value, result);
         return result;
      }

      CompositeValueSupport result = new CompositeValueSupport(type);
      mapping.put(value, result);

      BeanInfo beanInfo;
      try
      {
         ClassLoader cl = value.getClass().getClassLoader();
         if (cl == null)
            beanInfo = configuration.getBeanInfo(value.getClass());
         else
            beanInfo = configuration.getBeanInfo(type.getTypeName(), cl);
      }
      catch (Exception e)
      {
         throw new RuntimeException("Error retrieving BeanInfo for " + type, e);
      }

      for (String name : type.itemSet())
      {
         MetaType itemType = type.getType(name);
         Object itemValue = null;
         try
         {
            PropertyInfo property = beanInfo.getProperty(name);
            if (property.isReadable())
               itemValue = beanInfo.getProperty(value, name);
         }
         catch (RuntimeException e)
         {
            throw e;
         }
         catch (Error e)
         {
            throw e;
         }
         catch (Throwable t)
         {
            throw new RuntimeException("Error getting property: " + name + " for " + value.getClass(), t);
         }

         MetaValue item = internalCreate(itemValue, null, itemType);
         result.set(name, item);
      }
     
      return result;
   }
View Full Code Here

      for (Iterator<Map.Entry> i = value.entrySet().iterator(); i.hasNext();)
      {
         Map.Entry entry = i.next();
         MetaValue key = internalCreate(entry.getKey(), null, keyType);
         MetaValue val = internalCreate(entry.getValue(), null, valType);
         CompositeValueSupport data = new CompositeValueSupport(entryType, DefaultMetaTypeFactory.MAP_ITEM_NAMES, new MetaValue[] { key, val });
         table.put(data);
      }

      return table;
   }
View Full Code Here

      {
         Object value = object.getKeyProperty((String)key);
         keyValues.put(key, value);
      }
      MetaValue[] itemValues = {SimpleValueSupport.wrap(object.getDomain()), keyValues};
      CompositeValueSupport mv = new CompositeValueSupport(ObjectNameTypeBuilder.META_TYPE,
            itemNames, itemValues);
      return mv;
   }
View Full Code Here

   public void testClass() throws Exception
   {
      CompositeMetaType metaType = assertInstanceOf(resolve(Class.class), CompositeMetaType.class);
      String[] itemNames = { "name" };
      MetaValue[] itemValues = { SimpleValueSupport.wrap(Class.class.getName()) };
      CompositeValue expected = new CompositeValueSupport(metaType, itemNames, itemValues);
     
      MetaValue result = createMetaValue(Class.class);
      CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
      getLog().debug("Class.class: " + actual);
      assertEquals(expected, actual);
View Full Code Here

    * @throws Exception for any problem
    */
   public void testObject() throws Exception
   {
      CompositeMetaType metaType = assertInstanceOf(resolve(Object.class), CompositeMetaType.class);
      CompositeValue expected = new CompositeValueSupport(metaType, new String[0], new MetaValue[0]);
     
      MetaValue result = createMetaValue(new Object());
      CompositeValue actual = assertInstanceOf(result, CompositeValue.class);
      getLog().debug("new Object(): " + actual);
      assertEquals(expected, actual);
View Full Code Here

TOP

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

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.