tabsln("'use strict';");
tabsln("var contract = {};");
tabsln("contract.YASS_VERSION = '%s';", Version.VALUE);
println();
for (final Map.Entry<Integer, TypeHandler> entry : id2typeHandler.entrySet()) {
final TypeHandler typeHandler = entry.getValue();
final Class<?> type = typeHandler.type;
if (type.isEnum()) {
generateEnum((Class<Enum<?>>)type);
} else if (typeHandler instanceof ClassTypeHandler) {
generateClass(type);
}
}
final Class<?> clientServices = Class.forName(this.rootPackage + "ClientServices");
final Class<?> serverServices = Class.forName(this.rootPackage + "ServerServices");
final Set<Class<?>> interfacesSet = getInterfaces(clientServices);
interfacesSet.addAll(getInterfaces(serverServices));
final List<Class<?>> interfacesList = new ArrayList<>(interfacesSet);
Collections.sort(interfacesList, new Comparator<Class<?>>() {
@Override public int compare(final Class<?> type1, final Class<?> type2) {
return type1.getCanonicalName().compareTo(type2.getCanonicalName());
}
});
for (final Class<?> type : interfacesList) {
generateInterface(type);
}
generateServices(clientServices);
generateServices(serverServices);
for (final Map.Entry<Integer, TypeHandler> entry : id2typeHandler.entrySet()) {
final TypeHandler typeHandler = entry.getValue();
if (typeHandler instanceof ClassTypeHandler) {
generateFields((ClassTypeHandler)typeHandler);
}
}
tabs("contract.SERIALIZER = yass.serializer(");