1 24 package org.objectweb.jalisto.se.test.data; 25 26 import org.objectweb.jalisto.se.api.ClassDescription; 27 import org.objectweb.jalisto.se.JalistoFactory; 28 import org.objectweb.jalisto.se.impl.meta.type.MetaTypeFactory; 29 30 public class Client { 31 32 private Client() { 33 } 34 35 private Client(String firstName, String lastName) { 36 this.firstName = firstName; 37 this.lastName = lastName; 38 } 39 40 public String getFirstName() { 41 return firstName; 42 } 43 44 public void setFirstName(String firstName) { 45 this.firstName = firstName; 46 } 47 48 public String getLastName() { 49 return lastName; 50 } 51 52 public void setLastName(String lastName) { 53 this.lastName = lastName; 54 } 55 56 public boolean equals(Object o) { 57 try { 58 Client candidate = (Client) o; 59 return (candidate.firstName.equals(firstName) && 60 candidate.lastName.equals(lastName)); 61 } catch (Exception e) { 62 } 63 return false; 64 } 65 66 public Object [] toArray() { 67 Object [] result = new Object [2]; 68 result[0] = firstName; 69 result[1] = lastName; 70 return result; 71 } 72 73 public static Client toClient(Object [] array) { 74 Client client = new Client(); 75 client.setFirstName((String ) array[0]); 76 client.setLastName((String ) array[1]); 77 return client; 78 } 79 80 public static ClassDescription getMetaDescription() { 81 ClassDescription meta = JalistoFactory.createClassDescription(Client.class.getName()); 82 meta.addField(JalistoFactory.createFieldDescription("firstName", MetaTypeFactory.StringType)); 83 meta.addField(JalistoFactory.createFieldDescription("lastName", MetaTypeFactory.StringType)); 84 return meta; 85 } 86 87 public static Client newClient() { 88 counter++; 89 return new Client(getNewFirstName(counter), getNewLastName(counter)); 90 } 91 92 private static String getNewFirstName(int c) { 93 return firstNames[c % firstNames.length]; 94 } 95 96 private static String getNewLastName(int c) { 97 return lastNames[c % lastNames.length]; 98 } 99 100 private String firstName; 101 private String lastName; 102 103 public static int counter = -1; 104 105 public static final String [] firstNames = {"Katharina", 106 "Sigourney", 107 "Winona", 108 "Jody", 109 "Famke"}; 110 111 public static final String [] lastNames = {"Hepburn", 112 "Weaver", 113 "Rider", 114 "Foster", 115 "Janssen", 116 "Seymour", 117 "Scott Thommas", 118 "Harlow", 119 "Kruegger", 120 "Sastre", 121 "Pfeiffer", 122 "Jovovitch", 123 "Valetta"}; 124 } 125 | Popular Tags |