Examples of Immutable


Examples of br.com.six2six.fixturefactory.model.Immutable

    FixtureFactoryLoader.loadTemplates("br.com.six2six.template");
  }
 
  @Test
  public void shouldCreateImmutableObjectUsingCorrectPartialConstructor() {
    Immutable result = Fixture.from(Immutable.class).gimme("twoParameterConstructor");
   
    assertNotNull(result.getPropertyA());
    assertNotNull(result.getPropertyB());
    assertEquals("default", result.getPropertyC());
    assertNotNull(result.getImmutableInner().getPropertyD());
    assertNull(result.getDate());
    assertNull(result.getAddress());
  }
View Full Code Here

Examples of br.com.six2six.fixturefactory.model.Immutable

    assertNull(result.getAddress());
  }

  @Test
  public void shouldCreateImmutableObjectUsingAnotherPartialConstructor() {
    Immutable result = Fixture.from(Immutable.class).gimme("threeParameterConstructor");
   
    assertEquals("default", result.getPropertyA());
    assertNotNull(result.getPropertyB());
    assertNotNull(result.getPropertyC());
    assertNotNull(result.getImmutableInner().getPropertyD());
    assertNull(result.getDate());
    assertNotNull(result.getAddress());
  }
View Full Code Here

Examples of br.com.six2six.fixturefactory.model.Immutable

    assertNotNull(result.getAddress());
  }
 
  @Test
  public void shouldCreateImmutableObjectUsingFullConstructor() {
    Immutable result = Fixture.from(Immutable.class).gimme("fullConstructor");
   
    assertNotNull(result.getPropertyA());
    assertNotNull(result.getPropertyB());
    assertEquals(result.getPropertyA() + " based", result.getPropertyC());
    assertNotNull(result.getDate());
    assertNotNull(result.getAddress());
  }
View Full Code Here

Examples of groovy.transform.Immutable

        throw new RuntimeException(createErrorMessage(className, fieldName, typeName, "constructing"));
    }

    @SuppressWarnings("Unchecked")
    public static Object checkImmutable(Class<?> clazz, String fieldName, Object field) {
        Immutable immutable = (Immutable) clazz.getAnnotation(MY_CLASS);
        List<Class> knownImmutableClasses = new ArrayList<Class>();
        if (immutable != null && immutable.knownImmutableClasses().length > 0) {
            knownImmutableClasses = Arrays.asList(immutable.knownImmutableClasses());
        }

        if (field == null || field instanceof Enum || inImmutableList(field.getClass().getName()) || knownImmutableClasses.contains(field.getClass()))
            return field;
        if (field.getClass().getAnnotation(MY_CLASS) != null) return field;
View Full Code Here

Examples of org.apache.isis.applib.annotation.Immutable

        super(FeatureType.EVERYTHING_BUT_PARAMETERS);
    }

    @Override
    public void process(final ProcessClassContext processClassContaxt) {
        final Immutable annotation = Annotations.getAnnotation(processClassContaxt.getCls(), Immutable.class);
        FacetUtil.addFacet(create(annotation, processClassContaxt.getFacetHolder()));
    }
View Full Code Here

Examples of org.apache.isis.applib.annotation.Immutable

        super(FeatureType.EVERYTHING_BUT_PARAMETERS);
    }

    @Override
    public void process(final ProcessClassContext processClassContaxt) {
        final Immutable annotation = Annotations.getAnnotation(processClassContaxt.getCls(), Immutable.class);
        FacetUtil.addFacet(create(annotation, processClassContaxt.getFacetHolder()));
    }
View Full Code Here

Examples of org.apache.isis.applib.annotation.Immutable

        super(FeatureType.EVERYTHING_BUT_PARAMETERS);
    }

    @Override
    public void process(final ProcessClassContext processClassContaxt) {
        final Immutable annotation = getAnnotation(processClassContaxt.getCls(), Immutable.class);
        FacetUtil.addFacet(create(annotation, processClassContaxt.getFacetHolder()));
    }
View Full Code Here

Examples of org.apache.isis.applib.annotation.Immutable

        super(FeatureType.OBJECTS_ONLY);
    }

    @Override
    public void process(final ProcessClassContext processClassContaxt) {
        final Immutable annotation = getAnnotation(processClassContaxt.getCls(), Immutable.class);
        FacetUtil.addFacet(create(annotation, processClassContaxt.getFacetHolder()));
    }
View Full Code Here

Examples of org.jboss.xb.binding.Immutable

      attributeType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Immutable(Config.ConfigAttr.class);
         }

         public Object endElement(Object o, QName name, ElementBinding element)
         {
            Immutable imm = (Immutable)o;
            return imm.newInstance();
         }
      }
      );
      attributeType.setSimpleType(new CharactersHandler(){
         public void setValue(QName qName, ElementBinding element, Object owner, Object value)
         {
            Immutable imm = (Immutable)owner;
            Config.ConfigAttr.ConfigAttrDataValue o = new Config.ConfigAttr.ConfigAttrDataValue();
            o.setData((String)value);
            imm.addChild(qName.getLocalPart(), o);
         }
      });

      attributeType.pushInterceptor(new QName("value1"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Immutable imm = (Immutable)parent;
            Config.ConfigAttr.ConfigAttrValue1 value1 = (Config.ConfigAttr.ConfigAttrValue1)child;
            imm.addChild(name.getLocalPart(), value1);
         }
      }
      );

      attributeType.pushInterceptor(new QName("value2"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Immutable imm = (Immutable)parent;
            Config.ConfigAttr.ConfigAttrValue2 value2 = (Config.ConfigAttr.ConfigAttrValue2)child;
            imm.addChild(name.getLocalPart(), value2);
         }
      }
      );

      attributeValue1Type.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Config.ConfigAttr.ConfigAttrValue1();
         }
      }
      );
      attributeValue1Type.pushInterceptor(new QName("property"), new DefaultElementInterceptor()
      {
         public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
         {
            Config.ConfigAttr.ConfigAttrValue1 value1 = (Config.ConfigAttr.ConfigAttrValue1)o;
            value1.setProperty(text);
         }
      }
      );

      attributeValue2Type.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Config.ConfigAttr.ConfigAttrValue2();
         }

      }
      );
      attributeValue2Type.setSimpleType(new CharactersHandler(){
         public void setValue(QName qName, ElementBinding element, Object owner, Object value)
         {
            Config.ConfigAttr.ConfigAttrValue2 value2 = (Config.ConfigAttr.ConfigAttrValue2)owner;
            value2.setValue2((String)value);
         }
      });

      beansType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new ArrayList();
         }
      }
      );
      beansType.pushInterceptor(new QName("bean"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Collection beans = (Collection)parent;
            Config.Bean bean = (Config.Bean)child;
            beans.add(bean);
         }
      }
      );

      beanType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Immutable(Config.Bean.class);
         }

         public Object endElement(Object o, QName name, ElementBinding element)
         {
            Immutable imm = (Immutable)o;
            Config.Bean bean = (Config.Bean)imm.newInstance();
            return bean;
         }
      }
      );

      beanType.pushInterceptor(new QName("name"), new DefaultElementInterceptor()
      {
         public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
         {
            Immutable imm = (Immutable)o;
            imm.addChild(name.getLocalPart(), text);
         }
      }
      );

      listType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new ArrayList();
         }
      }
      );
      listType.pushInterceptor(new QName("value"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Collection list = (Collection)parent;
            Config.ListValue value = (Config.ListValue)child;
            list.add(value);
         }
      }
      );
      listType.pushInterceptor(new QName("depends"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Collection list = (Collection)parent;
            Config.Depends depends = (Config.Depends)child;
            list.add(depends);
         }
      }
      );
      listType.pushInterceptor(new QName("list"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Collection list = (Collection)parent;
            Collection sublist = (Collection)child;
            list.add(sublist);
         }
      }
      );

      listValueType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Immutable(Config.ListValue.class);
         }

         public void attributes(Object o,
                                QName elementName,
                                ElementBinding element,
                                Attributes attrs,
                                NamespaceContext nsCtx)
         {
            Immutable imm = (Immutable)o;
            for(int i = 0; i < attrs.getLength(); ++i)
            {
               String lName = attrs.getLocalName(i);
               if("type".equals(lName))
               {
                  imm.addChild(lName, attrs.getValue(i));
               }
            }
         }

         public Object endElement(Object o, QName name, ElementBinding element)
         {
            Immutable imm = (Immutable)o;
            Config.ListValue value = (Config.ListValue)imm.newInstance();
            return value;
         }
      }
      );
      listValueType.setSimpleType(new CharactersHandler(){
         public void setValue(QName qName, ElementBinding element, Object owner, Object value)
         {
            Immutable imm = (Immutable)owner;
            imm.addChild(qName.getLocalPart(), value);
         }
      });

      listDependsType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Immutable(Config.Depends.class);
         }

         public void attributes(Object o,
                                QName elementName,
                                ElementBinding element,
                                Attributes attrs,
                                NamespaceContext nsCtx)
         {
            Immutable imm = (Immutable)o;
            for(int i = 0; i < attrs.getLength(); ++i)
            {
               String lName = attrs.getLocalName(i);
               if("value".equals(lName))
               {
                  imm.addChild(lName, attrs.getValue(i));
               }
            }
         }

         public Object endElement(Object o, QName name, ElementBinding element)
         {
            Immutable imm = (Immutable)o;
            Config.Depends depends = (Config.Depends)imm.newInstance();
            return depends;
         }
      }
      );
View Full Code Here

Examples of org.jboss.xb.binding.Immutable

      attributeType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Immutable(Config.ConfigAttr.class);
         }

         public Object endElement(Object o, QName name, ElementBinding element)
         {
            Immutable imm = (Immutable)o;
            return imm.newInstance();
         }
      }
      );
      attributeType.setSimpleType(new CharactersHandler(){
         public void setValue(QName qName, ElementBinding element, Object owner, Object value)
         {
            Immutable imm = (Immutable)owner;
            Config.ConfigAttr.ConfigAttrDataValue o = new Config.ConfigAttr.ConfigAttrDataValue();
            o.setData((String)value);
            imm.addChild(qName.getLocalPart(), o);
         }
      });

      attributeType.pushInterceptor(new QName("value1"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Immutable imm = (Immutable)parent;
            Config.ConfigAttr.ConfigAttrValue1 value1 = (Config.ConfigAttr.ConfigAttrValue1)child;
            imm.addChild(name.getLocalPart(), value1);
         }
      }
      );

      attributeType.pushInterceptor(new QName("value2"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Immutable imm = (Immutable)parent;
            Config.ConfigAttr.ConfigAttrValue2 value2 = (Config.ConfigAttr.ConfigAttrValue2)child;
            imm.addChild(name.getLocalPart(), value2);
         }
      }
      );

      attributeValue1Type.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Config.ConfigAttr.ConfigAttrValue1();
         }
      }
      );
      attributeValue1Type.pushInterceptor(new QName("property"), new DefaultElementInterceptor()
      {
         public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
         {
            Config.ConfigAttr.ConfigAttrValue1 value1 = (Config.ConfigAttr.ConfigAttrValue1)o;
            value1.setProperty(text);
         }
      }
      );

      attributeValue2Type.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Config.ConfigAttr.ConfigAttrValue2();
         }

      }
      );
      attributeValue2Type.setSimpleType(new CharactersHandler(){
         public void setValue(QName qName, ElementBinding element, Object owner, Object value)
         {
            Config.ConfigAttr.ConfigAttrValue2 value2 = (Config.ConfigAttr.ConfigAttrValue2)owner;
            value2.setValue2((String)value);
         }
      });

      beansType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new ArrayList();
         }
      }
      );
      beansType.pushInterceptor(new QName("bean"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Collection<Bean> beans = (Collection<Bean>)parent;
            Config.Bean bean = (Config.Bean)child;
            beans.add(bean);
         }
      }
      );

      beanType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Immutable(Config.Bean.class);
         }

         public Object endElement(Object o, QName name, ElementBinding element)
         {
            Immutable imm = (Immutable)o;
            Config.Bean bean = (Config.Bean)imm.newInstance();
            return bean;
         }
      }
      );

      beanType.pushInterceptor(new QName("name"), new DefaultElementInterceptor()
      {
         public void characters(Object o, QName name, TypeBinding type, NamespaceContext nsCtx, String text)
         {
            Immutable imm = (Immutable)o;
            imm.addChild(name.getLocalPart(), text);
         }
      }
      );

      listType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new ArrayList();
         }
      }
      );
      listType.pushInterceptor(new QName("value"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Collection<ListValue> list = (Collection<ListValue>)parent;
            Config.ListValue value = (Config.ListValue)child;
            list.add(value);
         }
      }
      );
      listType.pushInterceptor(new QName("depends"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Collection<Depends> list = (Collection<Depends>)parent;
            Config.Depends depends = (Config.Depends)child;
            list.add(depends);
         }
      }
      );
      listType.pushInterceptor(new QName("list"), new DefaultElementInterceptor()
      {
         public void add(Object parent, Object child, QName name)
         {
            Collection<Collection<?>> list = (Collection<Collection<?>>)parent;
            Collection<?> sublist = (Collection<?>)child;
            list.add(sublist);
         }
      }
      );

      listValueType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Immutable(Config.ListValue.class);
         }

         public void attributes(Object o,
                                QName elementName,
                                ElementBinding element,
                                Attributes attrs,
                                NamespaceContext nsCtx)
         {
            Immutable imm = (Immutable)o;
            for(int i = 0; i < attrs.getLength(); ++i)
            {
               String lName = attrs.getLocalName(i);
               if("type".equals(lName))
               {
                  imm.addChild(lName, attrs.getValue(i));
               }
            }
         }

         public Object endElement(Object o, QName name, ElementBinding element)
         {
            Immutable imm = (Immutable)o;
            Config.ListValue value = (Config.ListValue)imm.newInstance();
            return value;
         }
      }
      );
      listValueType.setSimpleType(new CharactersHandler(){
         public void setValue(QName qName, ElementBinding element, Object owner, Object value)
         {
            Immutable imm = (Immutable)owner;
            imm.addChild(qName.getLocalPart(), value);
         }
      });

      listDependsType.setHandler(new DefaultElementHandler()
      {
         public Object startElement(Object parent, QName name, ElementBinding element)
         {
            return new Immutable(Config.Depends.class);
         }

         public void attributes(Object o,
                                QName elementName,
                                ElementBinding element,
                                Attributes attrs,
                                NamespaceContext nsCtx)
         {
            Immutable imm = (Immutable)o;
            for(int i = 0; i < attrs.getLength(); ++i)
            {
               String lName = attrs.getLocalName(i);
               if("value".equals(lName))
               {
                  imm.addChild(lName, attrs.getValue(i));
               }
            }
         }

         public Object endElement(Object o, QName name, ElementBinding element)
         {
            Immutable imm = (Immutable)o;
            Config.Depends depends = (Config.Depends)imm.newInstance();
            return depends;
         }
      }
      );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.