List of usage examples for org.apache.commons.lang3 ObjectUtils NULL
Null NULL
To view the source code for org.apache.commons.lang3 ObjectUtils NULL.
Click Source Link
Singleton used as a null placeholder where null has another meaning.
For example, in a HashMap the java.util.HashMap#get(java.lang.Object) method returns null if the Map contains null or if there is no matching key.
From source file:com.ebuddy.cassandra.structure.DecomposerTest.java
@Test(groups = "unit") public void decomposeSimpleObjectsWithSimplePaths() throws Exception { Map<Path, Object> structures = new HashMap<Path, Object>(); structures.put(DefaultPath.fromStrings("x"), ""); structures.put(DefaultPath.fromStrings("y"), 42); structures.put(DefaultPath.fromStrings("z"), true); structures.put(DefaultPath.fromStrings("N"), null); Map<Path, Object> result = decomposer.decompose(structures); assertNotSame(result, structures);//from w w w .j a v a 2 s . com // output of only simple objects is still equal to the input // with one exception, nulls are replaced by the NULL token structures.put(DefaultPath.fromStrings("N"), ObjectUtils.NULL); assertEquals(result, structures); }
From source file:com.ebuddy.cassandra.structure.DecomposerTest.java
@Test(groups = "unit") public void decomposeSimpleObjectsWithLongerPaths() throws Exception { Map<Path, Object> structures = new HashMap<Path, Object>(); structures.put(DefaultPath.fromEncodedPathString("a/b@/c"), ""); structures.put(DefaultPath.fromEncodedPathString("d/e#/f"), 42); structures.put(DefaultPath.fromEncodedPathString("g/h/i"), true); structures.put(DefaultPath.fromEncodedPathString("j/k/l"), null); Map<Path, Object> result = decomposer.decompose(structures); assertNotSame(result, structures);//from w w w . ja va 2 s . co m // output of only simple objects is equal to the input // except nulls are replaced by the NULL token. // Note that the special characters are not URL-encoded in input paths structures.put(DefaultPath.fromEncodedPathString("j/k/l"), ObjectUtils.NULL); assertEquals(result, structures); }
From source file:edu.umich.flowfence.service.SandboxManager.java
public synchronized int setMaxHotSpare(int count) { int oldCount = mMaxHotSpares; int newCount = Math.max(mMinHotSpares, Math.min(count, SANDBOX_COUNT)); Log.i(TAG, "Changing max hot spares from " + oldCount + " to " + newCount); dumpSandboxes();//from w ww .j a v a2s . co m mMaxHotSpares = newCount; while (mHotSpares.size() > mMaxHotSpares) { mIdleSandboxes.put(mHotSpares.remove(), ObjectUtils.NULL); } trimIdle(); return oldCount; }
From source file:edu.umich.flowfence.service.SandboxManager.java
public synchronized Sandbox tryGetSandboxById(final int id, final CallRecord record) { final Sandbox sb = Sandbox.get(id); if (localLOGD) { Log.d(TAG, "getSandboxById " + sb); }/*w ww .j a v a2 s . c o m*/ if (mRunningSandboxes.contains(sb)) { Log.i(TAG, "Explicitly requested sandbox " + sb + " busy"); return null; } if (mStoppedSandboxes.remove(sb)) { sb.start(this); } if (mHotSpares.remove(sb)) { refillHotSpares(); } // Put into mIdleSandboxes temporarily, beginExecution expects it. mIdleSandboxes.put(sb, ObjectUtils.NULL); if (record != null) { String packageName = record.getQM().getDescriptor().definingClass.getPackageName(); String assignedName = sb.getAssignedPackage(); if ((assignedName != null && !assignedName.equals(packageName)) || !record.getInboundTaints().isSubsetOf(sb.getTaints())) { // We need to restart this sandbox for security reasons. Log.i(TAG, "Restarting " + sb + " for explicit request"); sb.restart(); } } return sb; }
From source file:edu.umich.oasis.service.SandboxManager.java
public synchronized Sandbox tryGetSandboxById(final int id, final CallRecord record) { final Sandbox sb = Sandbox.get(id); if (localLOGD) { Log.d(TAG, "getSandboxById " + sb); }/* ww w .jav a2 s . c om*/ if (mRunningSandboxes.contains(sb)) { Log.i(TAG, "Explicitly requested sandbox " + sb + " busy"); return null; } if (mStoppedSandboxes.remove(sb)) { sb.start(this); } if (mHotSpares.remove(sb)) { refillHotSpares(); } // Put into mIdleSandboxes temporarily, beginExecution expects it. mIdleSandboxes.put(sb, ObjectUtils.NULL); if (record != null) { String packageName = record.getSODA().getDescriptor().definingClass.getPackageName(); String assignedName = sb.getAssignedPackage(); if ((assignedName != null && !assignedName.equals(packageName)) || !record.getInboundTaints().isSubsetOf(sb.getTaints())) { // We need to restart this sandbox for security reasons. Log.i(TAG, "Restarting " + sb + " for explicit request"); sb.restart(); } } return sb; }
From source file:edu.umich.flowfence.service.NamespaceSharedPrefs.java
public void registerOnNamespacePreferenceChangedListener(OnNamespacePreferenceChangeListener listener) { synchronized (mListenerMap) { mListenerMap.put(listener, ObjectUtils.NULL); }/*from w ww .jav a 2 s.c o m*/ }
From source file:edu.umich.flowfence.service.SandboxManager.java
public void putSandbox(Sandbox sb) { Map<AsyncCallback, Sandbox> callbacks; synchronized (this) { if (!mRunningSandboxes.remove(sb)) { Log.w(TAG, "Put non-running sandbox " + sb); return; }/*from w w w.j a v a 2s .c o m*/ sb.stop(mExecutionReferenceKey); if (localLOGD) { Log.d(TAG, "putSandbox " + sb); } // This was a trimmed sandbox. Let it go out of circulation. if (sb.getID() >= mMaxCount) { sb.stop(this); return; } mIdleSandboxes.put(sb, ObjectUtils.NULL); refillHotSpares(); trimIdle(); callbacks = tryExecuteQueueLocked(); } tryExecuteQueueUnlocked(callbacks); }
From source file:org.amanzi.awe.distribution.ui.wrappers.DistributionWrapperFactory.java
@Override public Iterator<ITreeWrapper> getWrappers(final Object parent) { Iterator<ITreeWrapper> result = null; try {/*from w w w . java 2 s . com*/ IProjectModel projectModel = null; IPropertyStatisticalModel sourceModel = null; if (parent != null) { if (parent.equals(ObjectUtils.NULL)) { projectModel = projectModelProvider.getActiveProjectModel(); } else if (parent instanceof IUIItem) { sourceModel = ((IUIItem) parent).castChild(IPropertyStatisticalModel.class); } } Iterator<IDistributionModel> modelIterator = null; if (projectModel != null) { modelIterator = new DistributionModelIterator(getSourceModelIterator(projectModel)); } else if (sourceModel != null) { modelIterator = distributionModelProvider.findAll(sourceModel); } if (modelIterator != null) { result = new DistributionWrapperIterator(modelIterator); } } catch (final ModelException e) { LOGGER.error("Error on collecting Tree Wrappers", e); } return result; }
From source file:org.amanzi.awe.statistics.ui.wrapper.StatisticsWrapperFactory.java
@Override public Iterator<ITreeWrapper> getWrappers(final Object parent) { Iterator<ITreeWrapper> result = null; try {/*from w ww. j av a 2s . co m*/ IProjectModel projectModel = null; IMeasurementModel sourceModel = null; if (parent != null) { if (parent.equals(ObjectUtils.NULL)) { projectModel = projectModelProvider.getActiveProjectModel(); } else if (parent instanceof IUIItem) { sourceModel = ((IUIItem) parent).castChild(IMeasurementModel.class); } } Iterator<IStatisticsModel> modelIterator = null; if (projectModel != null) { modelIterator = new StatisticsModelIterator(getMeasurementModelIterator(projectModel)); } else if (sourceModel != null) { modelIterator = getStatisticsModelsIterator(sourceModel); } if (modelIterator != null) { result = new StatisticsWrapperIterator(modelIterator); } } catch (final ModelException e) { LOGGER.error("Error on collecting Tree Wrappers", e); } return result; }
From source file:org.amanzi.awe.ui.tree.view.AbstractAWETreeView.java
protected TreeViewer createTreeViewer(final Composite parent) { final TreeViewer treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL); treeViewer.setContentProvider(createContentProvider()); treeViewer.setLabelProvider(createLabelProvider()); treeViewer.setInput(ObjectUtils.NULL); parent.setLayout(new GridLayout(1, false)); treeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); return treeViewer; }