Created
October 24, 2012 12:02
-
-
Save nakamura-to/3945704 to your computer and use it in GitHub Desktop.
An Embedded Value implementation in Doma
This file contains 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
import org.seasar.doma.Entity; | |
import org.seasar.doma.Id; | |
@Entity | |
public class Dept { | |
@Id | |
private Integer id; | |
private String name; | |
private String city; | |
private int x; | |
private int y; | |
public Integer getId() { | |
return id; | |
} | |
public void setId(Integer id) { | |
this.id = id; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public Location getLocation() { | |
return new Location(city, new Point(x, y)); | |
} | |
public void setLocation(Location location) { | |
this.city = location.getCity(); | |
this.x = location.getPoint().getX(); | |
this.y = location.getPoint().getY(); | |
} | |
} |
This file contains 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
public class Location { | |
private String city; | |
private Point point; | |
public Location(String city, Point point) { | |
this.city = city; | |
this.point = point; | |
} | |
public String getCity() { | |
return city; | |
} | |
public Point getPoint() { | |
return point; | |
} | |
} |
This file contains 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
public class Point { | |
private int x; | |
private int y; | |
public Point(int x, int y) { | |
this.x = x; | |
this.y = y; | |
} | |
public int getX() { | |
return x; | |
} | |
public int getY() { | |
return y; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment