List of usage examples for java.lang Boolean TYPE
Class TYPE
To view the source code for java.lang Boolean TYPE.
Click Source Link
From source file:Main.java
public static boolean modifyPermissionAutoStart(Context context, boolean enable) { try {//from w w w .j a va 2 s. c o m Class cls = Class.forName("android.miui.AppOpsUtils"); if (cls != null) { Method declaredMethod = cls.getDeclaredMethod("setApplicationAutoStart", new Class[] { Context.class, String.class, Boolean.TYPE }); if (declaredMethod != null) { declaredMethod.invoke(cls, new Object[] { context, context.getPackageName(), Boolean.valueOf(enable) }); return true; } } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:Main.java
public static boolean isConvertible(Class<?> srcPrimitive, Class<?> tgtPrimitive) { if (Boolean.TYPE.equals(srcPrimitive)) { return Boolean.TYPE.equals(tgtPrimitive); } else if (Byte.TYPE.equals(tgtPrimitive)) { return Byte.TYPE.equals(tgtPrimitive) || Short.TYPE.equals(tgtPrimitive) || Integer.TYPE.equals(tgtPrimitive) || Long.TYPE.equals(tgtPrimitive) || Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); } else if (Character.TYPE.equals(srcPrimitive)) { return Character.TYPE.equals(tgtPrimitive) || Integer.TYPE.equals(tgtPrimitive) || Long.TYPE.equals(tgtPrimitive) || Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); } else if (Double.TYPE.equals(srcPrimitive)) { return Double.TYPE.equals(tgtPrimitive); } else if (Float.TYPE.equals(srcPrimitive)) { return Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); } else if (Integer.TYPE.equals(srcPrimitive)) { return Integer.TYPE.equals(tgtPrimitive) || Long.TYPE.equals(tgtPrimitive) || Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); } else if (Long.TYPE.equals(srcPrimitive)) { return Long.TYPE.equals(tgtPrimitive) || Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); } else if (Short.TYPE.equals(srcPrimitive)) { return Short.TYPE.equals(tgtPrimitive) || Integer.TYPE.equals(tgtPrimitive) || Long.TYPE.equals(tgtPrimitive) || Float.TYPE.equals(tgtPrimitive) || Double.TYPE.equals(tgtPrimitive); }// ww w.ja va 2s .co m return false; }
From source file:PrimitiveUtils.java
public static Object read(String value, Class type) { Object ret = value;/*from w w w .jav a 2 s. com*/ if (Integer.TYPE.equals(type)) { ret = Integer.valueOf(value); } if (Byte.TYPE.equals(type)) { ret = Byte.valueOf(value); } if (Short.TYPE.equals(type)) { ret = Short.valueOf(value); } if (Long.TYPE.equals(type)) { ret = Long.valueOf(value); } if (Float.TYPE.equals(type)) { ret = Float.valueOf(value); } if (Double.TYPE.equals(type)) { ret = Double.valueOf(value); } if (Boolean.TYPE.equals(type)) { ret = Boolean.valueOf(value); } if (Character.TYPE.equals(type)) { ret = value.charAt(0); } // TODO others. return ret; }
From source file:Main.java
public static ContentValues objectToContentValues(Object object) { if (object == null) { throw new IllegalArgumentException("please check your argument"); }/*w w w. j ava 2 s . com*/ ContentValues contentValues = new ContentValues(); try { Field[] fields = object.getClass().getDeclaredFields(); for (Field field : fields) { String fieldName = field.getName(); Type type = field.getType(); field.setAccessible(true); if (type.equals(String.class)) { contentValues.put(fieldName, field.get(object).toString()); } else if (type.equals(Integer.class) || type.equals(Integer.TYPE)) { contentValues.put(fieldName, field.getInt(object)); } else if (type.equals(Float.class) || type.equals(Float.TYPE)) { contentValues.put(fieldName, field.getFloat(object)); } else if (type.equals(Long.class) || type.equals(Long.TYPE)) { contentValues.put(fieldName, field.getLong(object)); } else if (type.equals(Double.class) || type.equals(Double.TYPE)) { contentValues.put(fieldName, field.getDouble(object)); } else if (type.equals(Boolean.class) || type.equals(Boolean.TYPE)) { contentValues.put(fieldName, field.getBoolean(object)); } } } catch (IllegalAccessException | IllegalArgumentException e) { e.printStackTrace(); } return contentValues; }
From source file:sim.portrayal.inspector.TimeSeriesChartingPropertyInspector.java
public static Class[] types() { return new Class[] { Number.class, Boolean.TYPE, Byte.TYPE, Short.TYPE, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE, Valuable.class }; }
From source file:Main.java
public static void setDataEnabled(Context context, boolean enabled) { ConnectivityManager conMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); Class<?> conMgrClass = null; Field iConMgrField = null;/* w w w . ja v a2 s . c o m*/ Object iConMgr = null; Class<?> iConMgrClass = null; Method setMobileDataEnabledMethod = null; try { conMgrClass = Class.forName(conMgr.getClass().getName()); iConMgrField = conMgrClass.getDeclaredField("mService"); iConMgrField.setAccessible(true); iConMgr = iConMgrField.get(conMgr); iConMgrClass = Class.forName(iConMgr.getClass().getName()); setMobileDataEnabledMethod = iConMgrClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE); setMobileDataEnabledMethod.setAccessible(true); setMobileDataEnabledMethod.invoke(iConMgr, enabled); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
private static Class<?> getPrimitive(Class<?> argClass) { if (argClass == Boolean.class) return Boolean.TYPE; else if (argClass == Character.class) return Character.TYPE; else if (argClass == Byte.class) return Byte.TYPE; else if (argClass == Short.class) return Short.TYPE; else if (argClass == Integer.class) return Integer.TYPE; else if (argClass == Long.class) return Long.TYPE; else if (argClass == Float.class) return Float.TYPE; else if (argClass == Double.class) return Double.TYPE; else//from w ww . j a va 2 s .c om return null; }
From source file:Main.java
public static String getTypeForField(Field field) { Class type = field.getType(); // Animation//w w w . j a v a 2 s .c om if (type.isAssignableFrom(Animation.class)) return "anim"; // Color State List else if (type.isAssignableFrom(ColorStateList.class)) return "color"; // Drawable else if (type.isAssignableFrom(Drawable.class)) return "drawable"; // String else if (type.isAssignableFrom(String.class)) return "string"; // String Array else if (type.isArray()) return "array"; // TODO: Recognize plural strings if possible // else if (type.isAssignableFrom(String.class)) // return "plural"; // Boolean else if (type.isAssignableFrom(Boolean.TYPE) || type.isAssignableFrom(Boolean.class)) return "bool"; // Integer else if (type.isAssignableFrom(Integer.TYPE) || type.isAssignableFrom(Integer.class)) return "integer"; // Dimen else if (type.isAssignableFrom(Float.TYPE) || type.isAssignableFrom(Float.class)) return "dimen"; throw new RuntimeException("No suitable type found for " + field.getName() + "of class " + type.getName()); }
From source file:com.alibaba.doris.admin.service.impl.ValueParseUtil.java
/** * ?,?,/*from w w w . j a v a 2 s.c o m*/ * * @param clazz * @return */ @SuppressWarnings("unchecked") private static <T> T getInternalDefaultValue(Class<T> clazz) { if (!clazz.isPrimitive()) { return null; } if (Short.TYPE.equals(clazz)) { return (T) Short.valueOf((short) 0); } if (Integer.TYPE.equals(clazz)) { return (T) Integer.valueOf(0); } if (Long.TYPE.equals(clazz)) { return (T) Long.valueOf(0); } if (Boolean.TYPE.equals(clazz)) { return (T) Boolean.valueOf(false); } if (Float.TYPE.equals(clazz)) { return (T) Float.valueOf(0); } if (Double.TYPE.equals(clazz)) { return (T) Double.valueOf(0); } if (Byte.TYPE.equals(clazz)) { return (T) Byte.valueOf((byte) 0); } if (Character.TYPE.equals(clazz)) { return (T) Character.valueOf('\0'); } return null; }
From source file:Main.java
private static Class<?>[] getArgsClasses(Object[] paramArrayOfObject) { Class[] arrayOfClass = null;//from w w w . j ava2 s. c o m if (paramArrayOfObject != null) { arrayOfClass = new Class[paramArrayOfObject.length]; for (int i = 0; i < paramArrayOfObject.length; ++i) { if (paramArrayOfObject[i] != null) { arrayOfClass[i] = paramArrayOfObject[i].getClass(); if (arrayOfClass[i] == Integer.class) { arrayOfClass[i] = Integer.TYPE; } else if (arrayOfClass[i] != String.class) { if (arrayOfClass[i] == Boolean.class) { arrayOfClass[i] = Boolean.TYPE; } else if (arrayOfClass[i] == Long.class) { arrayOfClass[i] = Long.TYPE; } } } } } return arrayOfClass; }