@Test public void parseSuccess() throws Exception { Schema schema = TmlProcessor.build("src/test/resources/example-v2.tml"); Class person = (Class) schema .findType("class<com.expedia.tesla.example.Person>"); assertNotNull(person); assertEquals(Primitive.STRING, person.findField("Name").getType()); Primitive pbyte = (Primitive) schema.findType("byte"); assertEquals(Primitive.BYTE, pbyte); Nullable nullableByte = (Nullable) schema.findType("nullable<byte>"); assertEquals(pbyte, nullableByte.getElementType()); assertEquals(nullableByte, person.findField("Age").getType()); Enum sex = (Enum) schema.findType("enum<org.tesla.example.Sex>"); assertNotNull(sex); assertEquals(sex, person.findField("Sex").getType()); Class contact = (Class) schema .findType("class<com.expedia.tesla.example.Contact>"); assertNotNull(contact); Array contactArray = (Array) schema .findType("array<class<com.expedia.tesla.example.Contact>>"); assertNotNull(contactArray); assertEquals(contact, contactArray.getElementType()); assertEquals(contactArray, person.findField("Contacts").getType()); Collection<EnumEntry> sexValues = sex.getEntries(); assertEquals(2, sexValues.size()); assertEquals(1, sex.findEntry("Male").getValue()); assertEquals(2, sex.findEntry("Female").getValue()); assertEquals("Male", sex.findEntry("Male").getName()); assertEquals("Female", sex.findEntry("Female").getName()); Class employee = (Class) schema .findType("class<com.expedia.tesla.example.Employee>"); assertNotNull(employee); assertEquals(person, employee.getBases().get(0)); assertEquals(Primitive.STRING, employee.findField("Title").getType()); }
public static Schema build(String path) throws TeslaSchemaException, IOException { Collection<Object> types = TmlProcessor.load(path); long hash = TmlProcessor.getSchemaHash(path); Tml.Version ver = TmlGraph.unmarshallTml(new File(path)).getVersion(); return TmlProcessor.build(types, new SchemaVersion(hash, ver.getNumber() == null ? (short) 0 : ver.getNumber().shortValue(), ver.getName(), path)); }
TmlProcessor { public static Schema build(String path) throws TeslaSchemaException, IOException { Collection<Object> types = TmlProcessor.load(path); long hash = TmlProcessor.getSchemaHash(path); Tml.Version ver = TmlGraph.unmarshallTml(new File(path)).getVersion(); return TmlProcessor.build(types, new SchemaVersion(hash, ver.getNumber() == null ? (short) 0 : ver.getNumber().shortValue(), ver.getName(), path)); } }
TmlProcessor { public static Schema build(String path) throws TeslaSchemaException, IOException { Collection<Object> types = TmlProcessor.load(path); long hash = TmlProcessor.getSchemaHash(path); Tml.Version ver = TmlGraph.unmarshallTml(new File(path)).getVersion(); return TmlProcessor.build(types, new SchemaVersion(hash, ver.getNumber() == null ? (short) 0 : ver.getNumber().shortValue(), ver.getName(), path)); }  }
TmlProcessor { public static Schema build(String path) throws TeslaSchemaException, IOException { Collection<Object> types = TmlProcessor.load(path); long hash = TmlProcessor.getSchemaHash(path); Tml.Version ver = TmlGraph.unmarshallTml(new File(path)).getVersion(); return TmlProcessor.build(types, new SchemaVersion(hash, ver.getNumber() == null ? (short) 0 : ver.getNumber().shortValue(), ver.getName(), path)); }  static Collection<Object> load(String path); static void save(Schema schema, OutputStream os); static void save(List<Object> userTypes, OutputStream os,
			String versionName, int versionNumber); static Tml unmarshalTml(String path); static long getSchemaHash(String filename); static Schema build(String path); static Schema build(Collection<Object> types, SchemaVersion ver); }
TmlProcessor { public static Schema build(String path) throws TeslaSchemaException, IOException { Collection<Object> types = TmlProcessor.load(path); long hash = TmlProcessor.getSchemaHash(path); Tml.Version ver = TmlGraph.unmarshallTml(new File(path)).getVersion(); return TmlProcessor.build(types, new SchemaVersion(hash, ver.getNumber() == null ? (short) 0 : ver.getNumber().shortValue(), ver.getName(), path)); }  static Collection<Object> load(String path); static void save(Schema schema, OutputStream os); static void save(List<Object> userTypes, OutputStream os,
			String versionName, int versionNumber); static Tml unmarshalTml(String path); static long getSchemaHash(String filename); static Schema build(String path); static Schema build(Collection<Object> types, SchemaVersion ver);  }