Example usage for java.util LinkedHashSet add

List of usage examples for java.util LinkedHashSet add

Introduction

In this page you can find the example usage for java.util LinkedHashSet add.

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:com.redhat.rhn.frontend.action.token.configuration.RankChannelsAction.java

/**
 *
 * {@inheritDoc}//w ww  . j a  v a 2 s. c  o  m
 */
private void populateWidgetLabels(LinkedHashSet labelValues, RequestContext context) {

    ActivationKey key = context.lookupAndBindActivationKey();
    for (ConfigChannel channel : key.getConfigChannelsFor(context.getCurrentUser())) {
        labelValues.add(lv(channel.getName(), channel.getId().toString()));
    }
}

From source file:org.mule.runtime.extension.api.persistence.BasePersistenceTestCase.java

@Before
public void setUp() throws IOException {
    final ImmutableParameterModel carNameParameter = new ImmutableParameterModel(CAR_NAME_PARAMETER_NAME,
            "Name of the car", stringType, true, false, false, SUPPORTED, "", BEHAVIOUR, defaultParameterDsl,
            defaultDisplayModel, defaultLayoutModel, emptySet());

    final ImmutableParameterModel usernameParameter = new ImmutableParameterModel("username", "Username",
            stringType, true, true, false, SUPPORTED, "", BEHAVIOUR, defaultParameterDsl, defaultDisplayModel,
            defaultLayoutModel, emptySet());
    final ImmutableParameterModel passwordParameter = new ImmutableParameterModel("password", "Password",
            stringType, false, true, false, SUPPORTED, "", BEHAVIOUR, defaultParameterDsl, defaultDisplayModel,
            defaultLayoutModel, emptySet());
    final ImmutableParameterModel complexParameter = new ImmutableParameterModel(COMPLEX_PARAMETER_NAME,
            "complex type to serialize",
            ExtensionsTypeLoaderFactory.getDefault().createTypeLoader().load(ComplexFieldsType.class), false,
            true, false, SUPPORTED, null, BEHAVIOUR, defaultParameterDsl, defaultDisplayModel,
            defaultLayoutModel, emptySet());

    String schema = IOUtils.toString(Thread.currentThread().getContextClassLoader()
            .getResourceAsStream(CREATE_CUSTOMER_REQUEST_TYPE_SCHEMA_JSON));
    final MetadataType jsonLoadedType = new JsonTypeLoader(schema).load("").get();
    final ImmutableParameterModel loadedParameter = new ImmutableParameterModel(LOADED_PARAMETER_NAME,
            "loaded type from json to serialize", jsonLoadedType, false, true, false, SUPPORTED, null,
            BEHAVIOUR, defaultParameterDsl, defaultDisplayModel, defaultLayoutModel, emptySet());

    exportedType = typeBuilder.objectType().id(TEST_PACKAGE_EXPORTED_CLASS)
            .with(new ClassInformationAnnotation(ExportedClass.class, emptyList()))
            .with(new TypeAliasAnnotation(ExportedClass.class.getSimpleName())).build();

    final ImmutableParameterModel objectMap = new ImmutableParameterModel(OBJECT_MAP_NAME, "object map",
            typeBuilder.objectType().id(HashMap.class.getName()).openWith(exportedType).build(),

            false, true, false, SUPPORTED, null, BEHAVIOUR, defaultParameterDsl, defaultDisplayModel,
            defaultLayoutModel, emptySet());

    ObjectTypeBuilder typeNoId = typeBuilder.objectType();
    typeNoId.addField().key("fieldName").value(exportedType).build();
    final ImmutableParameterModel noIdParameter = new ImmutableParameterModel(NO_ID_PARAMETER_NAME,
            "type to serialize without ID", typeNoId.build(), false, true, false, SUPPORTED, null, BEHAVIOUR,
            defaultParameterDsl, defaultDisplayModel, defaultLayoutModel, emptySet());

    final ImmutableOutputModel outputModel = new ImmutableOutputModel("Message.Payload", stringType, true,
            emptySet());//from  www  .  ja v  a 2 s . c om
    final ImmutableOutputModel outputAttributesModel = new ImmutableOutputModel("Message.Attributes",
            stringType, false, emptySet());

    getCarOperation = new ImmutableOperationModel(GET_CAR_OPERATION_NAME, "Obtains a car",
            asParameterGroup(carNameParameter, complexParameter, loadedParameter), outputModel,
            outputAttributesModel, true, CPU_LITE, false, false, false, defaultDisplayModel,
            singleton(ERROR_MODEL), emptySet(), modelProperties);

    createCoreOperations();

    final ImmutableConnectionProviderModel basicAuth = new ImmutableConnectionProviderModel("BasicAuth",
            "Basic Auth Config", asParameterGroup(usernameParameter, passwordParameter, objectMap), NONE,
            externalLibrarySet(), defaultDisplayModel, emptySet());

    sourceModel = new ImmutableSourceModel(SOURCE_NAME, "A Message Source", true,
            asParameterGroup(carNameParameter, noIdParameter), outputModel, outputAttributesModel,
            Optional.of(new ImmutableSourceCallbackModel("onSuccess", "", asParameterGroup(complexParameter),
                    DisplayModel.builder().build(), emptySet())),
            Optional.empty(), false, false, false, DisplayModel.builder().build(), emptySet(), emptySet());

    LinkedHashSet<ObjectType> typesCatalog = new LinkedHashSet<>();
    typesCatalog.add(exportedType);
    typesCatalog.add((ObjectType) jsonLoadedType);

    configureOAuth();
    originalExtensionModel = new ImmutableExtensionModel("DummyExtension", "Test extension", "4.0.0",
            "MuleSoft", COMMUNITY, new MuleVersion("4.0"), emptyList(),
            asList(getCarOperation, foreachScope, choiceRouter), singletonList(basicAuth),
            singletonList(sourceModel), defaultDisplayModel, XmlDslModel.builder().build(), emptySet(),
            typesCatalog, emptySet(), emptySet(), singleton(ERROR_MODEL), externalLibrarySet(),
            singleton(accessCodeModelProperty));

    extensionModelJsonSerializer = new ExtensionModelJsonSerializer(true);
    final String serializedExtensionModelString = extensionModelJsonSerializer
            .serialize(originalExtensionModel);
    serializedExtensionModel = new JsonParser().parse(serializedExtensionModelString);
    deserializedExtensionModel = extensionModelJsonSerializer.deserialize(serializedExtensionModelString);
    operationModelProperties = serializedExtensionModel.getAsJsonObject().get(OPERATIONS_NODE).getAsJsonArray()
            .get(0).getAsJsonObject().get(MODEL_PROPERTIES_NODE).getAsJsonObject();
    extensionModelList = asList(deserializedExtensionModel, originalExtensionModel);
}

From source file:edu.ksu.cs.a4vm.bse.MatingInfo.java

@Override
public void onResume() {
    super.onResume();
    //load data//from w ww. j a v a2s .  c  om
    Util.setFields(SharedPrefUtil.getValue(getApplicationContext(), Constant.PREFS_MATING_INFO, bullKey),
            fields);
    //display toggle buttons
    Util.setToggleButtons(SharedPrefUtil.getValue(getApplicationContext(), Constant.PREFS_MATING_INFO, bullKey),
            tgBtns);

    save.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Toast.makeText(getApplicationContext(),tgbtn.getText().toString().trim() + bullKey,Toast.LENGTH_SHORT).show();
            if (tgbtn.getCurrentTextColor() == ContextCompat.getColor(getApplicationContext(),
                    R.color.colorAccent)
                    || tgbtn1.getCurrentTextColor() == ContextCompat.getColor(getApplicationContext(),
                            R.color.colorAccent)
                    || tgbtn2.getCurrentTextColor() == ContextCompat.getColor(getApplicationContext(),
                            R.color.colorAccent)
                    || tgbtn3.getCurrentTextColor() == ContextCompat.getColor(getApplicationContext(),
                            R.color.colorAccent)) {
                try {
                    if (breedSeason.getText().toString().trim().length() == 0
                            || (Integer.parseInt(breedSeason.getText().toString().trim()) > 0
                                    && Integer.parseInt(breedSeason.getText().toString().trim()) < 31)) {
                        LinkedHashSet<String> data = new LinkedHashSet<String>();
                        data.add(tgbtn.getText().toString().trim() + "=" + tgbtn.getCurrentTextColor());
                        data.add(tgbtn1.getText().toString().trim() + "=" + tgbtn1.getCurrentTextColor());
                        data.add(tgbtn2.getText().toString().trim() + "=" + tgbtn2.getCurrentTextColor());
                        data.add(tgbtn3.getText().toString().trim() + "=" + tgbtn3.getCurrentTextColor());
                        data.add(breedSeason.getHint().toString().trim() + "="
                                + breedSeason.getText().toString().trim());
                        data.add(perfDesc.getHint().toString().trim() + "="
                                + perfDesc.getText().toString().trim().replace(",", ";"));
                        data.add(comments.getHint().toString().trim() + "="
                                + comments.getText().toString().trim().replace(",", ";"));
                        data.add(sire1Btn.getText().toString().trim() + "=" + sire1Btn.getCurrentTextColor());
                        data.add(sire2Btn.getText().toString().trim() + "=" + sire2Btn.getCurrentTextColor());
                        data.add(sire3Btn.getText().toString().trim() + "=" + sire3Btn.getCurrentTextColor());

                        //save to shared pref
                        SharedPrefUtil.saveGroup(getApplicationContext(), Constant.PREFS_MATING_INFO, bullKey,
                                data);

                        Intent goPrev = new Intent(getApplicationContext(), BullExam.class);
                        goPrev.putExtra("bullKey", bullKey);
                        startActivity(goPrev);

                        Toast.makeText(getApplicationContext(), "Saved!", Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(getApplicationContext(), "Breed Season should be 1-30",
                                Toast.LENGTH_LONG).show();
                        breedSeason.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                    }
                } catch (NumberFormatException ne) {
                    if (breedSeason.getText().toString().trim().length() > 0) {
                        Toast.makeText(getApplicationContext(), "Breed Season should be 1-30",
                                Toast.LENGTH_SHORT).show();
                        breedSeason.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                    } else {
                        breedSeason.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.no_fill));
                    }

                } catch (Exception e) {
                    Toast.makeText(getApplicationContext(), "Invalid information entered", Toast.LENGTH_SHORT)
                            .show();
                }

            } else {
                Toast.makeText(getApplicationContext(), "Performance last season must be specified",
                        Toast.LENGTH_LONG).show();
            }
        }
    });

    breedSeason.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                String text = breedSeason.getText().toString().trim();
                try {
                    if (Integer.valueOf(text) > 0 && Integer.valueOf(text) < 31) {
                        breedSeason.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                    } else {
                        breedSeason.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        Toast.makeText(getApplicationContext(), "Breed Season should be 1-30",
                                Toast.LENGTH_SHORT).show();
                    }
                } catch (NumberFormatException ne) {

                    if (text.length() > 0) {
                        ne.printStackTrace();
                        breedSeason.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                        Toast.makeText(getApplicationContext(), "Invalid breed season", Toast.LENGTH_SHORT)
                                .show();
                    } else {
                        breedSeason.setBackground(
                                ContextCompat.getDrawable(getApplicationContext(), R.drawable.no_fill));
                    }

                }
            }
        }
    });

}

From source file:opennlp.tools.jsmlearning.JSMLearnerOnLatticeWithDeduction.java

public JSMDecision buildLearningModel(List<String> posTexts, List<String> negTexts, String unknown,
        String[] separationKeywords) {
    psPos = new LinguisticPatternStructure(0, 0);
    psNeg = new LinguisticPatternStructure(0, 0);
    if (separationKeywords != null) { // re-sort by occurrence of separation keyword
        Pair<List<String>, List<String>> pair = reGroupByOccurrenceOfSeparationKeyword(posTexts, negTexts,
                separationKeywords);//from  w  w  w  .ja  v  a  2  s  . c o m
        posTexts = pair.getFirst();
        negTexts = pair.getSecond();
    }

    List<List<List<ParseTreeChunk>>> lingRepsPos = new ArrayList<List<List<ParseTreeChunk>>>(),
            lingRepsNeg = new ArrayList<List<List<ParseTreeChunk>>>();
    for (String text : posTexts)
        lingRepsPos.add(chunk_maker.formGroupedPhrasesFromChunksForPara(text));

    for (String text : negTexts)
        lingRepsNeg.add(chunk_maker.formGroupedPhrasesFromChunksForPara(text));

    LinkedHashSet<Integer> obj = null;
    int i = 0;
    for (List<List<ParseTreeChunk>> chunk : lingRepsPos) {
        obj = new LinkedHashSet<Integer>();
        obj.add(i);
        psPos.AddIntent(chunk, obj, 0);
        i++;
    }
    i = 0;
    for (List<List<ParseTreeChunk>> chunk : lingRepsNeg) {
        obj = new LinkedHashSet<Integer>();
        obj.add(i);
        psNeg.AddIntent(chunk, obj, 0);
        i++;
    }

    List<List<ParseTreeChunk>> chunksUnknown = chunk_maker.formGroupedPhrasesFromChunksForPara(unknown);
    List<List<List<ParseTreeChunk>>> posIntersections = new ArrayList<List<List<ParseTreeChunk>>>(),
            negIntersections = new ArrayList<List<List<ParseTreeChunk>>>();
    List<List<ParseTreeChunk>> intersection = null;
    for (int iConcept = 0; iConcept < psPos.conceptList.size(); iConcept++) {
        if (psPos.conceptList.get(iConcept).intent != null
                && psPos.conceptList.get(iConcept).intent.size() > 0) {
            intersection = computeIntersectionWithIntentExtendedByDeduction(psPos, iConcept, chunksUnknown);
            if (reduceList(intersection).size() > 0)
                posIntersections.add(reduceList(intersection));
        }
    }
    for (int iConcept = 0; iConcept < psNeg.conceptList.size(); iConcept++) {
        if (psNeg.conceptList.get(iConcept).intent != null
                && psNeg.conceptList.get(iConcept).intent.size() > 0) {
            intersection = computeIntersectionWithIntentExtendedByDeduction(psNeg, iConcept, chunksUnknown);
            if (reduceList(intersection).size() > 0)
                negIntersections.add(reduceList(intersection));
        }
    }

    Pair<List<List<List<ParseTreeChunk>>>, List<List<List<ParseTreeChunk>>>> pair = removeInconsistenciesFromPosNegIntersections(
            posIntersections, negIntersections);

    posIntersections = pair.getFirst();
    negIntersections = pair.getSecond();

    List<List<List<ParseTreeChunk>>> posIntersectionsUnderNeg = new ArrayList<List<List<ParseTreeChunk>>>(),
            negIntersectionsUnderPos = new ArrayList<List<List<ParseTreeChunk>>>();

    for (int iConcept = 0; iConcept < psNeg.conceptList.size(); iConcept++) {
        for (int iConceptJ = 0; iConceptJ < negIntersections.size(); iConceptJ++) {
            intersection = md.matchTwoSentencesGroupedChunksDeterministic(
                    psNeg.conceptList.get(iConcept).intent, negIntersections.get(iConceptJ));
            if (reduceList(intersection).size() > 0)
                posIntersectionsUnderNeg.add(reduceList(intersection));
        }
    }

    for (int iConcept = 0; iConcept < psPos.conceptList.size(); iConcept++) {
        for (int iConceptJ = 0; iConceptJ < posIntersections.size(); iConceptJ++) {
            intersection = md.matchTwoSentencesGroupedChunksDeterministic(
                    psPos.conceptList.get(iConcept).intent, posIntersections.get(iConceptJ));
            if (reduceList(intersection).size() > 0)
                negIntersectionsUnderPos.add(reduceList(intersection));
        }
    }

    List<ParseTreeChunk> posIntersectionsUnderNegLst = flattenParseTreeChunkLst(posIntersectionsUnderNeg);
    List<ParseTreeChunk> negIntersectionsUnderPosLst = flattenParseTreeChunkLst(negIntersectionsUnderPos);

    posIntersectionsUnderNegLst = subtract(posIntersectionsUnderNegLst, negIntersectionsUnderPosLst);
    negIntersectionsUnderPosLst = subtract(negIntersectionsUnderPosLst, posIntersectionsUnderNegLst);

    System.out.println("Pos - neg inters = " + posIntersectionsUnderNegLst);
    System.out.println("Neg - pos inters = " + negIntersectionsUnderPosLst);

    Boolean bPositiveClass = (float) posIntersectionsUnderNegLst.size()
            / (float) negIntersectionsUnderPosLst.size() > 1f;

    JSMDecision decision = new JSMDecision("keywordClassName", bPositiveClass, posIntersections,
            negIntersections, posIntersectionsUnderNeg, negIntersectionsUnderPos, separationKeywords);

    accumulatedJSMResults.add(decision);

    return decision;

}

From source file:org.springsource.ide.eclipse.boot.maven.analyzer.graph.DirectedGraph.java

/**
 * Retrieve all vertices in the graph that have only outgoing but no
 * incoming edges.//from  w ww.j a va 2 s.  c  om
 */
public Collection<Object> getRoots() {
    final LinkedHashSet<Object> roots = new LinkedHashSet<Object>();
    for (Object node : getNodes()) {
        Collection<Object> parents = getPredecessors(node);
        if (parents.isEmpty()) {
            roots.add(node);
        }
    }
    return roots;
}

From source file:com.enonic.cms.core.content.imports.ImportDataReaderXml.java

private LinkedHashSet<String> getStringValues(final NodeInfo nodeInfo, final String xpath)
        throws XPathException {
    final XPathExpression expr = getXPathExpression(nodeInfo, xpath);
    final List<Object> os = expr.evaluate(nodeInfo);

    final LinkedHashSet<String> values = new LinkedHashSet<String>();
    for (Object o : os) {
        values.add(getStringValue(o));
    }/*from   w  w w.  ja  v a 2s .com*/
    return values;
}

From source file:org.search.niem.uml.qvt.NiemQvtLibrary.java

@Operation(contextual = true, kind = Operation.Kind.QUERY)
public static LinkedHashSet<Object> getElementElements(final Object self) {
    final org.w3c.dom.Element element = (org.w3c.dom.Element) self;
    final NodeList childNodes = element.getChildNodes();
    final LinkedHashSet<Object> childElements = new LinkedHashSet<>();
    for (int i = 0; i < childNodes.getLength(); i++) {
        final Node childNode = childNodes.item(i);
        if (childNode instanceof org.w3c.dom.Element) {
            childElements.add(childNode);
        }//from   w  w  w .j  av a2 s.  c om
    }
    return childElements;
}

From source file:edu.ksu.cs.a4vm.bse.Motility.java

@Override
public void onResume() {
    super.onResume();
    try {/*  w w  w . jav  a 2  s.co  m*/
        //display fields
        Util.setFields(SharedPrefUtil.getValue(getApplicationContext(), Constant.PREFS_MOTILITY_INFO, bullKey),
                fields);
        //display toggle buttons
        Util.setToggleButtons(
                SharedPrefUtil.getValue(getApplicationContext(), Constant.PREFS_MOTILITY_INFO, bullKey),
                tgBtns);

        tgbtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Util.changeToggleColor(tgbtn, getApplicationContext());
                tgbtn1.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
                tgbtn2.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
                tgbtn3.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
            }
        });

        tgbtn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Util.changeToggleColor(tgbtn1, getApplicationContext());
                tgbtn.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
                tgbtn2.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
                tgbtn3.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
            }
        });

        tgbtn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Util.changeToggleColor(tgbtn2, getApplicationContext());
                tgbtn.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
                tgbtn1.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
                tgbtn3.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
            }
        });

        tgbtn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Util.changeToggleColor(tgbtn3, getApplicationContext());
                tgbtn.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
                tgbtn1.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
                tgbtn2.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.lightBlue));
            }
        });

        ringsDesc.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (!hasFocus) {
                    String text = ringsDesc.getText().toString().trim();
                    try {
                        if (text.length() == 0
                                || (Float.valueOf(text) >= 0.0 && Float.valueOf(text) <= 100.0)) {
                            ringsDesc.setBackground(
                                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                        } else {
                            ringsDesc.setBackground(
                                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                            Toast.makeText(getApplicationContext(), "Value must be between 0-100",
                                    Toast.LENGTH_SHORT).show();
                        }
                    } catch (NumberFormatException ne) {
                        if (text.length() > 0) {
                            ringsDesc.setBackground(
                                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                            Toast.makeText(getApplicationContext(), "Invalid entry", Toast.LENGTH_SHORT).show();
                        } else {
                            ringsDesc.setBackground(
                                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.no_fill));
                        }

                    }
                }
            }
        });

        scrotalDesc.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (!hasFocus) {
                    String text = scrotalDesc.getText().toString().trim();
                    try {
                        if (text.length() == 0
                                || (Float.valueOf(text) >= 0.0 && Float.valueOf(text) <= 100.0)) {
                            scrotalDesc.setBackground(
                                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.focus_color));
                        } else {
                            scrotalDesc.setBackground(
                                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                            Toast.makeText(getApplicationContext(), "Value must be between 0-100",
                                    Toast.LENGTH_SHORT).show();
                        }
                    } catch (NumberFormatException ne) {
                        if (text.length() > 0) {
                            scrotalDesc.setBackground(
                                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.highlight));
                            Toast.makeText(getApplicationContext(), "Invalid entry", Toast.LENGTH_SHORT).show();
                        } else {
                            scrotalDesc.setBackground(
                                    ContextCompat.getDrawable(getApplicationContext(), R.drawable.no_fill));
                        }

                    }
                }
            }
        });

        save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (tgbtn1.getCurrentTextColor() == ContextCompat.getColor(getApplicationContext(),
                        R.color.colorAccent)
                        || tgbtn2.getCurrentTextColor() == ContextCompat.getColor(getApplicationContext(),
                                R.color.colorAccent)
                        || tgbtn3.getCurrentTextColor() == ContextCompat.getColor(getApplicationContext(),
                                R.color.colorAccent)
                        || tgbtn.getCurrentTextColor() == ContextCompat.getColor(getApplicationContext(),
                                R.color.colorAccent)) {
                    LinkedHashSet<String> data = new LinkedHashSet<String>();
                    data.add(tgbtn.getText().toString().trim() + "=" + tgbtn.getCurrentTextColor());
                    data.add(tgbtn1.getText().toString().trim() + "=" + tgbtn1.getCurrentTextColor());
                    data.add(tgbtn2.getText().toString().trim() + "=" + tgbtn2.getCurrentTextColor());
                    data.add(tgbtn3.getText().toString().trim() + "=" + tgbtn3.getCurrentTextColor());
                    data.add(ringsDesc.getHint().toString().trim() + "="
                            + ringsDesc.getText().toString().trim().replace(",", ";"));
                    data.add(scrotalDesc.getHint().toString().trim() + "="
                            + scrotalDesc.getText().toString().trim().replace(",", ";"));

                    //save to shared pref
                    SharedPrefUtil.saveGroup(getApplicationContext(), Constant.PREFS_MOTILITY_INFO, bullKey,
                            data);

                    Intent goPrev = new Intent(getApplicationContext(), BullExam.class);
                    goPrev.putExtra("bullKey", bullKey);
                    startActivity(goPrev);

                    //display fields
                    /*Util.setFields(SharedPrefUtil.getValue(getApplicationContext(), Constant.PREFS_MOTILITY_INFO,
                        bullKey), fields);
                    //display toggle buttons
                    Util.setToggleButtons(SharedPrefUtil.getValue(getApplicationContext(), Constant.PREFS_MOTILITY_INFO,
                        bullKey), tgBtns);*/

                    Toast.makeText(getApplicationContext(), "Saved!", Toast.LENGTH_SHORT).show();
                }
            }
        });
    } catch (Exception e) {
        Toast.makeText(getApplicationContext(), "App not responding due to invalid data entered",
                Toast.LENGTH_SHORT).show();
    }

}

From source file:net.famzangl.minecraft.minebot.ai.command.CommandRegistry.java

public String[] fillTabComplete(MinebotNetHandler minebotNetHandler, String[] serverResponse,
        String lastSendTabComplete) {
    String command = getCommandId(lastSendTabComplete);
    LinkedHashSet<String> res = new LinkedHashSet<String>();
    for (String c : commandTable.keySet()) {
        if (c.startsWith(command)) {
            res.add("/" + c);
        }/*w  w  w. jav  a  2 s  . c  o m*/
    }
    if (res.isEmpty())
        return serverResponse;
    res.addAll(Arrays.asList(serverResponse));

    return res.toArray(new String[0]);
}

From source file:com.qwazr.database.TableManager.java

public Set<String> getNameSet() {
    rwl.r.lock();/*from   www . j  a  va 2s.c om*/
    try {
        LinkedHashSet<String> names = new LinkedHashSet<String>();
        for (File file : directory.listFiles((FileFilter) FileFilterUtils.directoryFileFilter()))
            if (!file.isHidden())
                names.add(file.getName());
        return names;
    } finally {
        rwl.r.unlock();
    }
}