下面列出了java.util.Collection#isEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Constructor that should be overridden by child implementation. The constructor allows for easy toString() output
* customization.
*
* @param toStringName a general name of the object (such as 'policy' or 'nested policy') that will be used in the
* toString() method to identify the object.
* @param sets represents the collection of policy alternatives of the policy object created. During the creation of
* the new policy object, the content of the alternatives collection is copied into an internal policy object structure,
* thus any subsequent operations on the collection will have no impact on the newly constructed policy object. The
* collection may be {@code null} or empty. In such case a 'NULL' policy object is constructed.
*/
Policy(final String toStringName, final Collection<AssertionSet> sets) {
this.nsVersion = NamespaceVersion.getLatestVersion();
this.toStringName = toStringName;
if (sets == null || sets.isEmpty()) {
this.assertionSets = NULL_POLICY_ASSERTION_SETS;
this.vocabulary = EMPTY_VOCABULARY;
this.immutableVocabulary = EMPTY_VOCABULARY;
} else {
this.assertionSets = new LinkedList<AssertionSet>();
this.vocabulary = new TreeSet<QName>(PolicyUtils.Comparison.QNAME_COMPARATOR);
this.immutableVocabulary = Collections.unmodifiableCollection(this.vocabulary);
addAll(sets);
}
}
private Status validateQueryParameter(final HttpServerExchange exchange,
final SwaggerOperation swaggerOperation,
final Parameter queryParameter) {
final Collection<String> queryParameterValues = exchange.getQueryParameters().get(queryParameter.getName());
if ((queryParameterValues == null || queryParameterValues.isEmpty())) {
if(queryParameter.getRequired()) {
return new Status(VALIDATOR_REQUEST_PARAMETER_QUERY_MISSING, queryParameter.getName(), swaggerOperation.getPathString().original());
}
} else {
Optional<Status> optional = queryParameterValues
.stream()
.map((v) -> parameterValidators.validate(v, queryParameter))
.filter(s -> s != null)
.findFirst();
if(optional.isPresent()) {
return optional.get();
}
}
return null;
}
@Override
public <T> int[] batchInsert(Collection<T> collection) {
if (collection == null || collection.isEmpty()) {
throw new JdbcException("batchInsert collection不能为空");
}
int row[] = null;
List<Object[]> batchArgs = new ArrayList<Object[]>();
String sql = "";
for (T t : collection) {
SqlObject sqlField = DynamicSql.insertSql(t);
if (sqlField == null) {
throw new JdbcException("batchInsert SqlField 不能为空");
}
if (StringUtils.isBlank(sql)) {
sql = sqlField.sql;
}
batchArgs.add(sqlField.params.toArray());
}
row = getJdbcTemplate().batchUpdate(sql, batchArgs);
return row;
}
public static <E, V, T extends RpmBaseTag> void putFields ( final Header<T> header, final Collection<E> entries, final T tag, final ArrayAllocator<V> arrayAllocator, final Function<E, V> func, final Putter<T, V> putter )
{
if ( entries.isEmpty () )
{
return;
}
final V[] values = arrayAllocator.allocate ( entries.size () );
int i = 0;
for ( final E entry : entries )
{
values[i] = func.apply ( entry );
i++;
}
putter.put ( header, tag, values );
}
@Override
public Collection<VisualNode> collect(VisualModel model) {
Collection<VisualNode> joints = new HashSet<>();
if (model instanceof VisualCircuit) {
VisualCircuit circuit = (VisualCircuit) model;
joints.addAll(Hierarchy.getDescendantsOfType(circuit.getRoot(), VisualJoint.class));
Collection<VisualNode> selection = circuit.getSelection();
if (!selection.isEmpty()) {
HashSet<VisualNode> selectedJoints = new HashSet<>(selection);
selectedJoints.retainAll(joints);
if (!selectedJoints.isEmpty()) {
joints.retainAll(selection);
}
}
}
return joints;
}
private QualityPropertyType[] createQuality(Collection<SweQuality> quality) {
if (!quality.isEmpty()) {
ArrayList<QualityPropertyType> xbQualities = Lists.newArrayListWithCapacity(quality.size());
for (SweQuality sweQuality : quality) {
QualityPropertyType xbQuality = QualityPropertyType.Factory.newInstance();
if (sweQuality instanceof SweText) {
xbQuality.addNewText().set(createText((SweText) sweQuality));
} else if (sweQuality instanceof SweCategory) {
xbQuality.addNewCategory().set(createCategory((SweCategory) sweQuality));
} else if (sweQuality instanceof SweQuantity) {
xbQuality.addNewQuantity().set(createQuantity((SweQuantity) sweQuality));
} else if (sweQuality instanceof SweQuantityRange) {
xbQuality.addNewQuantityRange().set(createQuantityRange((SweQuantityRange) sweQuality));
}
xbQualities.add(xbQuality);
}
return xbQualities.toArray(new QualityPropertyType[xbQualities.size()]);
}
return new QualityPropertyType[] { QualityPropertyType.Factory.newInstance() };
}
/**
* This method retrieves the vendor identification code for the vendor found who has a matching tax id and tax payer type
* code.
*
* @param taxIDNumber The tax id number used to retrieve the associated vendor.
* @param taxPayerTypeCode The tax payer type code used to retrieve the associated vendor. See the TAX_TYPE_* constants defined in
* DisbursementVoucherRuleConstants for examples of valid tax type codes.
* @return The id of the vendor found matching the tax id and type code provided. Null if no matching vendor is found.
*
* @see org.kuali.kfs.fp.document.service.DisbursementVoucherTaxService#getPayeeNumber(java.lang.String, java.lang.String)
*/
public String getVendorId(String taxIDNumber, String taxPayerTypeCode) {
String vendorId = null;
Map taxIDCrit = new HashMap();
taxIDCrit.put("taxIdNumber", taxIDNumber);
taxIDCrit.put("taxpayerTypeCode", taxPayerTypeCode);
Collection<VendorDetail> foundPayees = businessObjectService.findMatching(VendorDetail.class, taxIDCrit);
if (!foundPayees.isEmpty()) {
VendorDetail vendor = (VendorDetail) foundPayees.iterator().next();
vendorId = vendor.getVendorHeaderGeneratedIdentifier().toString();
}
return vendorId;
}
@Override
public void process(final JVoiceXMLEvent event) throws JVoiceXMLEvent {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("processing event " + event + "...");
}
final RecognitionEvent recognitionEvent = (RecognitionEvent) event;
final RecognitionResult result = recognitionEvent
.getRecognitionResult();
final VoiceXmlInterpreterContext context =
getVoiceXmlInterpreterContext();
final DataModel model = context.getDataModel();
setApplicationLastResult(result);
final Collection<InputItem> filtered = filterEvent(model, result);
if ((filtered == null) || filtered.isEmpty()) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("no matching form items: processing aborted");
}
return;
}
setFilledInputItems(result, filtered);
setInitialFormItems();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("executing filled elements...");
}
final Collection<Filled> filledElements = dialog.getFilledElements();
final FormInterpretationAlgorithm fia =
getFormInterpretationAlgorithm();
final VoiceXmlInterpreter interpreter = getVoiceXmlInterpreter();
final TagStrategyExecutor executor = getTagStrategyExecutor();
for (Filled filled : filledElements) {
if (shouldExecute(filled, model)) {
executor.executeChildNodes(context, interpreter, fia, null,
filled);
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("...done executing filled element");
}
}
static Assertion getAddressingPolicy(AssertionInfoMap aim, boolean optional) {
Collection<AssertionInfo> lst = aim.get(MetadataConstants.USING_ADDRESSING_2004_QNAME);
Assertion assertion = null;
if (null != lst && !lst.isEmpty()) {
assertion = lst.iterator().next().getAssertion();
}
if (assertion == null) {
lst = aim.get(MetadataConstants.USING_ADDRESSING_2005_QNAME);
if (null != lst && !lst.isEmpty()) {
assertion = lst.iterator().next().getAssertion();
}
}
if (assertion == null) {
lst = aim.get(MetadataConstants.USING_ADDRESSING_2006_QNAME);
if (null != lst && !lst.isEmpty()) {
assertion = lst.iterator().next().getAssertion();
}
}
if (assertion == null) {
return new PrimitiveAssertion(MetadataConstants.USING_ADDRESSING_2006_QNAME,
optional);
} else if (optional) {
return new PrimitiveAssertion(assertion.getName(),
optional);
}
return assertion;
}
static void log(String prefix, Collection cls) {
if(LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, prefix);
if(cls.isEmpty()) {
LOG.log(Level.FINE, " EMPTY"); // NOI18N
} else {
for (Object o : cls) {
LOG.log(Level.FINE, " {0}", o.toString()); // NOI18N
}
}
}
}
@Override
public String[] unparse(LoadContext context, Campaign campaign)
{
Changes<String> changes = context.getObjectContext().getListChanges(campaign, ListKey.BOOK_TYPE);
if (changes == null || changes.isEmpty())
{
return null;
}
Collection<String> added = changes.getAdded();
if (added == null || added.isEmpty())
{
return null;
}
return new String[]{StringUtil.join(added, Constants.PIPE)};
}
/**
* Awaits for all futures to complete and optionally reduces all results into one.
*
* @param timeout Timeout for waiting ({@code 0} for forever).
* @param rdc Optional reducer. If not {@code null}, then results will be reduced into one.
* @param futs List of futures to wait for.
* @param <T> Return type of the futures.
* @param <R> Return type of the reducer.
* @return Reduced result if reducer is provided, {@code null} otherwise.
* @throws IgniteCheckedException If any of the futures failed.
*/
@Deprecated
@Nullable public static <T, R> R awaitAll(long timeout, @Nullable IgniteReducer<T, R> rdc,
@Nullable Collection<IgniteInternalFuture<T>> futs) throws IgniteCheckedException {
if (futs == null || futs.isEmpty())
return null;
long end = timeout == 0 ? Long.MAX_VALUE : U.currentTimeMillis() + timeout;
// Overflow.
if (end < 0)
end = Long.MAX_VALUE;
// Note that it is important to wait in the natural order of collection and
// not via listen method, because caller may actually add to this collection
// concurrently while this method is in progress.
for (IgniteInternalFuture<T> fut : futs) {
T t;
if (timeout > 0) {
long left = end - U.currentTimeMillis();
if (left <= 0 && !fut.isDone())
throw new IgniteFutureTimeoutCheckedException("Timed out waiting for all futures: " + futs);
if (fut.isDone() && left < 0)
left = 0;
t = fut.get(left);
}
else
t = fut.get();
if (rdc != null)
rdc.collect(t);
}
return rdc == null ? null : rdc.reduce();
}
@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);
Collection<SpecialDate> specialDates = getSpecialDates();
if(component.isEnabledInHierarchy()){
response.render(CssReferenceHeaderItem.forReference(DATE_PICKER_CSS));
response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_JAVASCRIPT));
response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_EXTENSION_JAVASCRIPT));
if(!component.getLocale().getLanguage().equals("en")){
response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "locales/bootstrap-datepicker."+component.getLocale().getLanguage()+".min.js")));
}
if(null != specialDates && !specialDates.isEmpty()) {
StringBuilder sb = new StringBuilder();
sb.append("[");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
SpecialDate[] sdArray = specialDates.toArray(new SpecialDate[20]);
for(int i = 0; i < specialDates.size(); ++i) {
SpecialDate sd = sdArray[i];
sb.append("{dt:new Date('"+df.format(sd.getDt())+"'), css:'"+sd.getCssClass()+"', tooltip:'"+ sd.getTooltip() +"'}");
if(i < specialDates.size() - 1) {
sb.append(",");
}
}
sb.append("]");
response.render(OnDomReadyHeaderItem.forScript("$(\"#"+component.getMarkupId()+"\").datepicker(null, "+sb.toString()+")"));
} else {
response.render(OnDomReadyHeaderItem.forScript("$(\"#"+component.getMarkupId()+"\").datepicker()"));
}
}
}
/**
* Sets annotations on a given hex.
* @param c Coordinates of the hex to apply the annotations to.
* @param a A collection of annotations to assign to the hex. This may be null.
*/
public void setAnnotations(Coords c, @Nullable Collection<String> a) {
if (null == a || a.isEmpty()) {
annotations.remove(c);
} else {
annotations.put(c, a);
}
}
@Override
public void authorizeCreateSchemaBranch(UserAndGroups userAndGroups,
ISchemaRegistry schemaRegistry,
String schemaMetadataName,
Long schemaVersionId,
String branchTocreate)
throws AuthorizationException, SchemaNotFoundException {
SchemaMetadata sM = schemaRegistry
.getSchemaMetadataInfo(schemaMetadataName)
.getSchemaMetadata();
String sGroup = sM.getSchemaGroup();
String sName = sM.getName();
Authorizer.SchemaBranchResource schemaBranchResource =
new Authorizer.SchemaBranchResource(sGroup, sName, branchTocreate);
authorize(schemaBranchResource, AccessType.CREATE, userAndGroups);
Collection<SchemaBranch> branchSet = schemaRegistry.getSchemaBranchesForVersion(schemaVersionId);
if(branchSet.isEmpty()) {
throw new SchemaNotFoundException("Schema version with id : " + schemaVersionId + " not found");
}
String branch = getPrimaryBranch(branchSet);
Authorizer.SchemaVersionResource schemaVersionResource =
new Authorizer.SchemaVersionResource(sGroup, sName, branch);
authorize(schemaVersionResource, AccessType.READ, userAndGroups);
}
/** Don't use this for fast pixel grabbing; this is intended for the dropper tool and status bar reporting by mouse motion. */
public int[] getPixel(final int x, final int y, final double mag) {
// find Patch under cursor
final Collection<Displayable> under = find(Patch.class, x, y);
if (null == under || under.isEmpty()) return new int[3]; // zeros
final Patch pa = (Patch)under.iterator().next();// get(0) // the top one, since they are ordered like html divs
// TODO: edit here when adding layer mipmaps
return pa.getPixel(x, y, mag);
}
/**
* Returns a panel for choosing name and target location of the test
* class. If the panel already exists, returns the existing panel,
* otherwise creates a new panel.
*
* @return existing panel or a newly created panel if it did not exist
*/
private WizardDescriptor.Panel<WizardDescriptor> getTargetPanel() {
final Project project = Templates.getProject(wizard);
if(project == null) { // #176639
return new StepProblemMessage(project,
NbBundle.getMessage(
this.getClass(),
"MSG_UnsupportedPlugin")); //NOI18N
}
if (targetPanel == null || project != lastSelectedProject) {
JUnitPlugin plugin = JUnitTestUtil.getPluginForProject(project);
if (JUnitUtils.isInstanceOfDefaultPlugin(plugin)) {
targetPanel = new StepProblemMessage(
project,
NbBundle.getMessage(TestSuiteWizardIterator.class,
"MSG_UnsupportedPlugin")); //NOI18N
} else {
Collection<SourceGroup> sourceGroups = JUnitUtils.getTestTargets(project, true);
if (sourceGroups.isEmpty()) {
if (SourceGroupModifier.createSourceGroup(project, JavaProjectConstants.SOURCES_TYPE_JAVA, JavaProjectConstants.SOURCES_HINT_TEST) != null) {
sourceGroups = JUnitUtils.getTestTargets(project, true);
}
}
if (sourceGroups.isEmpty()) {
targetPanel = new StepProblemMessage(
project,
NbBundle.getMessage(TestSuiteWizardIterator.class,
"MSG_NoTestSourceGroup"));//NOI18N
} else {
sourceGroups.toArray(
testSrcGroups = new SourceGroup[sourceGroups.size()]);
if (optionsPanel == null) {
optionsPanel = new TestSuiteStepLocation();
}
targetPanel = JavaTemplates.createPackageChooser(project,
testSrcGroups,
optionsPanel);
}
}
lastSelectedProject = project;
}
return targetPanel;
}
final void addUpdateUnits (File... newFiles) {
Collection<UpdateUnit> alreadyInstalled = new HashSet<UpdateUnit> ();
for (File nbm : newFiles) {
UpdateUnit u = null;
if(NBM_FILE_FILTER.accept(nbm) || OSGI_BUNDLE_FILTER.accept(nbm)) {
u = createUpdateUnitFromNBM (nbm, false);
}
if (u != null) {
if (u.getAvailableUpdates () == null || u.getAvailableUpdates ().isEmpty ()) {
// already installed
alreadyInstalled.add (u);
} else if (getCodeName2Unit ().containsKey (u.getCodeName ())) {
UpdateElement uE1 = u.getAvailableUpdates ().get (0);
UpdateElement uE2 = getCodeName2Unit ().get (u.getCodeName ()).getAvailableUpdates ().get (0);
UpdateUnit winnerUnit;
File winnerFile;
UpdateUnit looserUnit;
File looserFile;
// both are valid, an user have to choose
String name1 = NbBundle.getMessage(LocalDownloadSupport.class, "NotificationPlugin", uE1.getDisplayName (), uE1.getSpecificationVersion ()); // NOI18N
String name2 = NbBundle.getMessage(LocalDownloadSupport.class, "NotificationPlugin", uE2.getDisplayName (), uE2.getSpecificationVersion ()); // NOI18N
Object res = DialogDisplayer.getDefault ().notify (
new NotifyDescriptor.Confirmation (
NbBundle.getMessage(LocalDownloadSupport.class, "NotificationAlreadyPresent", name2, name1), // NOI18N
NbBundle.getMessage(LocalDownloadSupport.class, "NotificationAlreadyPresentTitle"))); // NOI18N
if (NotifyDescriptor.YES_OPTION.equals (res)) {
winnerUnit = uE1.getUpdateUnit ();
winnerFile = nbm;
looserUnit = uE2.getUpdateUnit ();
looserFile = getNbm (winnerUnit.getCodeName ());
} else if (NotifyDescriptor.NO_OPTION.equals (res)) {
winnerUnit = uE2.getUpdateUnit ();
winnerFile = getNbm (winnerUnit.getCodeName ());
looserUnit = uE1.getUpdateUnit ();
looserFile = nbm;
} else {
// CANCEL_OPTION
break;
}
getNbm2CodeName ().remove (looserFile);
getCodeName2Unit ().remove (looserUnit.getCodeName ());
getNbm2CodeName ().put (winnerFile, winnerUnit.getCodeName ());
getCodeName2Unit ().put (winnerUnit.getCodeName (), winnerUnit);
fileList.removeFile (looserFile);
Containers.forUpdateNbms ().removeAll ();
Containers.forAvailableNbms ().removeAll ();
} else {
getNbm2CodeName ().put (nbm, u.getCodeName ());
getCodeName2Unit ().put (u.getCodeName (), u);
}
} else {
fileList.removeFile (nbm);
}
}
if (!alreadyInstalled.isEmpty ()) {
String msg;
if (alreadyInstalled.size () == 1) {
msg = NbBundle.getMessage(LocalDownloadSupport.class, "NotificationOneAlreadyInstalled", getDisplayNames (alreadyInstalled)); //NOI18N
} else {
msg = NbBundle.getMessage(LocalDownloadSupport.class, "NotificationMoreAlreadyInstalled", getDisplayNames (alreadyInstalled)); //NOI18N
}
DialogDisplayer.getDefault ().notify (new NotifyDescriptor.Message (
msg,
NotifyDescriptor.INFORMATION_MESSAGE));
}
}
public String getFirst( final String key )
{
final Collection<String> values = get( key );
return values.isEmpty() ? null : values.iterator().next();
}
/**
* Adds a new set of transitions to the FSM.
* @param triggerExpressions
* a list of trigger expressions for this transition, must not be null
* @param state
* the starting state of the FSM
* @param condition
* null or condition that has to return true for this transition
* to be considered
* @param secondary
* flag to mark secondary transitions to be taken into account after preferred transitions
* @param nextState
* the new state of the FSM
* @param reply
* a simple sentence reply (may be null for no reply)
* @param action
* a special action to be taken (may be null)
* @param label
* a label to find this transition at a later time
*/
public void add(Collection<Expression> triggerExpressions, final ConversationStates state, final ChatCondition condition,
boolean secondary, final ConversationStates nextState, final String reply, final ChatAction action, final String label) {
if (triggerExpressions!=null && !triggerExpressions.isEmpty()) {
stateTransitionTable.add(new Transition(state, triggerExpressions, condition, secondary, nextState, reply, action, label));
}
}