List of usage examples for org.apache.commons.lang Validate noNullElements
public static void noNullElements(Collection collection)
Validate an argument, throwing IllegalArgumentException
if the argument Collection has null
elements or is null
.
Validate.noNullElements(myCollection);
The message in the exception is 'The validated collection contains null element at index: '.
If the collection is null then the message in the exception is 'The validated object is null'.
From source file:org.marketcetera.photon.internal.module.SinkDataManager.java
@Override public void unregister(ISinkDataHandler handler, Class<?>... classes) { Validate.notNull(handler);/*from ww w. j av a 2 s . com*/ Validate.noNullElements(classes); for (Class<?> clazz : classes) { handlers.get(clazz).remove(handler); } }
From source file:org.marketcetera.photon.internal.positions.ui.PositionsView.java
/** * Shows the hierarchical page with the provided grouping. * /*from ww w. j a v a 2 s .co m*/ * NOTE: public access for testing * * @param grouping * the grouping */ public void showHierarchicalPage(Grouping[] grouping) { Validate.noNullElements(grouping); Validate.isTrue(grouping.length == 2); if (!Arrays.equals(mGrouping, grouping)) { mLastPart = PositionsPart.HIERARCHICAL; mGrouping = grouping; mLastGrouping = grouping; // dispose the last tree page if it exists to free up resources partClosed(PositionsPart.HIERARCHICAL); partActivated(PositionsPart.HIERARCHICAL); } }
From source file:org.marketcetera.photon.internal.strategy.RemoteAgentManager.java
/** * Constructor./*ww w.j ava2 s. c o m*/ * * @param moduleManager * module manager * @param beanServer * MBean server for module manipulation * @param agent * the remote agent bean * @param instanceName * the instance name to use for the module * @throws IllegalArgumentException * if any parameters are null * @throws InvalidURNException * if the instance name is invalid */ RemoteAgentManager(ModuleManager moduleManager, MBeanServerConnection beanServer, RemoteStrategyAgent agent, String instanceName) throws InvalidURNException { Validate.noNullElements(new Object[] { moduleManager, beanServer, agent, instanceName }); mModuleManager = moduleManager; mMBeanServer = beanServer; mAgent = agent; mAgentURN = new ModuleURN(EmitterFactory.PROVIDER_URN, instanceName); URNUtils.validateInstanceURN(mAgentURN, EmitterFactory.PROVIDER_URN); }
From source file:org.marketcetera.photon.internal.strategy.Strategy.java
/** * Constructor.// w w w .j a v a 2 s . c o m * * @param displayName * the human readable name for this strategy connection * @param urn * the ModuleURN of the underlying strategy module * @param file * the script file * @param className * the class name of the strategy object * @param routeToServer * true if the strategy should send orders to the server, false otherwise * @param parameters * parameters for the script * @throws IllegalArgumentException * if any parameter is null */ Strategy(String displayName, ModuleURN urn, IFile file, String className, boolean routeToServer, Properties parameters) { super(displayName); Validate.noNullElements(new Object[] { urn, file, className, parameters }); mURN = urn; mFile = file; mClassName = className; mRouteToServer = routeToServer; mParameters = parameters; }
From source file:org.marketcetera.photon.PhotonPositionMarketData.java
@Override public void addInstrumentMarketDataListener(Instrument instrument, InstrumentMarketDataListener listener) { Validate.noNullElements(new Object[] { instrument, listener }); synchronized (mListeners) { if (mDisposed.get()) return; IMarketDataReference<MDLatestTick> ref = mLatestTickReferences.get(instrument); if (ref == null) { ref = mMarketData.getLatestTick(instrument); mLatestTickReferences.put(instrument, ref); ref.get().eAdapters().add(mLatestTickAdapter); }//from ww w . j av a2 s . c o m IMarketDataReference<MDMarketstat> statRef = mStatReferences.get(instrument); if (statRef == null) { statRef = mMarketData.getMarketstat(instrument); mStatReferences.put(instrument, statRef); statRef.get().eAdapters().add(mClosingPriceAdapter); } mListeners.put(instrument, listener); } }
From source file:org.marketcetera.photon.PhotonPositionMarketData.java
@Override public void removeInstrumentMarketDataListener(Instrument instrument, InstrumentMarketDataListener listener) { Validate.noNullElements(new Object[] { instrument, listener }); List<IMarketDataReference<?>> toDispose = Lists.newArrayList(); synchronized (mListeners) { IMarketDataReference<MDLatestTick> ref = mLatestTickReferences.get(instrument); IMarketDataReference<MDMarketstat> statRef = mStatReferences.get(instrument); Set<InstrumentMarketDataListener> listeners = mListeners.get(instrument); listeners.remove(listener);//from w ww. j ava 2 s .c o m if (listeners.isEmpty()) { if (ref != null) { MDLatestTick tick = ref.get(); if (tick != null) { tick.eAdapters().remove(mLatestTickAdapter); mLatestTickReferences.remove(instrument); mLatestTickCache.remove(instrument); toDispose.add(ref); } } if (statRef != null) { MDMarketstat stat = statRef.get(); if (stat != null) { stat.eAdapters().remove(mClosingPriceAdapter); mStatReferences.remove(instrument); mClosingPriceCache.remove(instrument); toDispose.add(statRef); } } } } // dispose outside of the lock to avoid deadlock for (IMarketDataReference<?> ref : toDispose) { ref.dispose(); } }
From source file:org.marketcetera.photon.views.MarketDataViewItem.java
/** * Constructor. Will throw an exception if symbol is null. * // ww w .j a v a 2s . c om * @param equity * equity for item, cannot be null */ public MarketDataViewItem(IMarketData marketData, Equity equity) { Validate.noNullElements(new Object[] { marketData, equity }); mEquity = equity; mMarketData = marketData; init(); }
From source file:org.objectstyle.cayenne.dataview.DataView.java
public void load(File[] xmlSources) throws IOException { Validate.noNullElements(xmlSources); SAXBuilder builder = new SAXBuilder(); Document[] documents = new Document[xmlSources.length]; for (int i = 0; i < xmlSources.length; i++) { try {//from w w w . j a v a 2s . co m documents[i] = builder.build(xmlSources[i]); } catch (JDOMException ex) { ex.printStackTrace(); } } load(documents); }
From source file:org.objectstyle.cayenne.dataview.DataView.java
public void load(URL[] xmlSources) throws IOException { Validate.noNullElements(xmlSources); SAXBuilder builder = new SAXBuilder(); Document[] documents = new Document[xmlSources.length]; for (int i = 0; i < xmlSources.length; i++) { try {/*from ww w . j av a2 s. c o m*/ documents[i] = builder.build(xmlSources[i]); } catch (JDOMException ex) { ex.printStackTrace(); } } load(documents); }
From source file:org.objectstyle.cayenne.dataview.DataView.java
public void load(Reader[] xmlSources) throws IOException { Validate.noNullElements(xmlSources); SAXBuilder builder = new SAXBuilder(); Document[] documents = new Document[xmlSources.length]; for (int i = 0; i < xmlSources.length; i++) { try {//w w w .ja va 2s . co m documents[i] = builder.build(xmlSources[i]); } catch (JDOMException ex) { ex.printStackTrace(); } } load(documents); }