String interfaces = null; if (c != null && c.getFlattenedSupertypeHierarchy() != null) { assignables = "new HashSet<Class>(Arrays.asList("; boolean used = false; for (JType i : c.getFlattenedSupertypeHierarchy()) { if (!isVisible(i) || i.equals(t) || "java.lang.Object".equals(i.getErasedType().getQualifiedSourceName())) continue; if (used) assignables += ", ";
String interfaces = null; if (c != null && c.getFlattenedSupertypeHierarchy() != null) { assignables = "new HashSet<Class>(Arrays.asList("; boolean used = false; for (JType i : c.getFlattenedSupertypeHierarchy()) { if (!isVisible(i) || i.equals(t) || "java.lang.Object".equals(i.getErasedType().getQualifiedSourceName())) continue; if (used) assignables += ", ";
/** * Determines if the element implements Caption. * * @throws UnableToCompleteException */ protected boolean isCaption(UiBinderWriter writer, XMLElement element) throws UnableToCompleteException { JClassType type = writer.findFieldType(element); Set<? extends JClassType> classes = type.getFlattenedSupertypeHierarchy(); JClassType captionType = writer.getOracle().findType( Caption.class.getCanonicalName()); return classes.contains(captionType); }
@Override public void addTypeHierarchy(JClassType type) { if (!canBeCacheable) { return; } if (!types.add(type)) { return; } Set<? extends JClassType> superTypes = type.getFlattenedSupertypeHierarchy(); types.addAll(superTypes); }
@Override public void addTypeHierarchy(JClassType type) { if (!canBeCacheable) { return; } if (!types.add(type)) { return; } Set<? extends JClassType> superTypes = type.getFlattenedSupertypeHierarchy(); types.addAll(superTypes); }
private boolean hasCssToInject(final JClassType type) { for (final JClassType subtype : type.getFlattenedSupertypeHierarchy()) { if (hasCssAnnotations(subtype)) { return true; } } return false; }
public boolean isJson() { Set<? extends JClassType> hierarchy = rwType.getFlattenedSupertypeHierarchy(); for (JClassType type : hierarchy) { if (JsonReader.class.getName().equals(type.getQualifiedSourceName()) || JsonWriter.class.getName().equals(type.getQualifiedSourceName())) { return true; } } return false; }
searchType : for (JClassType searchType : referenceType.getFlattenedSupertypeHierarchy()) { for (JMethod method : searchType.getOverloads(pathElement)) { if (method.getParameters().length == 0) {
public boolean isXml() { Set<? extends JClassType> hierarchy = rwType.getFlattenedSupertypeHierarchy(); for (JClassType type : hierarchy) { if (XmlReader.class.getName().equals(type.getQualifiedSourceName()) || XmlWriter.class.getName().equals(type.getQualifiedSourceName())) { return true; } } return false; }
public static boolean supports(JClassType classType, Class<?> supportType) { if (classType == null) { return false; } String testTypeName = classType.getQualifiedSourceName(); String supportTypeName = supportType.getName(); if (testTypeName.equals(supportTypeName)) { return true; } Set<? extends JClassType> interfaces = new HashSet<JClassType>( classType.getFlattenedSupertypeHierarchy()); interfaces.remove(classType); for (JClassType implementedInterface : interfaces) { if (supports(implementedInterface, supportType)) { return true; } } return false; }
public static boolean supports(JClassType classType, Class<?> supportType) { if (classType == null) { return false; } String testTypeName = classType.getQualifiedSourceName(); String supportTypeName = supportType.getName(); if (testTypeName.equals(supportTypeName)) { return true; } Set<? extends JClassType> interfaces = new HashSet<JClassType>( classType.getFlattenedSupertypeHierarchy()); interfaces.remove(classType); for (JClassType implementedInterface : interfaces) { if (supports(implementedInterface, supportType)) { return true; } } return false; }
private void extractAllMethods(final JClassType uiModel, final JPrimitiveType voidType) { for (final JClassType type : uiModel.getFlattenedSupertypeHierarchy()) { for (final JMethod method : type.getMethods()) { if (isGetterMethod(method, voidType)) { final String name = toSimpleName(method); if (!methods.containsKey(name)) { methods.put(name, method); } } } } }
/** * Determines if the element implements Caption. * * @throws UnableToCompleteException */ protected boolean isCaption(UiBinderWriter writer, XMLElement element) throws UnableToCompleteException { JClassType type = writer.findFieldType(element); Set<? extends JClassType> classes = type.getFlattenedSupertypeHierarchy(); JClassType captionType = writer.getOracle().findType( Caption.class.getCanonicalName()); return classes.contains(captionType); }
/** * Determines if the element implements Caption. * * @throws UnableToCompleteException */ protected boolean isCaption(UiBinderWriter writer, XMLElement element) throws UnableToCompleteException { JClassType type = writer.findFieldType(element); Set<? extends JClassType> classes = type.getFlattenedSupertypeHierarchy(); JClassType captionType = writer.getOracle().findType( Caption.class.getCanonicalName()); return classes.contains(captionType); }
private JClassType getPlaceTypeForTokenizerType(JClassType tokenizerType) throws UnableToCompleteException { JClassType rtn = placeTypeForInterfaces(tokenizerType.getFlattenedSupertypeHierarchy()); if (rtn == null) { logger.log(TreeLogger.ERROR, "Found no Place type for " + tokenizerType.getQualifiedSourceName()); throw new UnableToCompleteException(); } return rtn; }
private JClassType getPlaceTypeForTokenizerType(JClassType tokenizerType) throws UnableToCompleteException { JClassType rtn = placeTypeForInterfaces(tokenizerType.getFlattenedSupertypeHierarchy()); if (rtn == null) { logger.log(TreeLogger.ERROR, "Found no Place type for " + tokenizerType.getQualifiedSourceName()); throw new UnableToCompleteException(); } return rtn; }
@Test public void doParse_unhandledFieldTypeRecursion() { Set<? extends JClassType> ownerTypeParentFieldTypeSubField1TypeFlattenedSupertypeHierarchy = Collections.singleton(ownerTypeParentFieldTypeSubField1Type); doReturn(ownerTypeParentFieldTypeSubField1TypeFlattenedSupertypeHierarchy) .when(ownerTypeParentFieldTypeSubField1Type).getFlattenedSupertypeHierarchy(); when(ownerTypeParentFieldTypeSubField1Type.getFields()).thenReturn(new JField[] { ownerTypeParentField }); assertThrows(UnableToCompleteException.class, () -> tested.doParse(ownerType, new ArrayList<>(), ".", "IdPrefix")); //$NON-NLS-1$ //$NON-NLS-2$ }
@Test public void doParse_handledFieldTypeRecursion() throws UnableToCompleteException { Set<? extends JClassType> ownerTypeParentFieldTypeSubField1TypeFlattenedSupertypeHierarchy = Collections.singleton(ownerTypeParentFieldTypeSubField1Type); doReturn(ownerTypeParentFieldTypeSubField1TypeFlattenedSupertypeHierarchy) .when(ownerTypeParentFieldTypeSubField1Type).getFlattenedSupertypeHierarchy(); when(ownerTypeParentFieldTypeSubField1Type.getFields()).thenReturn(new JField[] { ownerTypeParentField }); stubFieldIdAnnotation(ownerTypeParentField, "", false); //$NON-NLS-1$ tested.doParse(ownerType, new ArrayList<JClassType>(), ".", "IdPrefix"); //$NON-NLS-1$ //$NON-NLS-2$ List<ElementIdStatement> expected = Arrays.asList( getExpectedStatement("ownerTypeParentField", "IdPrefix_ownerTypeParentField"), //$NON-NLS-1$ //$NON-NLS-2$ getExpectedStatement("ownerTypeField1", "IdPrefix_ownerTypeField1"), //$NON-NLS-1$ //$NON-NLS-2$ getExpectedStatement("ownerTypeField2", "IdPrefix_ownerTypeField2")); //$NON-NLS-1$ //$NON-NLS-2$ assertThat(tested.statements.size(), is(equalTo(expected.size()))); assertThat(tested.statements.containsAll(expected), is(equalTo(true))); }
public static JClassType[] findParameterizationOf(JClassType intfType, JClassType subType) { assert intfType.isAssignableFrom(subType) : subType.getParameterizedQualifiedSourceName() + " is not assignable to " + subType.getParameterizedQualifiedSourceName(); for (JClassType supertype : subType.getFlattenedSupertypeHierarchy()) { JParameterizedType parameterized = supertype.isParameterized(); if (parameterized != null) { // Found the desired supertype if (intfType.equals(parameterized.getBaseType())) { return parameterized.getTypeArgs(); } } } return null; }
public static JClassType[] findParameterizationOf(JClassType intfType, JClassType subType) { assert intfType.isAssignableFrom(subType) : subType.getParameterizedQualifiedSourceName() + " is not assignable to " + subType.getParameterizedQualifiedSourceName(); for (JClassType supertype : subType.getFlattenedSupertypeHierarchy()) { JParameterizedType parameterized = supertype.isParameterized(); if (parameterized != null) { // Found the desired supertype if (intfType.equals(parameterized.getBaseType())) { return parameterized.getTypeArgs(); } } } return null; }