Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/com/github/rjeschke/neetutils/Objects.java

Issue 6606493159784448: New JNI bindings (Closed)
Patch Set: Removed TODO from AppInfo. Created April 11, 2014, 1:28 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « jni/Utils.cpp ('k') | src/com/github/rjeschke/neetutils/collections/Tuple.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/com/github/rjeschke/neetutils/Objects.java
diff --git a/src/com/github/rjeschke/neetutils/Objects.java b/src/com/github/rjeschke/neetutils/Objects.java
new file mode 100644
index 0000000000000000000000000000000000000000..aa2ba1ab4969948d0d06acbbbd7cd454f0dde470
--- /dev/null
+++ b/src/com/github/rjeschke/neetutils/Objects.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2012 René Jeschke <rene_jeschke@yahoo.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.github.rjeschke.neetutils;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @author René Jeschke (rene_jeschke@yahoo.de)
+ */
+public final class Objects
+{
+ private Objects()
+ {
+ //
+ }
+
+ @Deprecated
+ public final static boolean implementsInterface(final Object o, final Class<?> interfaceClass)
+ {
+ return implementsInterface(o.getClass(), interfaceClass);
+ }
+
+ @Deprecated
+ public final static boolean implementsInterface(final Class<?> clazz, final Class<?> interfaceClass)
+ {
+ if (clazz.equals(interfaceClass))
+ {
+ return true;
+ }
+ final Class<?>[] is = clazz.getInterfaces();
+ for (int i = 0; i < is.length; i++)
+ {
+ if (is[i].equals(interfaceClass))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public final static boolean isString(final Object o)
+ {
+ return o instanceof String;
+ }
+
+ public final static boolean isBoolean(final Object o)
+ {
+ return o instanceof Boolean;
+ }
+
+ public final static boolean isNumber(final Object o)
+ {
+ return o instanceof Number;
+ }
+
+ public final static boolean isMap(final Object o)
+ {
+ return o instanceof Map;
+ }
+
+ public final static boolean isList(final Object o)
+ {
+ return o instanceof List;
+ }
+
+ public final static boolean isCollection(final Object o)
+ {
+ return o instanceof Collection;
+ }
+
+ public final static boolean equals(final Object a, final Object b)
+ {
+ if (a == b)
+ {
+ return true;
+ }
+
+ if (a == null)
+ {
+ return b == null;
+ }
+
+ if (a.getClass() != b.getClass())
+ {
+ return false;
+ }
+
+ return a.equals(b);
+ }
+
+ public final static boolean isNullOrEmpty(final Object obj)
+ {
+ if (obj == null)
+ {
+ return true;
+ }
+
+ if (obj instanceof Collection)
+ {
+ return ((Collection<?>)obj).isEmpty();
+ }
+ if (obj instanceof Map)
+ {
+ return ((Map<?, ?>)obj).isEmpty();
+ }
+ if (obj instanceof String)
+ {
+ return ((String)obj).length() == 0;
+ }
+
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ public final static <A> A uncheckedCast(final Object a)
+ {
+ return (A)a;
+ }
+}
« no previous file with comments | « jni/Utils.cpp ('k') | src/com/github/rjeschke/neetutils/collections/Tuple.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld