private static <T extends PersistentBase> T getPersistent(T persitent, String[] fields) { List<Schema.Field> otherFields = persitent.getSchema().getFields(); String[] otherFieldStrings = new String[otherFields.size()]; for (int i = 0; i < otherFields.size(); i++) { otherFieldStrings[i] = otherFields.get(i).name(); } if (Arrays.equals(fields, otherFieldStrings)) { return persitent; } T clonedPersistent = AvroUtils.deepClonePersistent(persitent); clonedPersistent.clear(); if (fields != null && fields.length > 0) { for (String field : fields) { Schema.Field otherField = persitent.getSchema().getField(field); int index = otherField.pos(); clonedPersistent.put(index, persitent.get(index)); } } else { for (String field : otherFieldStrings) { Schema.Field otherField = persitent.getSchema().getField(field); int index = otherField.pos(); clonedPersistent.put(index, persitent.get(index)); } } return clonedPersistent; }
/** Clears all items in this group */ public synchronized void clear() { if (this.children != null) { isLoading = true; for (T item : getItems()) { item.clear(); } this.children.clear(); } }
@Override public void clear() { if (!isEnabled()) return; lock.acquireExclusiveLock(); try { cache.clear(); } finally { lock.releaseExclusiveLock(); } }
protected void testClear(final T queue) { System.out.println("=== testClear"); assertSize(0, queue); final String value = "value"; queue.enqueue(value); queue.enqueue(value); queue.clear(); assertSize(0, queue); final String value1 = "value1"; queue.enqueue(value1); assertEquals("deque()", value1, queue.dequeue()); }
@Override public void clear() { myPrimaryConsoleView.clear(); mySecondaryConsoleView.clear(); }
private void updateGroup(NodeList set) { try { List<T> newChildren = new ArrayList<T>(); if (requireUniqueIds) { synchronized (this) { newChildren.addAll(this.children); } } List<String> ids = new ArrayList<String>(); for (int i = 0; i < set.getLength(); i++) { T groupItem = null; boolean newItem = true; if (requireUniqueIds) { String id = getTextContent(ID_ELEMENT, set.item(i)); if (id != null && id.length() > 0) { ids.add(id); for (T item : this.children) { if (id.equals(item.getId())) { groupItem = item; newItem = false; break; } } if (groupItem == null) { groupItem = createItem(); if (requireUniqueIds) { groupItem.setId(id); } } } } else { groupItem = createItem(); } if (groupItem != null) { groupItem.suspendEvents(); groupItem.setLogger(getLogger()); groupItem.addListeners(getListeners()); groupItem.fromNode(set.item(i)); configureItem(groupItem); if (newItem && shouldAdd(groupItem)) { newChildren.add(groupItem); groupItem.fireChange(); } groupItem.resumeEvents(); } } if (requireUniqueIds) { Iterator<T> iterator = newChildren.iterator(); while (iterator.hasNext()) { T removedItem = iterator.next(); if (!ids.contains(removedItem.getId())) { iterator.remove(); removedItem.clear(); } } } synchronized (this) { this.children = newChildren; } } catch (Exception e1) { String message = MessageFormat.format( Messages.getString("CoreGroupObject.XPath_Error_During_Parse"), // $NON-NLS-1$ new Object[] {getLoggingPrefix(), e1.getMessage()}); logError(message); } finally { isLoading = false; } }
/** * Drops a particular Big Map. * * @param <T> * @param name * @param map */ @Override public <T extends Map> void dropBigMap(String name, T map) { ensureNotClosed(); map.clear(); }