@Test public void testEntityImplementsInterfaceParse() throws SyntaxError { String dsl = "INTERFACE User {" + " TEXT code *" + " NUMBER value" + " }" + " " + " ENTITY Test IMPLEMENTS User {" + " TEXT test *" + " }"; StringReader reader = new StringReader(dsl); RawSchema rawSchema = SchemaParser.parse(reader); Set<RawEntity> rawEntities = rawSchema.getRawEntities(); assertEquals(1, rawEntities.size()); Set<RawEntity> rawEntityInterfaces = rawSchema.getRawEntityInterfaces(); assertEquals(1, rawEntityInterfaces.size()); Map<String, RawEntity> rawModelsByName = rawSchema.getRawEntitiesByName(); RawEntity user = rawModelsByName.get("TEST"); Optional<RawEntity.Entry> test = user.getEntries().stream().filter(RawEntity.Entry::isLogicalKey).findAny(); assertTrue(test.isPresent()); RawEntity.Entry entry = test.get(); assertEquals("test", entry.getName()); }
private RawSchema parse() throws SyntaxError { RawSchemaBuilder rawSchemaBuilder = new RawSchemaBuilder(); nextToken(); while (currentToken != TokenType.EOF) { switch (currentToken) { case INTERFACE: rawSchemaBuilder.addInterface(parseEntity()); break; case ENTITY: rawSchemaBuilder.addEntity(parseEntity()); break; } } return rawSchemaBuilder.build(); }
SchemaParser { private RawSchema parse() throws SyntaxError { RawSchemaBuilder rawSchemaBuilder = new RawSchemaBuilder(); nextToken(); while (currentToken != TokenType.EOF) { switch (currentToken) { case INTERFACE: rawSchemaBuilder.addInterface(parseEntity()); break; case ENTITY: rawSchemaBuilder.addEntity(parseEntity()); break; } } return rawSchemaBuilder.build(); } }
SchemaParser { private RawSchema parse() throws SyntaxError { RawSchemaBuilder rawSchemaBuilder = new RawSchemaBuilder(); nextToken(); while (currentToken != TokenType.EOF) { switch (currentToken) { case INTERFACE: rawSchemaBuilder.addInterface(parseEntity()); break; case ENTITY: rawSchemaBuilder.addEntity(parseEntity()); break; } } return rawSchemaBuilder.build(); } private  SchemaParser(Reader r); }
SchemaParser { private RawSchema parse() throws SyntaxError { RawSchemaBuilder rawSchemaBuilder = new RawSchemaBuilder(); nextToken(); while (currentToken != TokenType.EOF) { switch (currentToken) { case INTERFACE: rawSchemaBuilder.addInterface(parseEntity()); break; case ENTITY: rawSchemaBuilder.addEntity(parseEntity()); break; } } return rawSchemaBuilder.build(); } private  SchemaParser(Reader r); static RawSchema parse(Reader r); }
SchemaParser { private RawSchema parse() throws SyntaxError { RawSchemaBuilder rawSchemaBuilder = new RawSchemaBuilder(); nextToken(); while (currentToken != TokenType.EOF) { switch (currentToken) { case INTERFACE: rawSchemaBuilder.addInterface(parseEntity()); break; case ENTITY: rawSchemaBuilder.addEntity(parseEntity()); break; } } return rawSchemaBuilder.build(); } private  SchemaParser(Reader r); static RawSchema parse(Reader r);  }