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

The following examples show how to use java.util.Collections#singletonList() . 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: PhoenixStatement.java    From phoenix with 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
Source File: TsExtractor.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @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
Source File: SQLExecuteHelper.java    From netbeans with 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 4
Source File: CatalogConfig.java    From cloudfoundry-service-broker with Apache License 2.0 6 votes vote down vote up
@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 5
Source File: DockerServerCredentialsHandler.java    From docker-commons-plugin with MIT License 5 votes vote down vote up
@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
Source File: AccountServiceWSTest.java    From development with Apache License 2.0 5 votes vote down vote up
@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
Source File: URICertStore.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source File: PackagedWorkflowManager.java    From wings with 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 9
Source File: SlowInstanceDiagnoserTest.java    From incubator-heron with Apache License 2.0 5 votes vote down vote up
@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 10
Source File: OrchestrationShardingSphereDataSource.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
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 11
Source File: EmbeddedKafkaCluster.java    From nd4j with Apache License 2.0 4 votes vote down vote up
public EmbeddedKafkaCluster(String zkConnection, Properties baseProperties) {
    this(zkConnection, baseProperties, Collections.singletonList(-1));
}
 
Example 12
Source File: RespawnPacket.java    From ProtocolSupportBungee with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Collection<PacketWrapper> toNative() {
	return Collections.singletonList(new PacketWrapper(new Respawn(dimension, 0, (short) difficulty, (short) gamemode, levelType), Unpooled.wrappedBuffer(readbytes)));
}
 
Example 13
Source File: HomeCommand.java    From IridiumSkyblock with GNU General Public License v2.0 4 votes vote down vote up
public HomeCommand() {
    super(Collections.singletonList("home"), "Teleport to your island home", "", true);
}
 
Example 14
Source File: GenerateUUIDBuilder.java    From kite with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<String> getNames() {
  return Collections.singletonList("generateUUID");
}
 
Example 15
Source File: AnyInValueSetInvocation.java    From clinical_quality_language with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<Expression> getOperands() {
    return Collections.singletonList(((AnyInValueSet) expression).getCodes());
}
 
Example 16
Source File: AndroidKeyAuthenticatorRegistrationValidationTest.java    From webauthn4j with Apache License 2.0 4 votes vote down vote up
@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 17
Source File: GenerateGrapqlSDL.java    From barleydb with GNU Lesser General Public License v3.0 4 votes vote down vote up
public List<Argument> getPrimaryKeyArguments() {
	NodeSpec nt = et.getPrimaryKeyNodes(true).iterator().next();
	return Collections.singletonList(new NodeQueryArgument(nt));
}
 
Example 18
Source File: PreExtendedPermissions.java    From drftpd with GNU General Public License v2.0 4 votes vote down vote up
@Override
public List<PermissionDefinition> permissions() {
    PermissionDefinition pre = new PermissionDefinition("pre",
            DefaultConfigHandler.class, "handlePathPerm");
    return Collections.singletonList(pre);
}
 
Example 19
Source File: ScalarMax.java    From deeplearning4j with 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 20
Source File: ApiClient.java    From openapi-generator with 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())));
}