public boolean isEquatable() { if (classSpec instanceof UnionTemplateSpec) { UnionTemplateSpec unionSpec = (UnionTemplateSpec)classSpec; TyperefTemplateSpec typerefSpec = unionSpec.getTyperefClass(); if (typerefSpec == null) return globalConfig.defaults.equatable; return globalConfig.lookupSwiftProperties(typerefSpec).equatable; } else { return swiftProperties.equatable; } }
@Override public String typeName() { if (_template.getTyperefClass() != null) { // If this union was typerefed then just use the typeref name TSTyperefSyntax refSyntax = TSTyperefSyntaxCreate(_template.getTyperefClass()); return refSyntax.typeName(); } else { // I actually never figured out why this works, so I'm very sorry if you're dealing // with the repercussions here. return escapeKeyword(this._template.getClassName(), EscapeStrategy.MANGLE); } }
public String docString() { if (this._template.getTyperefClass() != null) { return new TSNamedTypeSyntax(this._template.getTyperefClass().getSchema()).docString(); } else { return ""; } }
public static boolean isFlatTypedDefinition(UnionTemplateSpec unionSpec) { TyperefTemplateSpec typerefClass = unionSpec.getTyperefClass(); return (typerefClass != null && typerefClass.getSchema().getProperties().containsKey("flatTypedDefinition")); }
public static boolean isTypedDefinition(UnionTemplateSpec unionSpec) { TyperefTemplateSpec typerefClass = unionSpec.getTyperefClass(); return (typerefClass != null && typerefClass.getSchema().getProperties().containsKey("typedDefinition")); }
public static Map<String, String> getTypedDefinitionMapping(UnionTemplateSpec unionSpec, boolean flat) { String propertyName = flat ? "flatTypedDefinition" : "typedDefinition"; TyperefTemplateSpec typerefClass = unionSpec.getTyperefClass(); DataMap properties = (DataMap)typerefClass.getSchema().getProperties().get(propertyName); HashMap<String, String> results = new HashMap<String, String>(); for (String memberKey: properties.keySet()) { String typeName = properties.getString(memberKey); if (!memberKey.contains(".")) { String namespace = unionSpec.getNamespace(); if (namespace != null) { memberKey = unionSpec.getNamespace() + "." + memberKey; } } results.put(memberKey, typeName); } return results; } }