Last active
August 29, 2015 13:56
-
-
Save ashwanthkumar/8949926 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Vehicle { | |
1: string name | |
2: string model | |
} | |
struct Person { | |
1: string name | |
2: i32 age | |
// Empty collections can be specified using []. Same works for map and set as well. | |
3: list<Vehicle> cars = [] | |
// Another way to specify default empty values | |
4: list<Vehicle> bikes = empty | |
} | |
// Reference - http://stackoverflow.com/a/12501037 | |
struct Family { | |
1: Person familyHead = {"name": "Father", "age":60} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
@Override | |
public void clear() { | |
this.familyHead = new Person(); | |
this.familyHead.setName("Father"); | |
this.familyHead.setAge(60); | |
} | |
.... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
@Override | |
public void clear() { | |
this.name = null; | |
setAgeIsSet(false); | |
this.age = 0; | |
this.cars = new ArrayList<Vehicle>(); | |
this.bikes = new ArrayList<Vehicle>(); | |
} | |
.... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment