Java Code Examples for java.util.Collections.singletonList()

The following are Jave code examples for showing how to use singletonList() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: AbstractTestGenerator.java   View Source Code Vote up 6 votes
private static List<VariableTree> makeParamsCopy(
                                    List<? extends VariableElement> params,
                                    TreeMaker maker) {
    if (params.isEmpty()) {
        return Collections.emptyList();
    }

    int size = params.size();
    if (size == 1) {
        return Collections.singletonList(makeCopy(params.get(0), maker));
    }

    List<VariableTree> result = new ArrayList(size);
    for (VariableElement param : params) {
        result.add(makeCopy(param, maker));
    }
    return result;
}
 
Example 2
Project: talchain   File: GitHubVMTest.java   View Source Code Vote up 6 votes
@Test // testing full suite
public void testRandomVMGitHub() throws ParseException {

    String shacommit = "c5eafb85390eee59b838a93ae31bc16a5fd4f7b1";
    List<String> fileNames = getFileNamesForTreeSha(shacommit);
    List<String> excludedFiles =
            Collections.singletonList(
                    ""
            );

    for (String fileName : fileNames) {

        if (excludedFiles.contains(fileName)) continue;
        System.out.println("Running: " + fileName);
        String json = JSONReader.loadJSON("VMTests//RandomTests/" + fileName);
        GitHubJSONTestSuite.runGitHubJsonVMTest(json);
    }

}
 
Example 3
Project: SlotNSlot_Android   File: SlotMachine.java   View Source Code Vote up 5 votes
public Observable<Uint256> playerBalance() {
    Function function = new Function(
            "playerBalance",
            Collections.emptyList(),
            Collections.singletonList(new TypeReference<Uint256>() {
            }));
    return executeCallSingleValueReturnObservable(function);
}
 
Example 4
Project: QDrill   File: UnorderedDeMuxExchange.java   View Source Code Vote up 5 votes
@Override
public Receiver getReceiver(int minorFragmentId) {
  createSenderReceiverMapping();

  MinorFragmentEndpoint sender = receiverToSenderMapping.get(minorFragmentId);
  if (sender == null) {
    throw new IllegalStateException(String.format("Failed to find sender for receiver [%d]", minorFragmentId));
  }

  return new UnorderedReceiver(this.senderMajorFragmentId, Collections.singletonList(sender), false);
}
 
Example 5
Project: elasticsearch_my   File: DateIndexNameProcessor.java   View Source Code Vote up 5 votes
@Override
public DateIndexNameProcessor create(Map<String, Processor.Factory> registry, String tag,
                                     Map<String, Object> config) throws Exception {
    String localeString = ConfigurationUtils.readOptionalStringProperty(TYPE, tag, config, "locale");
    String timezoneString = ConfigurationUtils.readOptionalStringProperty(TYPE, tag, config, "timezone");
    DateTimeZone timezone = timezoneString == null ? DateTimeZone.UTC : DateTimeZone.forID(timezoneString);
    Locale locale = Locale.ENGLISH;
    if (localeString != null) {
        try {
            locale = (new Locale.Builder()).setLanguageTag(localeString).build();
        } catch (IllformedLocaleException e) {
            throw new IllegalArgumentException("Invalid language tag specified: " + localeString);
        }
    }
    List<String> dateFormatStrings = ConfigurationUtils.readOptionalList(TYPE, tag, config, "date_formats");
    if (dateFormatStrings == null) {
        dateFormatStrings = Collections.singletonList("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
    }
    List<Function<String, DateTime>> dateFormats = new ArrayList<>(dateFormatStrings.size());
    for (String format : dateFormatStrings) {
        DateFormat dateFormat = DateFormat.fromString(format);
        dateFormats.add(dateFormat.getFunction(format, timezone, locale));
    }

    String field = ConfigurationUtils.readStringProperty(TYPE, tag, config, "field");
    String indexNamePrefix = ConfigurationUtils.readStringProperty(TYPE, tag, config, "index_name_prefix", "");
    String dateRounding = ConfigurationUtils.readStringProperty(TYPE, tag, config, "date_rounding");
    String indexNameFormat = ConfigurationUtils.readStringProperty(TYPE, tag, config, "index_name_format", "yyyy-MM-dd");
    return new DateIndexNameProcessor(tag, field, dateFormats, timezone, indexNamePrefix, dateRounding, indexNameFormat);
}
 
Example 6
Project: SlotNSlot_Android   File: Hello.java   View Source Code Vote up 5 votes
public Observable<Uint256> say2(Uint256 input) {
    Function function = new Function(
            "say2",
            Collections.singletonList(input),
            Collections.singletonList(new TypeReference<Uint256>() {
            })
    );

    return executeCallSingleValueReturnObservable(function);
}
 
Example 7
Project: Phoenix-for-VK   File: ChatsInfoAdapter.java   View Source Code Vote up 5 votes
@Override
public ChatsInfoResponse deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    List<VKApiChat> chats;

    if(json.isJsonObject()){
        chats = Collections.singletonList(context.deserialize(json, VKApiChat.class));
    } else {
        JsonArray array = json.getAsJsonArray();
        chats = parseArray(array, VKApiChat.class, context, Collections.emptyList());
    }

    ChatsInfoResponse response = new ChatsInfoResponse();
    response.chats = chats;
    return response;
}
 
Example 8
Project: catalog-api-demo   File: ErrorTest.java   View Source Code Vote up 5 votes
@Test public void checkAndLogErrors_hasCodeAndCategory() {
  List<Error> errors = Collections.singletonList(new Error()
      .category(CategoryEnum.INVALID_REQUEST_ERROR)
      .code(CodeEnum.BAD_REQUEST)
      .detail("detail"));
  Errors.checkAndLogErrors(errors, logger);
  verify(logger).error("[INVALID_REQUEST_ERROR:BAD_REQUEST] detail");
}
 
Example 9
Project: ZorahPractice   File: PartyLeaveArgument.java   View Source Code Vote up 5 votes
public void onCommand(CommandSender sender, String[] args) throws CommandException {
    Player player = (Player) sender;
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    if (profile.getParty() == null) {
        throw new CommandException(Collections.singletonList("You do not have a party."));
    }

    if (profile.getParty().getLeader().equals(player)) {
        throw new CommandException(Collections.singletonList("You cannot leave your own party. Try using /party disband."));
    }

    PlayerLeavePartyEvent partyEvent = new PlayerLeavePartyEvent(player, profile.getParty(), true, true);
    Bukkit.getPluginManager().callEvent(partyEvent);
}
 
Example 10
Project: GitHub   File: MainActivity.java   View Source Code Vote up 4 votes
@Override
public List<Api.GifResult> getPreloadItems(int position) {
  return Collections.singletonList(results[position]);
}
 
Example 11
Project: kafka-0.11.0.0-src-with-comment   File: CompositeReadOnlyKeyValueStoreTest.java   View Source Code Vote up 4 votes
private CompositeReadOnlyKeyValueStore<Object, Object> rebalancing() {
    return new CompositeReadOnlyKeyValueStore<>(new WrappingStoreProvider(Collections.<StateStoreProvider>singletonList(new StateStoreProviderStub(true))),
            QueryableStoreTypes.keyValueStore(), storeName);
}
 
Example 12
Project: CalendarFX   File: TimeRangeField.java   View Source Code Vote up 4 votes
@Override
public Collection<ViewType> getViewTypes() {
    return Collections.singletonList(ViewType.WEEK_VIEW);
}
 
Example 13
Project: SteamAPI   File: ICheatReportingServiceGetCheatingReports.java   View Source Code Vote up 4 votes
public ICheatReportingServiceGetCheatingReports(ICheatReportingService steamInterface) {
    super(
        steamInterface,
        "GetCheatingReports",
        Collections.singletonList(
            SteamMethodVersion.create()
                .method(SteamHTTPMethod.GET)
                .hosts(SteamHost.PUBLIC, SteamHost.PARTNER)
                .version(SteamVersion.V_1)
                .visibility(SteamVisibility.PUBLISHER)
                .add(new KeyOption(true))
                .add(new AppIDOption(true))
                .add(new TimeBeginOption(true))
                .add(new TimeEndOption(true))
                .add(new SteamIDOption(false))
                .add(
                    Option.create()
                        .key("reportidmin")
                        .description("Minimum reportID to include.")
                        .optionType(OptionTypes.UINT_64)
                        .isRequired(true)
                    .build()
                )
                .add(
                    Option.create()
                        .key("includereports")
                        .description("Include reports.")
                        .optionType(OptionTypes.BOOL)
                        .isRequired(false)
                    .build()
                )
                .add(
                    Option.create()
                        .key("includebans")
                        .description("Include ban requests.")
                        .optionType(OptionTypes.BOOL)
                        .isRequired(true)
                    .build()
                )
            .build()
        )
    );
}
 
Example 14
Project: Equella   File: UserScriptContributeSection.java   View Source Code Vote up 4 votes
@Override
protected Collection<EntityEditor<UserScriptEditingBean, UserScript>> getAllEditors()
{
	return Collections.singletonList((EntityEditor<UserScriptEditingBean, UserScript>) userScriptEditorSection);
}
 
Example 15
Project: AppRTC-Android   File: PeerConnection.java   View Source Code Vote up 4 votes
public static Builder builder(String uri) {
  return new Builder(Collections.singletonList(uri));
}
 
Example 16
Project: Elasticsearch   File: AliasOrIndex.java   View Source Code Vote up 4 votes
@Override
public List<IndexMetaData> getIndices() {
    return Collections.singletonList(concreteIndex);
}
 
Example 17
Project: react-native-fast-image   File: FastImageViewPackage.java   View Source Code Vote up 4 votes
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    return Collections.<NativeModule>singletonList(new FastImageViewModule(reactContext));
}
 
Example 18
Project: dbadvisor   File: FallBackPrivilegedDataSourceProvider.java   View Source Code Vote up 4 votes
@Override
public List<String> getSchemas() {
    return Collections.singletonList(schemaName);
}
 
Example 19
Project: cyberduck   File: UploadTransfer.java   View Source Code Vote up 4 votes
public UploadTransfer(final Host host, final Path root, final Local local, final Filter<Local> f) {
    this(host, Collections.singletonList(new TransferItem(root, local)), f);
}
 
Example 20
Project: abhot   File: KairosDatastore.java   View Source Code Vote up 3 votes
public List<DataPointGroup> queryTags(QueryMetric metric) throws DatastoreException
{
	TagSet tagSet = m_datastore.queryMetricTags(metric);

	return Collections.<DataPointGroup>singletonList(new EmptyDataPointGroup(metric.getName(), tagSet));

}