@Override public Map<String, Object> serializeBean() { return U.map("relation", name, "ids", ids); }
@Override public synchronized Map<Object, Object> _extras() { if (extras == null) { extras = Collections.synchronizedMap(U.map()); } return extras; }
@Override public synchronized Map<Object, Object> _tmps() { if (tmps == null) { tmps = Collections.synchronizedMap(U.map()); } return tmps; }
public static String save(Object value) { Object ser = Beany.serialize(value); Class<?> cls = value != null ? value.getClass() : null; Map<String, Object> map = U.map("_", cls.getCanonicalName(), "v", ser); return jacksonStringify(map); }
public Map<String, Object> loadMetadata(InputStream in) { globalLock(); try { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line = reader.readLine(); U.must(line != null, "Missing meta-data at the first line in the database file!"); Map<String, Object> meta = U.map(); data.serializer.deserialize(line.getBytes(), meta); reader.close(); return meta; } catch (IOException e) { throw new RuntimeException("Cannot load meta-data from database!", e); } finally { globalUnlock(); } }
public static <E> E entity(Class<E> entityType, String prop1, Object value1, String prop2, Object value2, String prop3, Object value3, String prop4, Object value4, String prop5, Object value5) { return schema().entity(entityType, U.map(prop1, value1, prop2, value2, prop3, value3, prop4, value4, prop5, value5)); }
public static <E> E entity(Class<E> entityType, String prop1, Object value1, String prop2, Object value2, String prop3, Object value3, String prop4, Object value4) { return schema().entity(entityType, U.map(prop1, value1, prop2, value2, prop3, value3, prop4, value4)); }
public static <E> E entity(Class<E> entityType, String prop1, Object value1, String prop2, Object value2, String prop3, Object value3) { return schema().entity(entityType, U.map(prop1, value1, prop2, value2, prop3, value3)); }
public static <E> E entity(Class<E> entityType, String prop, Object value) { return schema().entity(entityType, U.map(prop, value)); }
public static <E> E entity(Class<E> entityType, String prop1, Object value1, String prop2, Object value2) { return schema().entity(entityType, U.map(prop1, value1, prop2, value2)); }
@Override public Object entity(String rql, Object... args) { String[] parts = rql.split(" "); String entityName = U.capitalized(parts[0]); Class<?> entityType = getEntityType(entityName); U.must(entityType != null, "Cannot find entity '%s'!", entityName); Map<String, Object> properties = U.map(); if (parts.length > 1) { String[] props = rql.substring(entityName.length() + 1).split("\\s*\\,\\s*"); int argIndex = 0; for (String prop : props) { String[] kv = prop.trim().split("\\s*=\\s*"); String key = kv[0]; Object value; if (kv.length > 1) { value = kv[1].equals("?") ? args[argIndex++] : kv[1]; } else { value = true; } properties.put(key, value); } } return entity(entityType, properties); }