All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.objectify.condition.IfEmpty Maven / Gradle / Ivy

Go to download

*** THIS VERSION UPLOADED FOR USE WITH CEDAR-COMMON, TO AVOID DEPENDENCIES ON GOOGLE CODE-BASED MAVEN REPOSITORIES. *** The simplest convenient interface to the Google App Engine datastore

The newest version!
package com.googlecode.objectify.condition;

import java.util.Collection;
import java.util.Map;


/**
 * 

Simple If condition that returns true if the value is null or empty. * The value can be one of:

*
    *
  • java.lang.String
  • *
  • java.util.Collection
  • *
  • java.util.Map
  • *
* * @author Jeff Schnitzer */ public class IfEmpty extends ValueIf { @Override public boolean matches(Object value) { if (value == null) return true; if (value instanceof String) return ((String)value).isEmpty(); if (value instanceof Collection) return ((Collection)value).isEmpty(); if (value instanceof Map) return ((Map)value).isEmpty(); throw new IllegalArgumentException("Don't know what to do with something of type " + value.getClass().getName()); } }