3. The Friend bean

We need a data structure to keep the name, description, and URL for each of our friends. A bean will be a perfect container for that information, because a lot of the RIFE interfaces can work with beans instead of handling a lot of properties individually. This will be more and more obvious as we learn more.

Example 7.4. Friend bean class

package tutorial.friends.backend;
 
public class Friend
{
  private String  mFirstname = null;
  private String  mLastname = null;
  private String  mDescription = null;
  private String  mUrl = null;
 
  public Friend(String firstname, String lastname, String description, String url)
  {
    mFirstname = firstname;
    mLastname = lastname;
    mDescription = description;
    mUrl = url;
  }
      
  public void setFirstname(String firstname)
  {
    mFirstname = firstname;
  }
                                                                                                 
  public String getFirstname()
  {
    return mFirstname;
  }
      
  // ... and so on for lastName, description and url

}

The set and get methods for lastName, description and url are omitted from the snippet here to save some space, but they look just like firstName.