List of usage examples for java.lang Object getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:Main.java
/** * Returns an empty array of the specified type. The intent is that * it will return the same empty array every time to avoid reallocation, * although this is not guaranteed.//from w w w .j av a2 s . c o m */ @SuppressWarnings("unchecked") public static <T> T[] emptyArray(final Class<T> kind) { if (kind == Object.class) { return (T[]) EMPTY; } final int bucket = ((System.identityHashCode(kind) / 8) & 0x7FFFFFFF) % CACHE_SIZE; Object cache = sCache[bucket]; if (cache == null || cache.getClass().getComponentType() != kind) { cache = Array.newInstance(kind, 0); sCache[bucket] = cache; // Log.e("cache", "new empty " + kind.getName() + " at " + bucket); } return (T[]) cache; }
From source file:Main.java
/** * Returns an empty array of the specified type. The intent is that * it will return the same empty array every time to avoid reallocation, * although this is not guaranteed./*from ww w . ja v a 2s . com*/ */ @SuppressWarnings("unchecked") public static <T> T[] emptyArray(Class<T> kind) { if (kind == Object.class) { return (T[]) EMPTY; } int bucket = ((System.identityHashCode(kind) / 8) & 0x7FFFFFFF) % CACHE_SIZE; Object cache = sCache[bucket]; if (cache == null || cache.getClass().getComponentType() != kind) { cache = Array.newInstance(kind, 0); sCache[bucket] = cache; // Log.e("cache", "new empty " + kind.getName() + " at " + bucket); } return (T[]) cache; }
From source file:Main.java
public static Object newInstance(Object model) { Object instance = null;//from w w w. j a v a 2 s.c o m try { Class<?> aClass = model.getClass(); instance = aClass.newInstance(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } return instance; }
From source file:Main.java
public static boolean hasAnnotation(Class<? extends Annotation> annotation, Object object, String methodName) { try {/*from w w w .j av a 2s. c o m*/ Class<? extends Object> c = object.getClass(); for (Method m : c.getMethods()) { if (m.getName().equals(methodName)) { if (m.isAnnotationPresent(annotation)) { return true; } } } } catch (Exception e) { } return false; }
From source file:org.makersoft.activesql.persistence.MyBatisContext.java
public static int insert(Object parameter) { return sqlSession.insert(parameter.getClass().getName() + ".insert", parameter); }
From source file:org.makersoft.activesql.persistence.MyBatisContext.java
public static int update(Object parameter) { return sqlSession.update(parameter.getClass().getName() + ".update", parameter); }
From source file:org.makersoft.activesql.persistence.MyBatisContext.java
public static int delete(Object parameter) { return sqlSession.delete(parameter.getClass().getName() + ".delete", parameter); }
From source file:Main.java
/** * Returns an empty array of the specified type. The intent is that * it will return the same empty array every time to avoid reallocation, * although this is not guaranteed.//from w ww. ja v a2 s .c o m */ @SuppressWarnings("unchecked") public static <T> T[] emptyArray(Class<T> kind) { if (kind == Object.class) { // return (T[]) EmptyArray.OBJECT; return (T[]) new Object[0]; } int bucket = (kind.hashCode() & 0x7FFFFFFF) % CACHE_SIZE; Object cache = sCache[bucket]; if (cache == null || cache.getClass().getComponentType() != kind) { cache = Array.newInstance(kind, 0); sCache[bucket] = cache; // Log.e("cache", "new empty " + kind.getName() + " at " + bucket); } return (T[]) cache; }
From source file:Main.java
public static void saveInstance(File outputFile, Object instance) throws JAXBException, IOException { Marshaller marshaller = JAXBContext.newInstance(instance.getClass()).createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(instance, outputFile); }
From source file:Book.java
public static void printDetails(ReadOnlyProperty<?> p) { String name = p.getName();/*from w w w.j a v a 2 s. c o m*/ Object value = p.getValue(); Object bean = p.getBean(); String beanClassName = (bean == null) ? "null" : bean.getClass().getSimpleName(); String propClassName = p.getClass().getSimpleName(); System.out.print(propClassName); System.out.print("[Name:" + name); System.out.print(", Bean Class:" + beanClassName); System.out.println(", Value:" + value + "]"); }