Package com.motomapia

Source Code of com.motomapia.OfyLoader

/*
*/

package com.motomapia;

import static com.motomapia.OfyService.ofy;

import com.googlecode.objectify.impl.LoaderImpl;
import com.motomapia.entity.EmailLookup;
import com.motomapia.entity.Person;

/**
* Extend the Loader command with our own logic
*
* @author Jeff Schnitzer
*/
public class OfyLoader extends LoaderImpl<OfyLoader>
{
  /** */
  public OfyLoader(Ofy base) {
    super(base);
  }

  /**
   * Gets the Person associated with the email, or null if there is no association.
   */
  public Person personByEmail(String email) {
    if (email == null || email.trim().length() == 0)
      return null;

    EmailLookup lookup = email(email);
    if (lookup == null)
      return null;
    else
      return lookup.getPerson();
  }

  /**
   * Gets the EmailLookup, or null if the normalized email is not in the system.
   */
  public EmailLookup email(String email) {
    return ofy().load().type(EmailLookup.class).id(EmailLookup.normalize(email)).now();
  }

}
TOP

Related Classes of com.motomapia.OfyLoader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.