135136137138139140141142143144145146
if (attr.getName().equals(name)) { attr.setValue(value); return; } } RealmAttributeEntity attr = new RealmAttributeEntity(); attr.setName(name); attr.setValue(value); attr.setRealm(realm); em.persist(attr); realm.getAttributes().add(attr); }
158159160161162163164165166167168169
} public void removeAttribute(String name) { Iterator<RealmAttributeEntity> it = realm.getAttributes().iterator(); while (it.hasNext()) { RealmAttributeEntity attr = it.next(); if (attr.getName().equals(name)) { it.remove(); em.remove(attr); } } }