Java Code Examples for java.util.Collections#EMPTY_LIST

The following examples show how to use java.util.Collections#EMPTY_LIST . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Palettes.java    From CameraColorPicker with Apache License 2.0 6 votes vote down vote up
/**
 * Get the {@link Palette}s of the user.
 *
 * @param sharedPreferences a {@link android.content.SharedPreferences} from which the {@link Palette}s will be retrieved.
 * @return a {@link java.util.List} of {@link Palette}s.
 */
@SuppressWarnings("unchecked")
private static List<Palette> getSavedColorPalettes(SharedPreferences sharedPreferences) {
    final String jsonColorPalettes = sharedPreferences.getString(KEY_SAVED_COLOR_PALETTES, "");

    // No saved colors were found.
    // Return an empty list.
    if ("".equals(jsonColorPalettes)) {
        return Collections.EMPTY_LIST;
    }

    // Parse the json into colorItems.
    final List<Palette> palettes = GSON.fromJson(jsonColorPalettes, COLOR_PALETTE_LIST_TYPE);

    // Sort the color items chronologically.
    Collections.sort(palettes, CHRONOLOGICAL_COMPARATOR);
    return palettes;
}
 
Example 2
Source File: Message.java    From helix with Apache License 2.0 6 votes vote down vote up
/**
 * Attach a relayed message and its destination participant to this message.
 * WARNNING: only content in SimpleFields of relayed message will be carried over and sent,
 * all contents in either ListFields or MapFields will be ignored.
 * @param instance destination participant name
 * @param message relayed message.
 */
public void attachRelayMessage(String instance, Message message) {
  List<String> relayList = _record.getListField(Attributes.RELAY_PARTICIPANTS.name());
  if (relayList == null) {
    relayList = Collections.EMPTY_LIST;
  }
  Set<String> relayParticipants = new LinkedHashSet<>(relayList);
  relayParticipants.add(instance);
  Map<String, String> messageInfo = message.getRecord().getSimpleFields();
  messageInfo.put(Attributes.RELAY_MSG_ID.name(), message.getId());
  messageInfo.put(Attributes.MSG_SUBTYPE.name(), MessageType.RELAYED_MESSAGE.name());
  messageInfo.put(Attributes.RELAY_FROM.name(), getTgtName());
  messageInfo.put(Attributes.EXPIRY_PERIOD.name(), String.valueOf(RELAY_MESSAGE_DEFAULT_EXPIRY));
  _record.setMapField(instance, messageInfo);
  _record.setListField(Attributes.RELAY_PARTICIPANTS.name(),
      Lists.newArrayList(relayParticipants));
}
 
Example 3
Source File: NoOpReconciler.java    From openregistry with Apache License 2.0 5 votes vote down vote up
public ReconciliationResult reconcile(final ReconciliationCriteria reconciliationCriteria) {
    return new ReconciliationResult() {
        public ReconciliationType getReconciliationType() {
            return ReconciliationType.NONE;
        }

        public List<PersonMatch> getMatches() {
            return Collections.EMPTY_LIST;
        }

        public boolean noPeopleFound() {
            return true;
        }

        public boolean personAlreadyExists() {
            return false;
        }

        public boolean multiplePeopleFound() {
            return false;  
        }

        public void setReconciliationFeedback(String feedback){
        }

        public String getReconciliationFeedback(){
            return "feedback";
        }
    };
}
 
Example 4
Source File: DefaultCuboidScheduler.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public List<Long> getSpanningCuboid(long cuboid) {
    if (cuboid > max || cuboid < 0) {
        throw new IllegalArgumentException("Cuboid " + cuboid + " is out of scope 0-" + max);
    }

    List<Long> spanning = parent2child.get(cuboid);
    if (spanning == null) {
        return Collections.EMPTY_LIST;
    }
    return spanning;
}
 
Example 5
Source File: RedisHash.java    From litchi with Apache License 2.0 5 votes vote down vote up
/**
 * 获取所有给定字段的值
 * @param key
 * @param fields
 * @return
 */
@SuppressWarnings("unchecked")
public List<String> mget(String key, String... fields) {
	try {
		return jedis.hmget(key, fields);
	} catch (Exception e) {
		LOGGER.error("", e);
	} finally {
		if (autoClose) {
			close();
		}
	}
	return Collections.EMPTY_LIST;
}
 
Example 6
Source File: DeadlockInfo.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Get a list of monitor locks that were acquired by this thread at this stack element.
 * @param threadInfo The thread that created the stack element
 * @param stackTraceElement The stack element
 * @return List of monitor locks that were acquired by this thread at this stack element
 * or an empty list if none were acquired
 */
public List<MonitorInfo> getMonitorLockedElements(final ThreadInfo threadInfo,
                                                  final StackTraceElement stackTraceElement) {
  final Map<StackTraceElement, List<MonitorInfo>> elementMap = monitorLockedElements.get(threadInfo);
  if (null == elementMap) {
    return Collections.EMPTY_LIST;
  }

  final List<MonitorInfo> monitorList = elementMap.get(stackTraceElement);
  if (null == monitorList) {
    return Collections.EMPTY_LIST;
  }

  return monitorList;
}
 
Example 7
Source File: JsrWebSocketServerTest.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
@Test
@Ignore("UT3 - P2")
public void testErrorHandling() throws Exception {


    ServerWebSocketContainer builder = new ServerWebSocketContainer(TestClassIntrospector.INSTANCE, DefaultServer.getEventLoopSupplier(), Collections.EMPTY_LIST, false, false);

    builder.addEndpoint(ServerEndpointConfig.Builder.create(ProgramaticErrorEndpoint.class, "/").configurator(new InstanceConfigurator(new ProgramaticErrorEndpoint())).build());
    deployServlet(builder);

    AnnotatedClientEndpoint c = new AnnotatedClientEndpoint();

    Session session = ContainerProvider.getWebSocketContainer().connectToServer(c, new URI("ws://" + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostPort("default") + "/"));

    Assert.assertEquals("hi", ProgramaticErrorEndpoint.getMessage());
    session.getAsyncRemote().sendText("app-error");
    Assert.assertEquals("app-error", ProgramaticErrorEndpoint.getMessage());
    Assert.assertEquals("ERROR: java.lang.RuntimeException", ProgramaticErrorEndpoint.getMessage());
    Assert.assertTrue(c.isOpen());

    session.getBasicRemote().sendText("io-error");
    Assert.assertEquals("io-error", ProgramaticErrorEndpoint.getMessage());
    Assert.assertEquals("ERROR: java.lang.RuntimeException", ProgramaticErrorEndpoint.getMessage());
    Assert.assertTrue(c.isOpen());
    ((UndertowSession) session).forceClose();
    Assert.assertEquals("CLOSED", ProgramaticErrorEndpoint.getMessage());

}
 
Example 8
Source File: ItemStorage.java    From seldon-server with Apache License 2.0 5 votes vote down vote up
public FilteredItems retrieveRecentlyAddedItemsWithTags(final String client, final int numItems, final int tagAttrId, final Set<String> tags, final int tagsKey){
    final String key = MemCacheKeys.getRecentItemsWithTags(client, tagAttrId, tagsKey, numItems);
    List<Long> retrievedItems = retrieveUsingJSON(key, numItems, new UpdateRetriever<List<Long>>() {
        @Override
        public List<Long> retrieve() throws Exception {
            return provider.getItemPersister(client).getRecentItemIdsWithTags(tagAttrId, tags, numItems);
        }
    }, new TypeReference<List<Long>>() {}, RECENT_ITEMS_EXPIRE_TIME);
    return new FilteredItems(retrievedItems==null? Collections.EMPTY_LIST : retrievedItems,SecurityHashPeer.md5(key));
}
 
Example 9
Source File: Field.java    From rapidoid with Apache License 2.0 5 votes vote down vote up
protected Collection<?> getOptionsOfType(Class<?> clazz) {
	if (Cls.kindOf(clazz) == TypeKind.UNKNOWN && Beany.hasProperty(clazz, "id")) {
		return Collections.EMPTY_LIST; // FIXME use magic?
	} else {
		return Collections.EMPTY_LIST;
	}
}
 
Example 10
Source File: ParameterDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private List getColumnValueList( )
{
	try
	{
		if ( columnChooser.getText( ) == null
				|| columnChooser.getText( ).equals( "" ) ) //$NON-NLS-1$
		{
			MessageDialog.openWarning( getShell( ),
					Messages.getString( "ParameterDialog.emptyColumnValueExpression.title" ), //$NON-NLS-1$
					Messages.getString( "ParameterDialog.emptyColumnValueExpression.message" ) ); //$NON-NLS-1$
			columnChooser.forceFocus( );
			return Collections.EMPTY_LIST;
		}
		ArrayList valueList = new ArrayList( );

		//Flow mode PARAM_EVALUATION_FLOW is propagated to data engine execution to exclude filters defined on data set.
		valueList.addAll( SelectValueFetcher.getSelectValueList(
				ExpressionButtonUtil.getExpression( columnChooser ),
				getDataSetHandle( ),
				DataEngineFlowMode.PARAM_EVALUATION_FLOW ) );
		java.util.Collections.sort( valueList );
		return valueList;
	}
	catch ( Exception e )
	{
		ExceptionHandler.handle( e );
		return Collections.EMPTY_LIST;
	}
}
 
Example 11
Source File: OpenFileInSystemEditorAction.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
protected List getSelectedNonResources() {		
	return Collections.EMPTY_LIST;
}
 
Example 12
Source File: ReceiveTaskLabel2EditPart.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
* @generated
*/
@SuppressWarnings("rawtypes")
protected List getModelChildren() {
	return Collections.EMPTY_LIST;
}
 
Example 13
Source File: FirstLastValueFunctionNode.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public List<ValueNode> getOperands() {
    return (operand != null ? Lists.newArrayList(operand) : Collections.EMPTY_LIST);
}
 
Example 14
Source File: CloseType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
protected List wrap(Close val)
{
    ErrorCondition error = val.getError();
    return error == null ? Collections.EMPTY_LIST : Collections.singletonList(error);
}
 
Example 15
Source File: StandardCostManager.java    From Llunatic with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
    private List<Repair> generateBackwardRepairs(EquivalenceClassForEGD equivalenceClass, Scenario scenario, IDatabase deltaDB, String stepId) {
        List<ViolationContext> violationContextsForBackward = extractViolationContextWithWitnessCells(equivalenceClass);
        if (violationContextsForBackward.isEmpty()) {
            return Collections.EMPTY_LIST;
        }
        if (violationContextsForBackward.size() > 10) {
            throw new ChaseException("Equivalence class is too big (" + violationContextsForBackward.size() + "). It is not possible to chase this scenario with standard cost manager: " + equivalenceClass);
        }
        List<Repair> result = new ArrayList<Repair>();
        Set<String> repairFingerprints = new HashSet<String>();
        if (logger.isDebugEnabled()) logger.debug("Generating backward repairs for equivalence class :" + equivalenceClass);
        GenericPowersetGenerator<Integer> powersetGenerator = new GenericPowersetGenerator<Integer>();
//        List<List<Integer>> powerset = powersetGenerator.generatePowerSet(CostManagerUtility.createIndexes(equivalenceClass.getSize()));
        List<List<Integer>> powerset = powersetGenerator.generatePowerSet(CostManagerUtility.createIndexes(violationContextsForBackward.size()));
        for (List<Integer> subsetIndex : powerset) {
            if (subsetIndex.isEmpty()) {
                continue;
            }
            Collections.reverse(subsetIndex);
            List<ViolationContext> backwardContexts = extractBackwardContexts(subsetIndex, violationContextsForBackward);
            if (logger.isDebugEnabled()) logger.debug("Generating backward repairs for subset indexes: " + subsetIndex);
            List<List<CellGroup>> backwardCellGroups = extractBackwardCellGroups(backwardContexts);
            if (backwardCellGroups == null) {
                //Backward is not allowed on some of the contexts
                if (logger.isDebugEnabled()) logger.debug("Cannot do backward on all contexts. Discarding");
                continue;
            }
            GenericListGenerator<CellGroup> listGenerator = new GenericListGenerator<CellGroup>();
            List<List<CellGroup>> backwardCombinations = listGenerator.generateListsOfElements(backwardCellGroups);
            for (List<CellGroup> backwardCombination : backwardCombinations) {
                if (logger.isDebugEnabled()) logger.debug("Generating repairs for backward combination " + backwardCombination);
                List<ViolationContext> forwardContext = extractForwardContext(backwardContexts, equivalenceClass);
                if (!checkConsistencyOfBackwardChanges(backwardCombination, backwardContexts, forwardContext, equivalenceClass)) {
                    if (logger.isTraceEnabled()) logger.debug("Cell group combination for backward is not consistent. Discarding " + backwardCombination);
                    continue;
                }
                if (!checkConsistencyOfForwardChanges(forwardContext, backwardContexts, equivalenceClass)) {
                    if (logger.isDebugEnabled()) logger.debug("Inconsistent subset. Discarding " + LunaticUtility.printViolationContextIDs(backwardContexts));
                    continue;
                }
                String repairFingerprint = generateRepairFingerprint(backwardCombination);
                if (repairFingerprints.contains(repairFingerprint)) {
                    if (logger.isDebugEnabled()) logger.debug("Duplicate repair fingerprint. Discarding " + repairFingerprint);
                    continue;
                }
                repairFingerprints.add(repairFingerprint);
                Repair repair = CostManagerUtility.generateRepairWithBackwards(forwardContext, backwardCombination, backwardContexts, scenario);
                if (logger.isDebugEnabled()) logger.debug("Generating repair for: \nForward contexts: " + forwardContext + "\nBackward groups: " + backwardCombination + "\n" + repair);
                result.add(repair);
            }
        }
        if (logger.isDebugEnabled()) logger.debug("########Backward repairs: " + result);
        return result;
    }
 
Example 16
Source File: PackageDescr.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public void addAccumulateImport(final AccumulateImportDescr importAccumulate) {
    if (this.accumulateImports == Collections.EMPTY_LIST) {
        this.accumulateImports = new ArrayList<AccumulateImportDescr>();
    }
    this.accumulateImports.add(importAccumulate);
}
 
Example 17
Source File: DistinctValueSelector.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private static List getSelectValueList1( Expression expression,
		ModuleHandle moduleHandle, DataSetHandle dataSetHandle,
		boolean useDataSetFilter, DataEngineFlowMode flowMode )
		throws BirtException
{
	ScriptExpression expr = null;
	DataSetHandle targetHandle = dataSetHandle;
	Map appContext = new HashMap( );
	DataSetPreviewer previewer = null;

	try
	{
		ModuleHandle targetModuleHandle = moduleHandle;
		if ( !useDataSetFilter )
		{
			targetModuleHandle = ( (Module) moduleHandle.copy( ) ).getModuleHandle( );
			SlotHandle dataSets = targetModuleHandle.getDataSets( );
			for ( int i = 0; i < dataSets.getCount( ); i++ )
			{
				if ( dataSetHandle.getName( ).equals( dataSets.get( i )
						.getName( ) ) )
				{
					targetHandle = (DataSetHandle) dataSets.get( i );
					targetHandle.clearProperty( IDataSetModel.FILTER_PROP );
					break;
				}
			}
		}
		previewer = new DataSetPreviewer( targetHandle,
				0,
				PreviewType.RESULTSET );
		
		DataModelAdapter adapter = new DataModelAdapter( new DataSessionContext( DataSessionContext.MODE_DIRECT_PRESENTATION,
				targetModuleHandle ) );
		expr = adapter.adaptExpression( expression );

		boolean startsWithRow = ExpressionUtility.isColumnExpression( expr.getText( ),
				true );
		boolean startsWithDataSetRow = ExpressionUtility.isColumnExpression( expr.getText( ),
				false );
		if ( !startsWithRow && !startsWithDataSetRow )
		{
			throw new DataException( Messages.getString( "SelectValueDialog.messages.info.invalidSelectVauleExpression" ) ); //$NON-NLS-1$
		}

		String dataSetColumnName = null;
		if ( startsWithDataSetRow )
		{
			dataSetColumnName = ExpressionUtil.getColumnName( expr.getText( ) );
		}
		else
		{
			dataSetColumnName = ExpressionUtil.getColumnBindingName( expr.getText( ) );
		}			
		
		ResourceIdentifiers identifiers = new ResourceIdentifiers( );
		String resouceIDs = ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE_IDS;					
		identifiers.setApplResourceBaseURI( DTPUtil.getInstance( ).getBIRTResourcePath( ) );
		identifiers.setDesignResourceBaseURI( DTPUtil.getInstance( ).getReportDesignPath( ) );
		appContext.put( resouceIDs,identifiers);
	
		AppContextPopulator.populateApplicationContext( targetHandle, appContext );
		previewer.open( appContext, getEngineConfig( targetHandle.getModuleHandle( ) ), flowMode );
		IResultIterator itr = previewer.preview( ) ;
		
		Set visitedValues = new HashSet( );
		Object value = null;
		
		while ( itr.next( ) )
		{
			// default is to return 10000 distinct value
			if ( visitedValues.size( ) > 10000 )
			{
				break;
			}
			value = itr.getValue( dataSetColumnName );
			if ( value != null && !visitedValues.contains( value ) )
			{
				visitedValues.add( value );
			}
		}

		if ( visitedValues.isEmpty( ) )
			return Collections.EMPTY_LIST;

		return new ArrayList( visitedValues );
	}
	finally
	{
		AppContextResourceReleaser.release( appContext );
		if ( previewer != null )
			previewer.close( );
	}
}
 
Example 18
Source File: StackTraceSnapshotBuilder.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void processDiffs(int threadId, StackTraceElement[] oldElements, StackTraceElement[] newElements, long timestamp, long threadtimestamp) throws IllegalStateException {
    if (oldElements.length == 0 && newElements.length == 0) {
        return;
    }
    
    int newMax = newElements.length - 1;
    int oldMax = oldElements.length - 1;
    int globalMax = Math.max(oldMax, newMax);
    
    List<StackTraceElement> newElementsList = Collections.EMPTY_LIST;
    List<StackTraceElement> oldElementsList = Collections.EMPTY_LIST;
    
    for (int iteratorIndex = 0; iteratorIndex <= globalMax; iteratorIndex++) {
        StackTraceElement oldElement = oldMax >= iteratorIndex ? oldElements[oldMax - iteratorIndex] : null;
        StackTraceElement newElement = newMax >= iteratorIndex ? newElements[newMax - iteratorIndex] : null;
        
        if (oldElement != null && newElement != null) {
            if (!oldElement.equals(newElement)) {
                if (hasSameMethodInfo(oldElement,newElement)) {
                    iteratorIndex++;
                }
                newElementsList = Arrays.asList(newElements).subList(0, newMax - iteratorIndex + 1);
                oldElementsList = Arrays.asList(oldElements).subList(0, oldMax - iteratorIndex + 1);
                break;
            }
        } else if (oldElement == null && newElement != null) {
            newElementsList = Arrays.asList(newElements).subList(0, newMax - iteratorIndex + 1);
            break;
            
        } else if (oldElement != null && newElement == null) {
            oldElementsList = Arrays.asList(oldElements).subList(0, oldMax - iteratorIndex + 1);
            break;
            
        }
    }
    
    // !!! The order is important - first we need to exit from the
    // already entered methods and only then we can enter the new ones !!!
    addMethodExits(threadId, oldElementsList, timestamp, threadtimestamp, newElements.length == 0);
    addMethodEntries(threadId, newElementsList, timestamp, threadtimestamp, oldElements.length == 0);
}
 
Example 19
Source File: ActivityName2EditPart.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
* @generated
*/
@SuppressWarnings("rawtypes")
protected List getModelChildren() {
	return Collections.EMPTY_LIST;
}
 
Example 20
Source File: StackTraceSnapshotBuilder.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void processDiffs(int threadId, StackTraceElement[] oldElements, StackTraceElement[] newElements, long timestamp, long threadtimestamp) throws IllegalStateException {
    if (oldElements.length == 0 && newElements.length == 0) {
        return;
    }
    
    int newMax = newElements.length - 1;
    int oldMax = oldElements.length - 1;
    int globalMax = Math.max(oldMax, newMax);
    
    List<StackTraceElement> newElementsList = Collections.EMPTY_LIST;
    List<StackTraceElement> oldElementsList = Collections.EMPTY_LIST;
    
    for (int iteratorIndex = 0; iteratorIndex <= globalMax; iteratorIndex++) {
        StackTraceElement oldElement = oldMax >= iteratorIndex ? oldElements[oldMax - iteratorIndex] : null;
        StackTraceElement newElement = newMax >= iteratorIndex ? newElements[newMax - iteratorIndex] : null;
        
        if (oldElement != null && newElement != null) {
            if (!oldElement.equals(newElement)) {
                if (hasSameMethodInfo(oldElement,newElement)) {
                    iteratorIndex++;
                }
                newElementsList = Arrays.asList(newElements).subList(0, newMax - iteratorIndex + 1);
                oldElementsList = Arrays.asList(oldElements).subList(0, oldMax - iteratorIndex + 1);
                break;
            }
        } else if (oldElement == null && newElement != null) {
            newElementsList = Arrays.asList(newElements).subList(0, newMax - iteratorIndex + 1);
            break;
            
        } else if (oldElement != null && newElement == null) {
            oldElementsList = Arrays.asList(oldElements).subList(0, oldMax - iteratorIndex + 1);
            break;
            
        }
    }
    
    // !!! The order is important - first we need to exit from the
    // already entered methods and only then we can enter the new ones !!!
    addMethodExits(threadId, oldElementsList, timestamp, threadtimestamp, newElements.length == 0);
    addMethodEntries(threadId, newElementsList, timestamp, threadtimestamp, oldElements.length == 0);
}