PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/data/jpa/src/test/java/org/appfuse/dao/jpa/mock/MockRoleBadGetter.java

https://gitlab.com/udarnick/appfuse
Java | 84 lines | 58 code | 20 blank | 6 comment | 6 complexity | 4b0ae7fc4f03c1833858c649b1990bf3 MD5 | raw file
  1. package org.appfuse.dao.jpa.mock;
  2. import org.apache.commons.lang.builder.ToStringBuilder;
  3. import org.apache.commons.lang.builder.ToStringStyle;
  4. import javax.persistence.Column;
  5. import javax.persistence.GeneratedValue;
  6. import javax.persistence.GenerationType;
  7. import javax.persistence.Id;
  8. import javax.persistence.Transient;
  9. /**
  10. * @author <a href="mailto:bwnoll@gmail.com">Bryan Noll</a>
  11. */
  12. public class MockRoleBadGetter {
  13. private static final long serialVersionUID = 3690197650654049848L;
  14. @Id @GeneratedValue(strategy=GenerationType.AUTO)
  15. private Long id;
  16. private String name;
  17. private String description;
  18. public MockRoleBadGetter() {
  19. }
  20. public MockRoleBadGetter(String name) {
  21. this.name = name;
  22. }
  23. public Long getPersistentId() {
  24. return id;
  25. }
  26. /**
  27. * @see org.springframework.security.core.GrantedAuthority#getAuthority()
  28. */
  29. @Transient
  30. public String getAuthority() {
  31. return getName();
  32. }
  33. @Column(length=20)
  34. public String getName() {
  35. return this.name;
  36. }
  37. @Column(length=64)
  38. public String getDescription() {
  39. return this.description;
  40. }
  41. public void setPersistentId(Long id) {
  42. this.id = id;
  43. }
  44. public void setName(String name) {
  45. this.name = name;
  46. }
  47. public void setDescription(String description) {
  48. this.description = description;
  49. }
  50. public boolean equals(Object o) {
  51. if (this == o) return true;
  52. if (!(o instanceof MockRoleBadGetter)) return false;
  53. final MockRoleBadGetter role = (MockRoleBadGetter) o;
  54. return !(name != null ? !name.equals(role.name) : role.name != null);
  55. }
  56. public int hashCode() {
  57. return (name != null ? name.hashCode() : 0);
  58. }
  59. public String toString() {
  60. return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
  61. .append(this.name)
  62. .toString();
  63. }
  64. }