Ejemplo n.º 1
0
 public final XMap<K, V> getQueuedOrphans() {
   XMap<K, V> map = this.delayOrphanMap;
   if (map == null) {
     return MACollections.emptyMap();
   }
   return MACollections.unmodifiable(map);
 }
Ejemplo n.º 2
0
  @Test
  public void testContravarianceList() {

    TabControl tabControl = new TabControl();
    TabPage tabPage1 = new TabPage();
    TabPage tabPage2 = new TabPage();
    TabPage tabPage3 = new TabPage();
    TabPage tabPage4 = new TabPage();

    assertTabControl(tabControl);
    assertContainer(tabControl);

    tabControl.getTabPages().addAll(MACollections.wrap(tabPage1, tabPage2, tabPage3, tabPage4));

    assertTabControl(tabControl, tabPage1, tabPage2, tabPage3, tabPage4);
    assertContainer(tabControl, tabPage1, tabPage2, tabPage3, tabPage4);
  }
Ejemplo n.º 3
0
 static {
   Map<String, String> map = new HashMap<>();
   String oracle = System.getProperty("oracle");
   if (oracle != null) {
     // For eclipse run/debug configuration, "-Doracle" means
     // empty string, but for shell, it means "-Doracle=true"
     if (!oracle.startsWith("jdbc:oracle:")) {
       oracle = "jdbc:oracle:thin:@localhost:1521:babyfish";
     }
     map.put(
         "hibernate.dialect",
         // babfish's dialect, not hibernate's dialect
         "org.babyfish.hibernate.dialect.Oracle10gDialect");
     map.put("hibernate.connection.driver_class", "oracle.jdbc.OracleDriver");
     map.put("hibernate.connection.url", oracle);
     map.put("hibernate.connection.username", System.getProperty("oracle.user", "babyfish"));
     map.put("hibernate.connection.password", System.getProperty("oracle.password", "123"));
   }
   ORACLE_PROPERTY_MAP = MACollections.unmodifiable(map);
 }
  static {
    Map<Class<?>, Class<?>> map = new HashMap<Class<?>, Class<?>>();

    map.put(NavigableMap.class, EntityNavigableMap.class);
    map.put(SortedMap.class, EntityNavigableMap.class);
    map.put(XOrderedMap.class, EntityOrderedMap.class);
    map.put(Map.class, EntityOrderedMap.class);

    map.put(NavigableSet.class, EntityNavigableSet.class);
    map.put(SortedSet.class, EntityNavigableSet.class);
    map.put(XOrderedSet.class, EntityOrderedSet.class);
    map.put(Set.class, EntityOrderedSet.class);

    map.put(List.class, EntityList.class);

    map.put(Collection.class, EntityCollection.class);

    map.put(KeyedReference.class, EntityKeyedReference.class);
    map.put(IndexedReference.class, EntityIndexedReference.class);
    map.put(Reference.class, EntityReference.class);

    ASSOCIATED_END_RESOLVER_MAP = MACollections.unmodifiable(map);
  }
Ejemplo n.º 5
0
 @Deprecated
 @Override
 public final List<Node> getChildNodes() {
   return MACollections.emptyList();
 }
  @Test
  public void test() {
    /*
     * Prepare two departments and 4 employees
     */
    Department department1 = new Department();
    Department department2 = new Department();
    Employee employee1 = new Employee("E-1");
    Employee employee2 = new Employee("E-2");
    Employee employee3 = new Employee("E-3");
    Employee employee4 = new Employee("E-4");

    {
      /*
       * Validate the initialized state of these objects
       */
      assertDepartment(department1);
      assertDepartment(department2);
      assertEmployee(employee1, null);
      assertEmployee(employee2, null);
      assertEmployee(employee3, null);
      assertEmployee(employee4, null);
    }

    {
      /*
       * Add employee1 into department1.
       * The property "department" of employee1 will be changed automatically and implicitly.
       */
      department1.getEmployees().add(employee1);

      assertDepartment(department1, employee1); // Changed by you
      assertDepartment(department2);
      assertEmployee(employee1, department1); // Changed automatically
      assertEmployee(employee2, null);
      assertEmployee(employee3, null);
      assertEmployee(employee4, null);
    }

    {
      /*
       * Set department1 to be the parent of employe2.
       * The property "employees" of department1 will be changed automatically and implicitly.
       */
      employee2.setDepartment(department1);

      assertDepartment(department1, employee1, employee2); // Changed automatically
      assertDepartment(department2);
      assertEmployee(employee1, department1);
      assertEmployee(employee2, department1); // Changed by you
      assertEmployee(employee3, null);
      assertEmployee(employee4, null);
    }

    {
      /*
       * Add employee3 and employee4 into department1.
       * (1) The property "department" of employee3 or employee4 will be changed automatically and implicitly.
       */
      department1.getEmployees().addAll(MACollections.wrap(employee3, employee4));

      assertDepartment(department1, employee1, employee2, employee3, employee4); // Changed by you
      assertDepartment(department2);
      assertEmployee(employee1, department1);
      assertEmployee(employee2, department1);
      assertEmployee(employee3, department1); // Changed automatically
      assertEmployee(employee4, department1); // Changed automatically
    }

    {
      /*
       * Change the parent object of employee4 to be department2.
       * (1) The property "employees" of the old parent object department1 will be changed automatically and implicitly.
       * (2) The property "employees" of the new parent object department2 will be changed automatically and implicitly.
       */
      employee4.setDepartment(department2);

      assertDepartment(department1, employee1, employee2, employee3); // Changed automatically
      assertDepartment(department2, employee4); // Changed automatically
      assertEmployee(employee1, department1);
      assertEmployee(employee2, department1);
      assertEmployee(employee3, department1);
      assertEmployee(employee4, department2); // Changed by you
    }

    {
      /*
       * Let department2 seize all the employees of department1
       * (1) The property "department" of employee1, employee2 and employee3
       *    will be changed automatically and implicitly.
       * (2) The original parent object department1 of employee1, employee2 and employee3 lost all the employees,
       *  so its property "employees" will be clean automatically and implicitly.
       */
      department2.getEmployees().addAll(department1.getEmployees());

      assertDepartment(department1); // Changed automatically
      assertDepartment(department2, employee1, employee2, employee3, employee4); // Changed by you
      assertEmployee(employee1, department2); // Changed automatically
      assertEmployee(employee2, department2); // Changed automatically
      assertEmployee(employee3, department2); // Changed automatically
      assertEmployee(employee4, department2);
    }

    {
      /*
       * Advance functionality:
       * Remove all the employees whose name ends with even number,
       * that means employee2 and employee4 will be removed.
       * The property "department" of employee2 and employee4 will be changed to be null automatically and implicitly.
       */
      Iterator<Employee> itr = department2.getEmployees().iterator();
      while (itr.hasNext()) {
        Employee employee = itr.next();
        int number =
            Integer.parseInt(employee.getName().substring(employee.getName().indexOf('-') + 1));
        if (number % 2 == 0) {
          itr.remove(); // Can ONLY invoke remove of iterator, can NOT invoke remove of collection
        }
      }

      assertDepartment(department1);
      assertDepartment(department2, employee1, employee3); // Changed by you
      assertEmployee(employee1, department2);
      assertEmployee(employee2, null); // Changed automatically
      assertEmployee(employee3, department2);
      assertEmployee(employee4, null); // Changed automatically
    }

    {
      /*
       * Change the property "department" of employee1 to be null.
       * The property "employees" of the parent object department2 will be changed automatically and implicitly.
       */
      employee1.setDepartment(null);

      assertDepartment(department1);
      assertDepartment(department2, employee3); // Changed automatically
      assertEmployee(employee1, null); // Changed by you
      assertEmployee(employee2, null);
      assertEmployee(employee3, department2);
      assertEmployee(employee4, null);
    }

    {
      /*
       * Clean the property "employees" of department2.
       * The property "department" of employee3 that is the last child of department2
       * will be changed automatically and implicitly.
       */
      department2.getEmployees().clear();

      assertDepartment(department1);
      assertDepartment(department2); // Changed by you
      assertEmployee(employee1, null);
      assertEmployee(employee2, null);
      assertEmployee(employee3, null); // Changed automatically
      assertEmployee(employee4, null);
    }
  }
Ejemplo n.º 7
0
 List<QueryPath> getQueryPaths() {
   List<QueryPath> queryPaths = this.queryPaths;
   return MACollections.wrap(queryPaths.toArray(new QueryPath[queryPaths.size()]));
 }