Tabnine Logo
com.googlecode.objectify
Code IndexAdd Tabnine to your IDE (free)

How to use com.googlecode.objectify

Best Java code snippets using com.googlecode.objectify (Showing top 20 results out of 315)

origin: objectify/objectify

/** Creates a Ref from a registered pojo entity */
public static <T> Ref<T> create(T value) {
  Key<T> key = Key.create(value);
  return create(key);
}
origin: objectify/objectify

  /**
   * Callback that we found a Ref in the object graph. Subclasses of this context may want to do something
   * special with this.
   */
  public Key saveRef(final Ref<?> value, final LoadConditions loadConditions) {
    return value.key().getRaw();
  }
}
origin: objectify/objectify

/**
 * You can extend the servlet and override this method if you are doing something unusual with the factory.
 */
protected EntityMemcacheStats getMemcacheStats() {
  return ObjectifyService.factory().getMemcacheStats();
}
 
origin: objectify/objectify

  /**
   * Like now(), but throws NotFoundException instead of returning null.
   * @throws NotFoundException if the loaded value was not found
   */
  public final T safe() throws NotFoundException {
    T t = now();
    if (t == null)
      throw new NotFoundException(key);
    else
      return t;
  }
}
origin: objectify/objectify

/**
 * A shortcut for {@code factory().register()}
 *  
 * @see ObjectifyFactory#register(Class) 
 */
public static void register(Class<?> clazz) {
  factory().register(clazz); 
}
origin: objectify/objectify

  @Override
  public T apply(Result<T> input) {
    return input.now();
  }
}
origin: objectify/objectify

  @Override
  public Key<?> fromString(String str) {
    return Key.create(str);
  }
}
origin: objectify/objectify

  /**
   * <p>An alternative to run() which is somewhat easier to use with testing (ie, @Before and @After) frameworks.
   * You must close the return value at the end of the request in a finally block. It's better/safer to use run().</p>
   *
   * <p>This method is not typically necessary - in a normal request, the ObjectifyFilter takes care of this housekeeping
   * for you. However, in unit tests or remote API calls it can be useful.</p>
   */
  public static Closeable begin() {
    return factory().open();
  }
}
origin: objectify/objectify

/**
 * The method to call at any time to get the current Objectify, which may change depending on txn context
 */
public static Objectify ofy() {
  return factory().ofy();
}
origin: objectify/objectify

/**
 * Obtain the entity value, throwing an exception if the entity was not found.
 *
 * @return the entity referenced. Never returns null.
 * @throws NotFoundException if the specified entity was not found
 */
final public T safe() throws NotFoundException {
  T t = this.get();
  if (t == null)
    throw new NotFoundException(key());
  else
    return t;
}
origin: objectify/objectify

/**
 * Easy null-safe conversion of the typed key.
 */
public static com.google.cloud.datastore.Key key(final Key<?> typed) {
  if (typed == null)
    return null;
  else
    return typed.getRaw();
}
origin: objectify/objectify

/** Comparison is based on key */
@Override
public int compareTo(Ref<T> o) {
  return this.key().compareTo(o.key());
}
origin: objectify/objectify

/** This is a shortcut for {@code ObjectifyService.init(new ObjectifyFactory())}*/
public static void init() {
  init(new ObjectifyFactory());
}
origin: objectify/objectify

/** Equality comparison is based on key equivalence */
@Override
public boolean equals(Object obj) {
  return obj != null && obj instanceof Ref && key().equals(((Ref<?>)obj).key());
}
origin: objectify/objectify

/** Hash code is simply that of key */
@Override
public int hashCode() {
  return key().hashCode();
}
origin: objectify/objectify

/** Type safe comparison for key equivalence */
public boolean equivalent(Key<T> other) {
  return key().equivalent(other);
}
origin: objectify/objectify

/**
 * This method exists to facilitate serialization via javabeans conventions. Unlike get(),
 * it will return null if isLoaded() is false.
 *
 * @return the entity referenced, or null if either the entity was not found or isLoaded() is false.
 */
final public T getValue() {
  return isLoaded() ? get() : null;
}
origin: objectify/objectify

/**
 * Same as key() but conforms to JavaBeans conventions in case this is being processed by a JSON
 * converter or expression language.
 */
final public Key<T> getKey() {
  return key();
}
origin: objectify/objectify

/**
 * Easy null-safe conversion of the raw key.
 */
public static <V> Key<V> key(final com.google.cloud.datastore.Key raw) {
  if (raw == null)
    return null;
  else
    return new Key<>(raw);
}
origin: objectify/objectify

/** A type-safe equivalence comparison */
public boolean equivalent(final Ref<T> other) {
  return (other != null) && equals(other.key());
}
com.googlecode.objectify

Most used classes

  • ObjectifyService
    This is a simple container for a single static instance of ObjectifyFactory. You can choose to use t
  • Objectify
    This is the main "business end" of Objectify. It lets you get(), put(), delete(), and query() your t
  • Result
    This interface provides a return value for asynchronous Objectify calls, nearly the same as java.ut
  • Saver
  • Key
    A typesafe wrapper for the datastore Key object.
  • Loader,
  • Entity,
  • Deleter,
  • Id,
  • LoadType,
  • Query,
  • ObjectifyFactory,
  • Index,
  • Closeable,
  • Parent,
  • Unindex,
  • Ref,
  • AlsoLoad,
  • Cache
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now