@Override protected V _adapt(U value) throws UnsupportedOperationException { if(read!=null) return read.adapt(value); throw new UnsupportedOperationException("No cached value available for reverse-operation value "+value); }
@Override protected U _reAdapt(V value) throws UnsupportedOperationException { if(write!=null) return write.adapt(value); throw new UnsupportedOperationException("No cached value available for reverse-operation value "+value); }
public String getLibrary(String elementFile, Identifier elementName) { if (elementName != null) { String libraryOverride = libraryOverrides.get(elementName.toString()); if (libraryOverride != null) { return libraryOverride; } } if (elementFile == null) { return libraryForElementsInNullFile; } return fileToLibrary == null ? defaultLibrary : fileToLibrary.adapt(new File(elementFile)); } Set<File> sourceFiles = new LinkedHashSet<File>();
public static String regexReplace(Pattern pattern, String string, Adapter<String[], String> adapter) { StringBuffer b=new StringBuffer(string.length()); int iLastCommitted=0; Matcher matcher=pattern.matcher(string); while (matcher.find(iLastCommitted)) { int start=matcher.start(); String s = string.substring(iLastCommitted,start); String g = matcher.group(0); b.append(s); if (adapter!=null) b.append(adapter.adapt(getGroups(matcher))); else b.append(g); iLastCommitted = start + g.length(); } b.append(string.substring(iLastCommitted)); return b.toString(); }
@Override public boolean add(final E e) { Pair<KEY,E>pair= pairs.get(e); if(pair!=null) return false; try{pair= new Pair<KEY,E>(propertyAdapter.adapt(new PropertyChangeEvent(e, propertyName, null, (PROPERTY_TYPE)PropertyUtils.getProperty(e, propertyName))),e);} catch(NoSuchMethodException ex){throw new IllegalArgumentException("Supplied element (bean) does not expose method for property: `"+propertyName+"`.");} catch(InvocationTargetException ex){throw new RuntimeException(ex);} catch(IllegalAccessException ex){throw new IllegalArgumentException("Supplied element (bean) does not allow access for property `"+propertyName+"`.",ex);} //listeners.put(e,propertyChangeListener); pairs.put(e,pair); e.addPropertyChangeListener(propertyName, elementPCL); assert pair!=null:"pair unexpectedly null."; delegate.add(pair); return true; }//end add(...)
@SuppressWarnings("unchecked") protected boolean removeWithoutBackWardAdapter(Object value) { try { currentlyCausingChange = true; if (collection.remove(backwardAdapter.adapt((V)value))) { if (collectionSupport != null && collectionSupport.hasListeners()) collectionSupport.fireRemoved(this, (Collection<V>)Collections.singleton(value)); return true; } return false; } finally { currentlyCausingChange = false; } }
@Override public boolean add(V value) { if (backwardAdapter == null) throw new UnsupportedOperationException("No backward adapter in this AdapterCollection"); try { currentlyCausingChange = true; if (collection.add(backwardAdapter.adapt(value))) { if (collectionSupport != null && collectionSupport.hasListeners()) collectionSupport.fireAdded(this, Collections.singleton(value)); return true; } return false; } finally { currentlyCausingChange = false; } }
file = file.getCanonicalFile(); if (library == null && fileToLibrary != null) { library = fileToLibrary.adapt(file);
@SuppressWarnings("unchecked") @Override public boolean remove(Object value) { if (backwardAdapter == null) { // Give index of removed element in collection event when it does not cost more // (simplifies subclassing as List, as for the remove method there is only the need to reimplement removeWithoutBackWardAdapter) int i = 0; for (Iterator<U> it = collection.iterator(); it.hasNext();) { if (forwardAdapter.adapt(it.next()).equals(value)) { try { currentlyCausingChange = true; it.remove(); if (collectionSupport != null && collectionSupport.hasListeners()) collectionSupport.fireRemoved(this, (Collection<V>)Collections.singleton(value), i, i); return true; } finally { currentlyCausingChange = false; } } i++; } return false; } else { return removeWithoutBackWardAdapter(value); } }
Runnable worker = new Runnable() { public void run() { for (;!Thread.interrupted();) { U value; synchronized (it) { if (!it.hasNext()) break; value = it.next(); } try { V mappedValue = mapper.adapt(value); synchronized (out) { out.add(mappedValue); } } catch (Throwable th) { synchronized (errorsOut) { errorsOut.add(new Pair<U, Throwable>(value, th)); } } //Thread.yield(); } }};
final DeclarationsHolder declarations, final DeclarationsHolder implementations, Identifier libraryClassName, int iConstructor) { if (result.config.functionsAccepter != null && !result.config.functionsAccepter.adapt(function)) { return;