@Test public void testIsAssignableFrom() throws Exception { assertFalse(helper.isAssignableFrom(null, null)); assertFalse(helper.isAssignableFrom("", null)); assertFalse(helper.isAssignableFrom(null, "")); assertFalse(helper.isAssignableFrom("", "")); assertFalse(helper.isAssignableFrom("a.A", "a.A")); assertFalse(helper.isAssignableFrom("d.E", "d.E")); assertTrue(helper.isAssignableFrom("a.A", "u.v.W")); assertTrue(helper.isAssignableFrom("a.A", "a.b.c.K")); assertTrue(helper.isAssignableFrom("a.A", "a.b.c.L")); assertTrue(helper.isAssignableFrom("a.b.c.K", "a.A")); assertTrue(helper.isAssignableFrom("a.b.c.L", "a.A")); assertTrue(helper.isAssignableFrom("a.B", "a.A")); assertFalse(helper.isAssignableFrom("a.A", "a.b.F")); assertFalse(helper.isAssignableFrom("a.A", "d.E")); assertTrue(helper.isAssignableFrom("d.D", "a.A")); assertTrue(helper.isAssignableFrom("d.e.H", "a.A")); assertTrue(helper.isAssignableFrom("a.b.F", "k.l.K")); assertTrue(helper.isAssignableFrom("k.l.K", "a.b.F")); helper.dataObjectExtended("a.A", "a.b.F", false); helper.dataObjectExtended("k.l.K", "a.b.F", true); assertFalse(helper.isAssignableFrom("k.l.K", "a.b.F")); assertTrue(helper.isAssignableFrom("a.A", "a.b.F")); helper.dataObjectExtended("a.B", "a.C", false); assertTrue(helper.isAssignableFrom("a.A", "d.E")); assertTrue(helper.isAssignableFrom("a.A", "d.e.H")); assertTrue(helper.isAssignableFrom("d.D", "a.A")); assertTrue(helper.isAssignableFrom("d.e.H", "a.A")); helper.dataObjectExtended("a.B", "a.C", true); helper.dataObjectExtended("k.l.K", "a.b.F", false); helper.dataObjectExtended("a.A", "a.b.F", true); }
public Boolean isAssignableFrom(String offspringCandidate, String parentCandidate) { if (offspringCandidate == null || offspringCandidate.length() == 0 || parentCandidate == null || parentCandidate.length() == 0 || offspringCandidate.equals(parentCandidate)) return false; Set<String> candidatesOffspring = offspringMap.get(offspringCandidate); boolean candidateHasOffspring = candidatesOffspring != null && candidatesOffspring.size() > 0; if (candidateHasOffspring) { if (candidatesOffspring.contains(parentCandidate)) return false; for (String newOffspringCandidate : candidatesOffspring) { if (!isAssignableFrom(newOffspringCandidate, parentCandidate)) return false; } } return true; }
DataModelHelper { public Boolean isAssignableFrom(String offspringCandidate, String parentCandidate) { if (offspringCandidate == null || offspringCandidate.length() == 0 || parentCandidate == null || parentCandidate.length() == 0 || offspringCandidate.equals(parentCandidate)) return false; Set<String> candidatesOffspring = offspringMap.get(offspringCandidate); boolean candidateHasOffspring = candidatesOffspring != null && candidatesOffspring.size() > 0; if (candidateHasOffspring) { if (candidatesOffspring.contains(parentCandidate)) return false; for (String newOffspringCandidate : candidatesOffspring) { if (!isAssignableFrom(newOffspringCandidate, parentCandidate)) return false; } } return true; } }
DataModelHelper { public Boolean isAssignableFrom(String offspringCandidate, String parentCandidate) { if (offspringCandidate == null || offspringCandidate.length() == 0 || parentCandidate == null || parentCandidate.length() == 0 || offspringCandidate.equals(parentCandidate)) return false; Set<String> candidatesOffspring = offspringMap.get(offspringCandidate); boolean candidateHasOffspring = candidatesOffspring != null && candidatesOffspring.size() > 0; if (candidateHasOffspring) { if (candidatesOffspring.contains(parentCandidate)) return false; for (String newOffspringCandidate : candidatesOffspring) { if (!isAssignableFrom(newOffspringCandidate, parentCandidate)) return false; } } return true; } DataModelHelper( String contextId ); }
DataModelHelper { public Boolean isAssignableFrom(String offspringCandidate, String parentCandidate) { if (offspringCandidate == null || offspringCandidate.length() == 0 || parentCandidate == null || parentCandidate.length() == 0 || offspringCandidate.equals(parentCandidate)) return false; Set<String> candidatesOffspring = offspringMap.get(offspringCandidate); boolean candidateHasOffspring = candidatesOffspring != null && candidatesOffspring.size() > 0; if (candidateHasOffspring) { if (candidatesOffspring.contains(parentCandidate)) return false; for (String newOffspringCandidate : candidatesOffspring) { if (!isAssignableFrom(newOffspringCandidate, parentCandidate)) return false; } } return true; } DataModelHelper( String contextId ); Collection<String> getDataObjectReferences( String className ); String getObjectLabelByClassName(String className); List<String> getClassList(); Map<String, String> getLabelledClassMap(); Map <String, PropertyType> getOrderedBaseTypes(); void dataModelChanged(DataModelerValueChangeEvent changeEvent); void dataObjectReferenced(String objectClassName, String subjectClassName); void dataObjectUnReferenced(String objectClassName, String subjectClassName); void dataObjectExtended(String parentClassName, String offspringClassName, Boolean _extends); void dataObjectDeleted(String objectClassName); void dataObjectCreated(String objectClassName); void dataObjectSelected(String objectClassName); void dataObjectUnSelected(String objectClassName); Boolean isBaseType(String type); Boolean isPrimitiveType(String type); Boolean isAssignableFrom(String offspringCandidate, String parentCandidate); void setDataModel(DataModel dataModel); void setBaseTypes(List<PropertyType> baseTypes); }
DataModelHelper { public Boolean isAssignableFrom(String offspringCandidate, String parentCandidate) { if (offspringCandidate == null || offspringCandidate.length() == 0 || parentCandidate == null || parentCandidate.length() == 0 || offspringCandidate.equals(parentCandidate)) return false; Set<String> candidatesOffspring = offspringMap.get(offspringCandidate); boolean candidateHasOffspring = candidatesOffspring != null && candidatesOffspring.size() > 0; if (candidateHasOffspring) { if (candidatesOffspring.contains(parentCandidate)) return false; for (String newOffspringCandidate : candidatesOffspring) { if (!isAssignableFrom(newOffspringCandidate, parentCandidate)) return false; } } return true; } DataModelHelper( String contextId ); Collection<String> getDataObjectReferences( String className ); String getObjectLabelByClassName(String className); List<String> getClassList(); Map<String, String> getLabelledClassMap(); Map <String, PropertyType> getOrderedBaseTypes(); void dataModelChanged(DataModelerValueChangeEvent changeEvent); void dataObjectReferenced(String objectClassName, String subjectClassName); void dataObjectUnReferenced(String objectClassName, String subjectClassName); void dataObjectExtended(String parentClassName, String offspringClassName, Boolean _extends); void dataObjectDeleted(String objectClassName); void dataObjectCreated(String objectClassName); void dataObjectSelected(String objectClassName); void dataObjectUnSelected(String objectClassName); Boolean isBaseType(String type); Boolean isPrimitiveType(String type); Boolean isAssignableFrom(String offspringCandidate, String parentCandidate); void setDataModel(DataModel dataModel); void setBaseTypes(List<PropertyType> baseTypes);  }