public boolean is(final JvmType type, final Class<?> clazz) { if (type == null) return false; boolean result = clazz.getCanonicalName().equals(type.getIdentifier()); return result; }
public boolean is(final JvmType type, final Class<?> clazz) { if (type == null) return false; String className = clazz.getName(); if (className.charAt(0) == '[') { className = clazz.getCanonicalName(); } boolean result = className.equals(type.getIdentifier()); return result; }
/** * Copied from TypeReferences.is(JvmType,Class<?>) to make functionality available without injection */ public static boolean is(final JvmType type, final Class<?> clazz) { if (type == null) return false; String className = clazz.getName(); if (className.charAt(0) == '[') { className = clazz.getCanonicalName(); } boolean result = className.equals(type.getIdentifier()); return result; }
protected LightweightTypeReference getFirstForRawType(Multimap<JvmType, LightweightTypeReference> all, JvmType rawType) { Iterator<LightweightTypeReference> iterator = all.get(rawType).iterator(); while(iterator.hasNext()) { LightweightTypeReference result = iterator.next(); if (result instanceof ParameterizedTypeReference || result instanceof ArrayTypeReference) { return result; } } throw new IllegalStateException(all.toString() + " does not contain a useful type reference for rawtype " + rawType.getIdentifier()); }
@Override public String apply(XAnnotation input) { return input.getAnnotationType().getIdentifier(); } });
public Set<String> collectNames(JvmType type) { Set<JvmType> superTypes = collect(type); final Set<String> superTypeNames = Sets.newHashSet(); for(JvmType collectedSuperType: superTypes) { superTypeNames.add(collectedSuperType.getIdentifier()); } return superTypeNames; }
@Override public String getIdentifier() { JvmType type = getType(); if (type != null) return type.getIdentifier(); return null; }
private boolean identifierStartWith(LightweightTypeReference typeReference, String prefix) { JvmType type = typeReference.getType(); if (type == null) return false; String identifier = type.getIdentifier(); if (identifier != null) return identifier.startsWith(prefix); return false; }
@Override public String getIdentifier() { JvmType type = getType(); if (type != null) return type.getIdentifier(); return null; }
@Override public String getIdentifier() { return getAsString(type.getIdentifier(), IdentifierFunction.INSTANCE); }
@Override public boolean isType(Class<?> clazz) { return type.eClass() != TypesPackage.Literals.JVM_TYPE_PARAMETER && clazz.getName().equals(type.getIdentifier()); }
@Override public String getJavaIdentifier() { return getAsString(type.getIdentifier(), JavaIdentifierFunction.INSTANCE); }
private static void appendType(JvmParameterizedTypeReference typeReference, char innerClassDelimiter, NameType nameType, StringBuilder result) { JvmType type = typeReference.getType(); if (type != null) { switch(nameType) { case ID: result.append(type.getIdentifier()); break; case QUALIFIED: result.append(type.getQualifiedName(innerClassDelimiter)); break; case SIMPLE: result.append(type.getSimpleName()); break; case TO_STRING: result.append(type.getIdentifier()); break; } } }
protected boolean hasAnnotation(Iterable<? extends XAnnotation> annotations, Class<?> annotationType) { for (XAnnotation anno : annotations) { if (anno.getAnnotationType() != null && annotationType.getName().equals(anno.getAnnotationType().getIdentifier())) return true; } return false; }
protected Object create(JvmType jvmType) { Class<?> class1 = reflectAccess.getRawType(jvmType); if (class1==null) throw new IllegalStateException("Couldn't find java.lang.Class for name '"+jvmType.getIdentifier()+"'"); try { return class1.newInstance(); } catch (Exception e) { throw new WrappedException(e); } }
private static String getSignatureType(JvmType type, ImportManager importManager) { if (importManager != null) { importManager.addImportFor(type); return type.getSimpleName(); } return type.getIdentifier(); }
@Override public String getJavaIdentifier() { return getAsStringNoFunctionType(getType().getIdentifier(), JavaIdentifierFunction.INSTANCE); }
protected boolean hasAnnotation(XtendAnnotationTarget source, Class<?> class1) { for (XAnnotation anno : source.getAnnotations()) { if (anno != null && anno.getAnnotationType() != null && class1.getName().equals(anno.getAnnotationType().getIdentifier())) return true; } return false; }
@Check public void checkTypeLiteral(XTypeLiteral typeLiteral) { if (!typeLiteral.getArrayDimensions().isEmpty() && typeLiteral.getType().getIdentifier().equals("void")) { error("'void"+Joiner.on("").join(typeLiteral.getArrayDimensions()) +"' is not a valid type", null, INVALID_TYPE); } }
public String getSuperTypeName(JvmTypeReference typeReference) { if (typeReference instanceof JvmParameterizedTypeReference) { JvmType rawType = typeReference.getType(); if (rawType != null && !rawType.eIsProxy()) { return rawType.getIdentifier(); } return null; } else { return typeReference.getIdentifier(); } } });