use of com.linkedin.data.schema.Name in project rest.li by linkedin.
the class PdlSchemaParser method setCurrentImports.
private void setCurrentImports(ImportDeclarationsContext imports) {
Map<String, Name> importsBySimpleName = new HashMap<>();
for (ImportDeclarationContext importDecl : imports.importDeclaration()) {
String importedFullname = importDecl.type.value;
Name importedName = new Name(importedFullname);
String importedSimpleName = importedName.getName();
if (importsBySimpleName.containsKey(importedSimpleName)) {
startErrorMessage(importDecl).append("'").append(importsBySimpleName.get(importedSimpleName)).append("' is already defined in an import.").append(NEWLINE);
}
importsBySimpleName.put(importedSimpleName, importedName);
}
this.currentImports = importsBySimpleName;
}
use of com.linkedin.data.schema.Name in project rest.li by linkedin.
the class PdlSchemaParser method parseTyperef.
private TyperefDataSchema parseTyperef(NamedTypeDeclarationContext context, TyperefDeclarationContext typeref) throws ParseException {
Name name = toName(typeref.name);
TyperefDataSchema schema = new TyperefDataSchema(name);
bindNameToSchema(name, schema);
DataSchema refSchema = toDataSchema(typeref.ref);
schema.setReferencedType(refSchema);
schema.setRefDeclaredInline(isDeclaredInline(typeref.ref));
setProperties(context, schema);
return schema;
}
use of com.linkedin.data.schema.Name in project rest.li by linkedin.
the class PdlSchemaParser method parseFixed.
private FixedDataSchema parseFixed(NamedTypeDeclarationContext context, FixedDeclarationContext fixed) throws ParseException {
Name name = toName(fixed.name);
FixedDataSchema schema = new FixedDataSchema(name);
bindNameToSchema(name, schema);
schema.setSize(fixed.size, errorMessageBuilder());
setProperties(context, schema);
return schema;
}
use of com.linkedin.data.schema.Name in project rest.li by linkedin.
the class PdlSchemaParser method parseEnum.
private EnumDataSchema parseEnum(NamedTypeDeclarationContext context, EnumDeclarationContext enumDecl) throws ParseException {
Name name = toName(enumDecl.name);
EnumDataSchema schema = new EnumDataSchema(name);
bindNameToSchema(name, schema);
List<EnumSymbolDeclarationContext> symbolDecls = enumDecl.enumDecl.symbolDecls;
List<String> symbols = new ArrayList<>(symbolDecls.size());
Map<String, Object> props = setProperties(context, schema);
Map<String, Object> symbolDocs = new HashMap<>();
DataMap deprecatedSymbols = new DataMap();
DataMap symbolProperties = new DataMap();
for (EnumSymbolDeclarationContext symbolDecl : symbolDecls) {
symbols.add(symbolDecl.symbol.value);
if (symbolDecl.doc != null) {
symbolDocs.put(symbolDecl.symbol.value, symbolDecl.doc.value);
}
for (PropDeclarationContext prop : symbolDecl.props) {
String symbol = symbolDecl.symbol.value;
Object value = parsePropValue(prop);
if (prop.name.equals("deprecated")) {
deprecatedSymbols.put(symbol, value);
} else {
List<String> path = new ArrayList<>(prop.path);
path.add(0, symbol);
addPropertiesAtPath(prop, symbolProperties, path, value);
}
}
}
schema.setSymbols(symbols, errorMessageBuilder());
if (symbolDocs.size() > 0) {
schema.setSymbolDocs(symbolDocs, errorMessageBuilder());
}
if (deprecatedSymbols.size() > 0) {
props.put("deprecatedSymbols", deprecatedSymbols);
}
if (symbolProperties.size() > 0) {
props.put("symbolProperties", symbolProperties);
}
schema.setProperties(props);
return schema;
}
use of com.linkedin.data.schema.Name in project rest.li by linkedin.
the class TestActionArgumentBuilder method getEnumParams.
private List<Parameter<?>> getEnumParams() {
EnumDataSchema simpleEnumSchema = new EnumDataSchema(new Name("com.linkedin.restli.common.test.SimpleEnum"));
simpleEnumSchema.setSymbols(Arrays.asList("A", "B", "C"), null);
return Collections.<Parameter<?>>singletonList(new Parameter<SimpleEnum>("simpleEnum", SimpleEnum.class, simpleEnumSchema, false, null, Parameter.ParamType.POST, true, new AnnotationSet(new Annotation[] {})));
}
Aggregations