Example usage for java.util Collections singletonList

List of usage examples for java.util Collections singletonList

Introduction

In this page you can find the example usage for java.util Collections singletonList.

Prototype

public static <T> List<T> singletonList(T o) 

Source Link

Document

Returns an immutable list containing only the specified object.

Usage

From source file:eu.over9000.cathode.data.parameters.ReactionOption.java

@Override
public List<NameValuePair> buildParamPairs() {
    return Collections.singletonList(new BasicNameValuePair("emote_id", value));
}

From source file:com.kantenkugel.discordbot.jdocparser.JDoc.java

public static List<Documentation> get(final String name) {
    final String[] split = name.toLowerCase().split("[#.]");
    JDocParser.ClassDocumentation classDoc;
    synchronized (docs) {
        if (!docs.containsKey(split[0]))
            return Collections.emptyList();
        classDoc = docs.get(split[0]);/* w ww .  ja  va  2 s  .co m*/
    }
    for (int i = 1; i < split.length - 1; i++) {
        if (!classDoc.subClasses.containsKey(split[i]))
            return Collections.emptyList();
        classDoc = classDoc.subClasses.get(split[i]);
    }

    String searchObj = split[split.length - 1];
    if (split.length == 1 || classDoc.subClasses.containsKey(searchObj)) {
        if (split.length > 1)
            classDoc = classDoc.subClasses.get(searchObj);
        return Collections.singletonList(classDoc);
    } else if (classDoc.classValues.containsKey(searchObj)) {
        return Collections.singletonList(classDoc.classValues.get(searchObj));
    } else {
        boolean fuzzy = false;
        String fixedSearchObj = searchObj;
        if (fixedSearchObj.charAt(fixedSearchObj.length() - 1) != ')') {
            fixedSearchObj += "()";
            fuzzy = true;
        }
        String[] methodParts = fixedSearchObj.split("[()]");
        String methodName = methodParts[0];
        if (classDoc.methodDocs.containsKey(methodName.toLowerCase())) {
            return getMethodDocs(classDoc, methodName, fixedSearchObj, fuzzy);
        } else if (classDoc.inheritedMethods.containsKey(methodName.toLowerCase())) {
            return get(classDoc.inheritedMethods.get(methodName.toLowerCase()) + '.' + searchObj);
        }
        return Collections.emptyList();
    }
}

From source file:eu.europa.ec.fisheries.uvms.rules.mapper.AbstractRulesBaseMapper.java

List<String> splitSingleStringByComma(String xpathListCommaSeparated) {
    if (StringUtils.isEmpty(xpathListCommaSeparated)) {
        return Collections.singletonList(null);
    }//from  ww  w.jav a  2s  .c  om
    return Arrays.asList(xpathListCommaSeparated.split("\\s*,\\s*"));
}

From source file:com.orange.cepheus.broker.Util.java

static public NotifyContext createNotifyContextTempSensor(float randomValue) throws URISyntaxException {

    NotifyContext notifyContext = new NotifyContext("1", new URI("http://iotAgent"));
    ContextElementResponse contextElementResponse = new ContextElementResponse();
    contextElementResponse.setContextElement(createTemperatureContextElement(randomValue));
    contextElementResponse.setStatusCode(new StatusCode(CODE_200));
    notifyContext.setContextElementResponseList(Collections.singletonList(contextElementResponse));

    return notifyContext;
}

From source file:com.haulmont.cuba.core.sys.jpql.Parser.java

public static List<JoinVariableNode> parseJoinClause(String join) throws RecognitionException {
    JPA2Parser parser = createParser(join);
    JPA2Parser.join_section_return aReturn = parser.join_section();
    CommonTree tree = (CommonTree) aReturn.getTree();
    if (tree == null) {
        parser = createParser("join " + join);
        aReturn = parser.join_section();
        tree = (CommonTree) aReturn.getTree();
    }/*from  ww  w.j av  a2 s .  c  om*/
    if (tree instanceof JoinVariableNode) {
        checkTreeForExceptions(join, tree);
        return Collections.singletonList((JoinVariableNode) tree);
    } else {
        List<JoinVariableNode> joins = tree.getChildren().stream()
                .filter(node -> node instanceof JoinVariableNode).map(JoinVariableNode.class::cast)
                .collect(Collectors.toList());
        checkTreeForExceptions(join, tree);
        return joins;
    }
}

From source file:bg.neutrino.GoogleLogin.java

public User login() throws Exception {
    DeviceProperties dp = new DeviceProperties();
    String CLIENT_ID = dp.get().getProperty("google.oauth2.api.key");

    GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(transport, jacksonFactory)
            .setAudience(Collections.singletonList(CLIENT_ID))
            // Or, if multiple clients access the backend:
            // .setAudience(Arrays.asList(CLIENT_ID_1, CLIENT_ID_2,
            // CLIENT_ID_3))
            .build();/*from ww  w. ja  va2 s  . co  m*/

    // (Receive idTokenString by HTTPS POST)
    //System.out.println(idTokenString);

    GoogleIdToken idToken = null;
    try {
        idToken = verifier.verify(idTokenString);
    } catch (GeneralSecurityException | IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    if (idToken != null) {
        Payload payload = idToken.getPayload();

        // Print user identifier
        String userId = payload.getSubject();
        //System.out.println("User ID: " + userId);

        // Get profile information from payload
        String email = payload.getEmail();
        boolean emailVerified = Boolean.valueOf(payload.getEmailVerified());
        String name = (String) payload.get("name");
        String pictureUrl = (String) payload.get("picture");
        String locale = (String) payload.get("locale");
        String familyName = (String) payload.get("family_name");
        String givenName = (String) payload.get("given_name");

        User user = new User();
        user.setId(userId);
        user.setEmail(email);
        user.setName(name);
        user.setIsGuest(false);

        return user;

    } else {
        throw new Exception("Invalid ID token.");
    }
}

From source file:io.syndesis.controllers.integration.NoopHandlerProvider.java

@Override
public List<StatusChangeHandler> getStatusChangeHandlers() {
    return Collections.singletonList(this);
}

From source file:io.relution.jenkins.awssqs.model.CodeCommitMessageParser.java

@Override
public List<ExecuteJenkinsJobEvent> parseMessage(final Message message) {
    try {/*from  www . java2  s.  c  o m*/
        String body = message.getBody();
        io.relution.jenkins.awssqs.logging.Log.info("Found json body: '%s'", body);
        return Collections.singletonList(this.gson.fromJson(body, ExecuteJenkinsJobEvent.class));
        //            Log.info("Got message with subject: %s", body.getSubject());
        //            final String json = body.getMessage();
        //            Log.info("Body of the message: %s", json);
        //            if (StringUtils.isEmpty(json)) {
        //                Log.warning("Message contains no text");
        //                return Collections.emptyList();
        //            }
        //
        //            if (!json.startsWith("{") || !json.endsWith("}")) {
        //                Log.warning("Message text is no JSON");
        //                return Collections.emptyList();
        //            }
        ////            return new ArrayList<Event>();
        //            return this.parseRecords(json);
    } catch (final com.google.gson.JsonSyntaxException e) {
        io.relution.jenkins.awssqs.logging.Log.warning("JSON syntax exception, cannot parse message: %s", e);
    }
    return Collections.emptyList();
}

From source file:com.dangdang.example.elasticjob.spring.job.SequenceDataFlowJobDemo.java

@Override
public List<Foo> fetchData(final JobExecutionSingleShardingContext context) {
    printContext.printFetchDataMessage(context.getShardingItem());
    return fooRepository.findActive(Collections.singletonList(context.getShardingItem()));
}

From source file:org.yamj.api.trakttv.model.SyncItems.java

public SyncItems movie(SyncMovie movie) {
    this.movies = Collections.singletonList(movie);
    return this;
}