Examples of Child


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

        assertNotNull(routePlanner.getRoute().getCities().get(0).getName());
    }

    @Test
    public void shouldWorkWithInheritance() {
        Child child = Fixture.from(Child.class).gimme("valid");
      assertThat(child.getParentAttribute().getValue().length(), is(8));
      assertThat(child.getChildAttribute().length(), is(16));
    }
View Full Code Here

Examples of ca.uhn.fhir.model.api.annotation.Child

  private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, Set<String> elementNames, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToElementDef, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToExtensionDef) {
    int baseElementOrder = theOrderToElementDef.isEmpty() ? 0 : theOrderToElementDef.lastEntry().getKey() + 1;

    for (Field next : theClass.getDeclaredFields()) {

      Child childAnnotation = next.getAnnotation(Child.class);
      if (childAnnotation == null) {
        ourLog.debug("Ignoring non-type field '" + next.getName() + "' on target type: " + theClass);
        continue;
      }

      Description descriptionAnnotation = next.getAnnotation(Description.class);

      String elementName = childAnnotation.name();
      int order = childAnnotation.order();
      if (order < 0 && order != Child.ORDER_UNKNOWN) {
        throw new ConfigurationException("Invalid order '" + order + "' on @Child for field '" + next.getName() + "' on target type: " + theClass);
      }
      if (order != Child.ORDER_UNKNOWN) {
        order = order + baseElementOrder;
      }
      int min = childAnnotation.min();
      int max = childAnnotation.max();
      TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> orderMap = theOrderToElementDef;

      Extension extensionAttr = next.getAnnotation(Extension.class);
      if (extensionAttr != null) {
        orderMap = theOrderToExtensionDef;
      }

      /*
       * Anything that's marked as unknown is given a new ID that is <0 so that it doesn't conflict wityh any
       * given IDs and can be figured out later
       */
      while (order == Child.ORDER_UNKNOWN && orderMap.containsKey(order)) {
        order--;
      }

      List<Class<? extends IElement>> choiceTypes = new ArrayList<Class<? extends IElement>>();
      for (Class<? extends IElement> nextChoiceType : childAnnotation.type()) {
        choiceTypes.add(nextChoiceType);
      }

      if (orderMap.containsKey(order)) {
        throw new ConfigurationException("Detected duplicate field order '" + childAnnotation.order() + "' for element named '" + elementName + "' in type '" + theClass.getCanonicalName() + "'");
      }

      if (elementNames.contains(elementName)) {
        throw new ConfigurationException("Detected duplicate field name '" + elementName + "' in type '" + theClass.getCanonicalName() + "'");
      }

      Class<?> nextElementType = determineElementType(next);

      if (nextElementType.equals(ContainedDt.class)) {
        /*
         * Child is contained resources
         */
        RuntimeChildContainedResources def = new RuntimeChildContainedResources(next, childAnnotation, descriptionAnnotation, elementName);
        orderMap.put(order, def);

      } else if (choiceTypes.size() > 1 && !ResourceReferenceDt.class.isAssignableFrom(nextElementType)) {
        /*
         * Child is a choice element
         */
        for (Class<? extends IElement> nextType : choiceTypes) {
          addScanAlso(nextType);
        }
        RuntimeChildChoiceDefinition def = new RuntimeChildChoiceDefinition(next, elementName, childAnnotation, descriptionAnnotation, choiceTypes);
        orderMap.put(order, def);

      } else if (next.getType().equals(ExtensionDt.class)) {

        RuntimeChildExtensionDt def = new RuntimeChildExtensionDt(next, elementName, childAnnotation, descriptionAnnotation);
        orderMap.put(order, def);
        if (IElement.class.isAssignableFrom(nextElementType)) {
          addScanAlso((Class<? extends IElement>) nextElementType);
        }

      } else if (extensionAttr != null) {
        /*
         * Child is an extension
         */
        Class<? extends IElement> et = (Class<? extends IElement>) nextElementType;
        RuntimeChildDeclaredExtensionDefinition def = new RuntimeChildDeclaredExtensionDefinition(next, childAnnotation, descriptionAnnotation, extensionAttr, elementName, extensionAttr.url(), et);
        orderMap.put(order, def);
        if (IElement.class.isAssignableFrom(nextElementType)) {
          addScanAlso((Class<? extends IElement>) nextElementType);
        }
      } else if (BaseResourceReference.class.isAssignableFrom(nextElementType)) {
        /*
         * Child is a resource reference
         */
        List<Class<? extends IResource>> refTypesList = new ArrayList<Class<? extends IResource>>();
        for (Class<? extends IElement> nextType : childAnnotation.type()) {
          if (IResource.class.isAssignableFrom(nextType) == false) {
            throw new ConfigurationException("Field '" + next.getName() + "' in class '" + next.getDeclaringClass().getCanonicalName() + "' is of type " + ResourceReferenceDt.class + " but contains a non-resource type: " + nextType.getCanonicalName());
          }
          refTypesList.add((Class<? extends IResource>) nextType);
          addScanAlso(nextType);
View Full Code Here

Examples of com.alvazan.test.db.Child

    User user1 = new User();
    user1.setAge(5);
    user1.setName("dean");
    mgr.put(user1);
   
    Child child1 = new Child();
    child1.setAge(5);
    child1.setName("bob1");
    mgr.put(child1);
   
    Child child2 = new Child();
    child2.setAge(5);
    child2.setName("dean2");
    mgr.put(child2);
   
    Child child3 = new Child();
    child3.setAge(6);
    child3.setName("none");
    mgr.put(child3);
   
    User user2 = new User();
    user2.setAge(8);
    user2.setName("joe");
    mgr.put(user2);
   
    User user3 = new User();
    user3.setAge(8);
    user3.setName("joe2");
    mgr.put(user3);
   
    Child child4 = new Child();
    child4.setAge(8);
    child4.setName("joe3");
    mgr.put(child4);
   
    User user4 = new User();
    user4.setAge(10);
    user4.setName("nochild");
   
    mgr.put(user4);
   
    Child child5 = new Child();
    child5.setAge(20);
    child5.setName("someone");
    mgr.put(child5);
   
    mgr.flush();
  }
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jpa.SubclassesJPA.Child

    e.setProperty("aString", "a");
    e.setProperty("bString", "b");
    ds.put(e);

    beginTxn();
    Child child = em.find(childClass, e.getKey());
    assertEquals(childClass, child.getClass());
    assertEquals("a", child.getAString());
    assertEquals("b", child.getBString());
    commitTxn();
  }
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jpa.SubclassesJPA.Child

    ds.put(e3);

    beginTxn();
    Query q = em.createQuery("select from " + childClass.getName() + " b where aString = :p");
    q.setParameter("p", "a2");
    Child child = (Child) q.getResultList().get(0);
    assertEquals(childClass, child.getClass());
    assertEquals("a2", child.getAString());
    assertEquals("b2", child.getBString());

    q = em.createQuery("select from " + childClass.getName() + " b where bString = :p");
    q.setParameter("p", "b2");
    child = (Child) q.getSingleResult();
    assertEquals(childClass, child.getClass());
    assertEquals("a2", child.getAString());
    assertEquals("b2", child.getBString());

    List<Child> kids = ((List<Child>) em.createQuery(
        "select from " + childClass.getName() + " b where aString = 'a2' order by bString desc").getResultList());
    assertEquals(3, kids.size());
    assertEquals(e2.getKey().getId(), kids.get(0).getId().longValue());
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jpa.SubclassesJPA.Child

    e.setProperty("aString", "a");
    e.setProperty("bString", "b");
    ds.put(e);

    beginTxn();
    Child child = em.find(childClass, e.getKey());
    em.remove(child);
    commitTxn();
    try {
      ds.get(e.getKey());
      fail("expected exception");
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jpa.SubclassesJPA.Child

    e.setProperty("bString", "b");
    e.setProperty("cString", "c");
    ds.put(e);

    beginTxn();
    Child child = em.find(grandchildClass, e.getKey());
    em.remove(child);
    commitTxn();
    try {
      ds.get(e.getKey());
      fail("expected exception");
View Full Code Here

Examples of com.google.appengine.datanucleus.test.jpa.SubclassesJPA.Child

    e.setProperty("aString", "a");
    e.setProperty("bString", "b");
    ds.put(e);

    beginTxn();
    Child child = em.find(childClass, e.getKey());
    child.setAString("not a");
    child.setBString("not b");
    commitTxn();
    e = ds.get(e.getKey());
    assertEquals("not a", e.getProperty("aString"));
    assertEquals("not b", e.getProperty("bString"));
  }
View Full Code Here

Examples of com.google.appengine.tools.mapreduce.testModels.Child

    List<MarshallingOutputWriter<Father>> writers = creator.createWriters(5);
    for (MarshallingOutputWriter<Father> writer : writers) {
      writer.beginShard();
      writer.beginSlice();
      writer.write(new Father(true, "Father",
          Lists.newArrayList(new Child("Childone", 1), new Child("childtwo", 2))));
      writer.endSlice();
      writer.endShard();
    }
    BigQueryStoreResult<GoogleCloudStorageFileSet> actual = creator.finish(writers);
View Full Code Here

Examples of com.google.appengine.tools.mapreduce.testModels.Child

    for (MarshallingOutputWriter<Father> writer : writers) {
      writer.beginShard();
      writer.beginSlice();
      writer = SerializationUtil.clone(writer);
      writer.write(new Father(true, "Father",
          Lists.newArrayList(new Child("Childone", 1), new Child("childtwo", 2))));
      writer.endSlice();
      writer.beginSlice();
      writer.write(new Father(true, "Father",
          Lists.newArrayList(new Child("Childone", 1), new Child("childtwo", 2))));
      writer.endSlice();
      writer = SerializationUtil.clone(writer);
      writer.beginSlice();
      writer.write(new Father(true, "Father",
          Lists.newArrayList(new Child("Childone", 1), new Child("childtwo", 2))));
      writer.endSlice();
      writer.endShard();
      finished.add(writer);
    }
    BigQueryStoreResult<GoogleCloudStorageFileSet> result = creator.finish(finished);
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.