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

The following examples show how to use java.util.Collections#singletonList() . These examples are extracted from open source projects. 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 Project: phoenix   File: PhoenixStatement.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public MutationPlan compilePlan(final PhoenixStatement stmt, Sequence.ValueOp seqAction) throws SQLException {
    final StatementContext context = new StatementContext(stmt);
    return new BaseMutationPlan(context, this.getOperation()) {
        @Override
        public ExplainPlan getExplainPlan() throws SQLException {
            return new ExplainPlan(Collections.singletonList("ALTER INDEX"));
        }

        @Override
        public MutationState execute() throws SQLException {
            MetaDataClient client = new MetaDataClient(getContext().getConnection());
            return client.alterIndex(ExecutableAlterIndexStatement.this);
        }
    };
}
 
Example 2
/**
 * @param mode Mode for the extractor. One of {@link #MODE_MULTI_PMT}, {@link #MODE_SINGLE_PMT}
 *     and {@link #MODE_HLS}.
 * @param timestampAdjuster A timestamp adjuster for offsetting and scaling sample timestamps.
 * @param payloadReaderFactory Factory for injecting a custom set of payload readers.
 */
public TsExtractor(
    @Mode int mode,
    TimestampAdjuster timestampAdjuster,
    TsPayloadReader.Factory payloadReaderFactory) {
  this.payloadReaderFactory = Assertions.checkNotNull(payloadReaderFactory);
  this.mode = mode;
  if (mode == MODE_SINGLE_PMT || mode == MODE_HLS) {
    timestampAdjusters = Collections.singletonList(timestampAdjuster);
  } else {
    timestampAdjusters = new ArrayList<>();
    timestampAdjusters.add(timestampAdjuster);
  }
  tsPacketBuffer = new ParsableByteArray(new byte[BUFFER_SIZE], 0);
  trackIds = new SparseBooleanArray();
  trackPids = new SparseBooleanArray();
  tsPayloadReaders = new SparseArray<>();
  continuityCounters = new SparseIntArray();
  durationReader = new TsDurationReader();
  pcrPid = -1;
  resetPayloadReaders();
}
 
Example 3
@Bean
public Catalog catalog() {
	return new Catalog(Collections.singletonList(
			new ServiceDefinition(
					"mongodb-service-broker",
					"mongodb",
					"A simple MongoDB service broker implementation",
					true,
					false,
					Collections.singletonList(
							new Plan("mongo-plan",
									"default",
									"This is a default mongo plan.  All services are created equally.",
									getPlanMetadata())),
					Arrays.asList("mongodb", "document"),
					getServiceDefinitionMetadata(),
					null,
					null)));
}
 
Example 4
Source Project: netbeans   File: SQLExecuteHelper.java    License: Apache License 2.0 6 votes vote down vote up
private static List<StatementInfo> getStatements(String script, int startOffset, int endOffset,
        Compatibility compat) {
    if ((startOffset == 0 && endOffset == script.length()) || (startOffset == endOffset)) {
        // Either the whole script, or the statement at offset startOffset.
        List<StatementInfo> allStatements = split(script, compat);
        if (startOffset == 0 && endOffset == script.length()) {
            return allStatements;
        }
        // Just the statement at offset startOffset.
        StatementInfo foundStatement = findStatementAtOffset(
                allStatements, startOffset, script);
        return foundStatement == null
                ? Collections.<StatementInfo>emptyList()
                : Collections.singletonList(foundStatement);
    } else {
        // Just execute the selected subscript.
        return split(script.substring(startOffset, endOffset), compat);
    }
}
 
Example 5
@Nonnull
@Override
public List<Map<String, Object>> getWithCredentialsParameters(String credentialsId) {
    Map<String, Object> map = new HashMap<>();
    map.put("$class", DockerServerCredentialsBinding.class.getName());
    map.put("variable", new EnvVarResolver());
    map.put("credentialsId", credentialsId);
    return Collections.singletonList(map);
}
 
Example 6
@Test(expected = ValidationException.class)
public void saveUdaDefinitions_EmptyTargetType() throws Exception {
    List<VOUdaDefinition> list = Collections
            .singletonList(createVOUdaDefinition("   ", "UDA", null,
                    UdaConfigurationType.SUPPLIER));
    accountService_Supplier.saveUdaDefinitions(list,
            new ArrayList<VOUdaDefinition>());
}
 
Example 7
/**
 * Checks if the specified X509CRL matches the criteria specified in the
 * CRLSelector.
 */
private static Collection<X509CRL> getMatchingCRLs
    (X509CRL crl, CRLSelector selector) {
    if (selector == null || (crl != null && selector.match(crl))) {
        return Collections.singletonList(crl);
    } else {
        return Collections.emptyList();
    }
}
 
Example 8
@Test
public void failsIfNoBufferSizeDisparity() {
  Symptom symptom = new Symptom(SYMPTOM_COMP_BACK_PRESSURE.text(), Instant.now(), null);
  Collection<Symptom> symptoms = Collections.singletonList(symptom);

  Collection<Diagnosis> result = diagnoser.diagnose(symptoms);
  assertEquals(0, result.size());
}
 
Example 9
public OrchestrationShardingSphereDataSource(final OrchestrationConfiguration orchestrationConfig) throws SQLException {
    super(new ShardingOrchestrationFacade(orchestrationConfig, Collections.singletonList(DefaultSchema.LOGIC_NAME)));
    ConfigCenter configService = getShardingOrchestrationFacade().getConfigCenter();
    Collection<RuleConfiguration> configurations = configService.loadRuleConfigurations(DefaultSchema.LOGIC_NAME);
    Preconditions.checkState(!configurations.isEmpty(), "Missing the sharding rule configuration on registry center");
    Map<String, DataSourceConfiguration> dataSourceConfigurations = configService.loadDataSourceConfigurations(DefaultSchema.LOGIC_NAME);
    dataSource = new ShardingSphereDataSource(DataSourceConverter.getDataSourceMap(dataSourceConfigurations), configurations, configService.loadProperties());
    initShardingOrchestrationFacade();
    disableDataSources();
    persistMetaData(dataSource.getSchemaContexts().getDefaultSchemaContext().getSchema().getMetaData().getSchema());
    initCluster();
}
 
Example 10
Source Project: wings   File: PackagedWorkflowManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Parse a workflow
 * 
 * @param workflowID
 *          workflow id
 * @param workflowXML
 *          xml representation of the workflow including all tasks
 * @return a workflow
 * @throws RepositoryException
 */
public Workflow parsePackagedWorkflow(String workflowID, String workflowXML)
    throws RepositoryException {
  try {
    File tmpfile = File.createTempFile("tempworkflow-", "-packaged");
    FileUtils.writeStringToFile(tmpfile, workflowXML);
    PackagedWorkflowRepository tmprepo = new PackagedWorkflowRepository(
        Collections.singletonList(tmpfile));
    tmpfile.delete();
    return tmprepo.getWorkflowById(workflowID);
  } catch (Exception e) {
    throw new RepositoryException("Failed to parse workflow xml: "
        + e.getMessage());
  }
}
 
Example 11
@Override
public Collection<PacketWrapper> toNative() {
	return Collections.singletonList(new PacketWrapper(new Respawn(dimension, 0, (short) difficulty, (short) gamemode, levelType), Unpooled.wrappedBuffer(readbytes)));
}
 
Example 12
Source Project: deeplearning4j   File: ScalarMax.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public List<SDVariable> doDiff(List<SDVariable> i_v1) {
    SDVariable mask = arg().gt(scalarValue.getDouble(0)).castTo(arg().dataType());
    return Collections.singletonList(i_v1.get(0).mul(mask));
}
 
Example 13
@Override
public List<PermissionDefinition> permissions() {
    PermissionDefinition pre = new PermissionDefinition("pre",
            DefaultConfigHandler.class, "handlePathPerm");
    return Collections.singletonList(pre);
}
 
Example 14
public List<Argument> getPrimaryKeyArguments() {
	NodeSpec nt = et.getPrimaryKeyNodes(true).iterator().next();
	return Collections.singletonList(new NodeQueryArgument(nt));
}
 
Example 15
@Test
void validate_RegistrationContext_with_android_key_attestation_statement_test() {
    String rpId = "example.com";
    Challenge challenge = new DefaultChallenge();
    AuthenticatorSelectionCriteria authenticatorSelectionCriteria =
            new AuthenticatorSelectionCriteria(
                    AuthenticatorAttachment.CROSS_PLATFORM,
                    true,
                    UserVerificationRequirement.REQUIRED);

    PublicKeyCredentialParameters publicKeyCredentialParameters = new PublicKeyCredentialParameters(PublicKeyCredentialType.PUBLIC_KEY, COSEAlgorithmIdentifier.ES256);

    PublicKeyCredentialUserEntity publicKeyCredentialUserEntity = new PublicKeyCredentialUserEntity();

    AuthenticationExtensionsClientInputs<RegistrationExtensionClientInput<?>> extensions = new AuthenticationExtensionsClientInputs<>();
    PublicKeyCredentialCreationOptions credentialCreationOptions
            = new PublicKeyCredentialCreationOptions(
            new PublicKeyCredentialRpEntity(rpId, "example.com"),
            publicKeyCredentialUserEntity,
            challenge,
            Collections.singletonList(publicKeyCredentialParameters),
            null,
            Collections.emptyList(),
            authenticatorSelectionCriteria,
            AttestationConveyancePreference.DIRECT,
            extensions
    );

    PublicKeyCredential<AuthenticatorAttestationResponse, RegistrationExtensionClientOutput<?>> credential = clientPlatform.create(credentialCreationOptions);
    AuthenticatorAttestationResponse registrationRequest = credential.getAuthenticatorResponse();
    AuthenticationExtensionsClientOutputs<RegistrationExtensionClientOutput<?>> clientExtensionResults = credential.getClientExtensionResults();
    Set<String> transports = Collections.emptySet();
    String clientExtensionJSON = authenticationExtensionsClientOutputsConverter.convertToString(clientExtensionResults);
    ServerProperty serverProperty = new ServerProperty(origin, rpId, challenge, null);
    RegistrationRequest webAuthnRegistrationRequest
            = new RegistrationRequest(
            registrationRequest.getAttestationObject(),
            registrationRequest.getClientDataJSON(),
            clientExtensionJSON,
            transports
    );
    RegistrationParameters webAuthnRegistrationParameters
            = new RegistrationParameters(
            serverProperty,
            false,
            true,
            Collections.emptyList()
    );

    RegistrationData response = target.validate(webAuthnRegistrationRequest, webAuthnRegistrationParameters);

    assertAll(
            () -> assertThat(response.getCollectedClientData()).isNotNull(),
            () -> assertThat(response.getAttestationObject()).isNotNull(),
            () -> assertThat(response.getClientExtensions()).isNotNull()
    );
}
 
Example 16
@Override
public Iterable<Expression> getOperands() {
    return Collections.singletonList(((AnyInValueSet) expression).getCodes());
}
 
Example 17
Source Project: kite   File: GenerateUUIDBuilder.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Collection<String> getNames() {
  return Collections.singletonList("generateUUID");
}
 
Example 18
public HomeCommand() {
    super(Collections.singletonList("home"), "Teleport to your island home", "", true);
}
 
Example 19
Source Project: nd4j   File: EmbeddedKafkaCluster.java    License: Apache License 2.0 4 votes vote down vote up
public EmbeddedKafkaCluster(String zkConnection, Properties baseProperties) {
    this(zkConnection, baseProperties, Collections.singletonList(-1));
}
 
Example 20
Source Project: openapi-generator   File: ApiClient.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Convert a URL query name/value parameter to a list of encoded {@link Pair}
 * objects.
 *
 * <p>The value can be null, in which case an empty list is returned.</p>
 *
 * @param name The query name parameter.
 * @param value The query value, which may not be a collection but may be
 *              null.
 * @return A singleton list of the {@link Pair} objects representing the input
 * parameters, which is encoded for use in a URL. If the value is null, an
 * empty list is returned.
 */
public static List<Pair> parameterToPairs(String name, Object value) {
  if (name == null || name.isEmpty() || value == null) {
    return Collections.emptyList();
  }
  return Collections.singletonList(new Pair(urlEncode(name), urlEncode(value.toString())));
}