Search in sources :

Example 56 with EnumMap

use of java.util.EnumMap in project gradle by gradle.

the class JvmLocalLibraryMetaDataAdapter method createResolvedMetaData.

private DefaultLibraryLocalComponentMetadata createResolvedMetaData(BinarySpecInternal selectedBinary, String projectPath, EnumMap<UsageKind, Iterable<DependencySpec>> dependenciesPerUsage, EnumMap<UsageKind, List<PublishArtifact>> artifacts) {
    final DefaultLibraryLocalComponentMetadata metadata = newResolvedLibraryMetadata(selectedBinary.getId(), toStringMap(dependenciesPerUsage), projectPath);
    for (Map.Entry<UsageKind, List<PublishArtifact>> entry : artifacts.entrySet()) {
        UsageKind usage = entry.getKey();
        final List<PublishArtifact> publishArtifacts = entry.getValue();
        metadata.addArtifacts(usage.getConfigurationName(), publishArtifacts);
        metadata.addVariant(usage.getConfigurationName(), new OutgoingVariant() {

            @Override
            public DisplayName asDescribable() {
                return Describables.of(metadata.getId());
            }

            @Override
            public AttributeContainerInternal getAttributes() {
                return ImmutableAttributes.EMPTY;
            }

            @Override
            public Set<? extends PublishArtifact> getArtifacts() {
                return new LinkedHashSet<PublishArtifact>(publishArtifacts);
            }

            @Override
            public Set<? extends OutgoingVariant> getChildren() {
                return ImmutableSet.of();
            }
        });
    }
    return metadata;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) DefaultLibraryLocalComponentMetadata(org.gradle.language.base.internal.model.DefaultLibraryLocalComponentMetadata) AttributeContainerInternal(org.gradle.api.internal.attributes.AttributeContainerInternal) OutgoingVariant(org.gradle.api.internal.artifacts.configurations.OutgoingVariant) DisplayName(org.gradle.internal.DisplayName) LinkedList(java.util.LinkedList) List(java.util.List) PublishArtifact(org.gradle.api.artifacts.PublishArtifact) DefaultPublishArtifact(org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact) HashMap(java.util.HashMap) Map(java.util.Map) EnumMap(java.util.EnumMap)

Example 57 with EnumMap

use of java.util.EnumMap in project drools by kiegroup.

the class Misc2Test method testNumberCoercionOnNonGenericMap.

@Test
public void testNumberCoercionOnNonGenericMap() {
    // JBRULES-3708
    String str = "package com.ilesteban.jit;\n" + "\n" + "import java.util.Map;\n" + "import java.util.EnumMap;\n" + "import " + Misc2Test.Parameter.class.getCanonicalName() + "\n" + "import " + Misc2Test.DataSample.class.getCanonicalName() + "\n" + "import " + DataSample.class.getCanonicalName() + "\n" + "\n" + "declare TestObject\n" + "    data    :   java.util.Map\n" + "end\n" + "\n" + "rule \"Rule 1\"\n" + "when\n" + "    $d: DataSample()\n" + "then\n" + "    //create a new object copying the Map<Parameter, Double> to a Map<Object, Object>\n" + "    insert( new TestObject($d.getValues()));\n" + "end\n" + "\n" + "rule \"Rule 2\"\n" + "when\n" + "    TestObject(data[Parameter.PARAM_A] > 3)\n" + "then\n" + "end\n";
    KieBase kbase = loadKnowledgeBaseFromString(str);
    KieSession ksession = kbase.newKieSession();
    Map<Parameter, Double> values = new EnumMap<Parameter, Double>(Parameter.class);
    values.put(Parameter.PARAM_A, 4.0);
    DataSample data = new DataSample();
    data.setValues(values);
    ksession.insert(data);
    assertEquals(2, ksession.fireAllRules());
}
Also used : KieBase(org.kie.api.KieBase) KieSession(org.kie.api.runtime.KieSession) StatelessKieSession(org.kie.api.runtime.StatelessKieSession) EnumMap(java.util.EnumMap) Test(org.junit.Test)

Example 58 with EnumMap

use of java.util.EnumMap in project megameklab by MegaMek.

the class DropshipStructureTab method quartersChanged.

@Override
public void quartersChanged(int officer, int standard, int secondclass, int steerage) {
    EnumMap<TestAero.Quarters, Integer> sizes = new EnumMap<>(TestAero.Quarters.class);
    for (Bay bay : getSmallCraft().getTransportBays()) {
        Quarters q = TestAero.Quarters.getQuartersForBay(bay);
        if (null != q) {
            sizes.merge(q, (int) bay.getCapacity(), Integer::sum);
        }
    }
    if (sizes.getOrDefault(TestAero.Quarters.FIRST_CLASS, 0) != officer) {
        setQuarters(TestAero.Quarters.FIRST_CLASS, officer);
    }
    if (sizes.getOrDefault(TestAero.Quarters.STANDARD, 0) != standard) {
        setQuarters(TestAero.Quarters.STANDARD, standard);
    }
    if (sizes.getOrDefault(TestAero.Quarters.SECOND_CLASS, 0) != secondclass) {
        setQuarters(TestAero.Quarters.SECOND_CLASS, secondclass);
    }
    if (sizes.getOrDefault(TestAero.Quarters.STEERAGE, 0) != steerage) {
        setQuarters(TestAero.Quarters.STEERAGE, steerage);
    }
    panCrew.setFromEntity(getSmallCraft());
    refreshSummary();
    refresh.refreshStatus();
    refresh.refreshPreview();
}
Also used : TestAero(megamek.common.verifier.TestAero) Bay(megamek.common.Bay) Quarters(megamek.common.verifier.TestAero.Quarters) EnumMap(java.util.EnumMap)

Example 59 with EnumMap

use of java.util.EnumMap in project react-native-camera by react-native-community.

the class RCTCameraViewFinder method initBarcodeReader.

/**
 * Initialize the barcode decoder.
 */
private void initBarcodeReader(List<String> barCodeTypes) {
    EnumMap<DecodeHintType, Object> hints = new EnumMap<>(DecodeHintType.class);
    EnumSet<BarcodeFormat> decodeFormats = EnumSet.noneOf(BarcodeFormat.class);
    if (barCodeTypes != null) {
        for (String code : barCodeTypes) {
            BarcodeFormat format = parseBarCodeString(code);
            if (format != null) {
                decodeFormats.add(format);
            }
        }
    }
    hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
    _multiFormatReader.setHints(hints);
}
Also used : DecodeHintType(com.google.zxing.DecodeHintType) BarcodeFormat(com.google.zxing.BarcodeFormat) EnumMap(java.util.EnumMap)

Example 60 with EnumMap

use of java.util.EnumMap in project BibleMultiConverter by schierlm.

the class TheWord method doExport.

@Override
public void doExport(Bible bible, String... exportArgs) throws Exception {
    boolean hasOT = false, hasNT = false;
    Map<BookID, Book> foundBooks = new EnumMap<>(BookID.class);
    for (Book bk : bible.getBooks()) {
        if (!COVERED_BOOKS.contains(bk.getId()))
            continue;
        foundBooks.put(bk.getId(), bk);
        if (bk.getId().isNT())
            hasNT = true;
        else
            hasOT = true;
    }
    if (!hasOT && !hasNT) {
        System.out.println("WARNING: Unable to export, no supported book is covered!");
        return;
    }
    File file = new File(exportArgs[0] + "." + (hasOT && hasNT ? "ont" : hasOT ? "ot" : "nt"));
    try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"))) {
        bw.write("\uFEFF");
        TheWordVisitor twvo = hasOT ? new TheWordVisitor(bw, false) : null;
        TheWordVisitor twvn = hasNT ? new TheWordVisitor(bw, true) : null;
        for (BookID bid : BOOK_ORDER) {
            if ((bid.isNT() && !hasNT) || (!bid.isNT() && !hasOT))
                continue;
            TheWordVisitor twv = bid.isNT() ? twvn : twvo;
            Book bk = foundBooks.get(bid);
            int[] verseCount = StandardVersification.KJV.getVerseCount(bid);
            for (int cnumber = 1; cnumber <= verseCount.length; cnumber++) {
                Chapter ch = bk != null && cnumber <= bk.getChapters().size() ? bk.getChapters().get(cnumber - 1) : null;
                int maxVerse = verseCount[cnumber - 1];
                int nextVerse = 1;
                if (ch != null) {
                    BitSet allowedNumbers = new BitSet(maxVerse + 1);
                    allowedNumbers.set(1, maxVerse + 1);
                    for (VirtualVerse vv : ch.createVirtualVerses(allowedNumbers)) {
                        while (vv.getNumber() > nextVerse) {
                            bw.write("- - -\r\n");
                            nextVerse++;
                        }
                        if (vv.getNumber() != nextVerse)
                            throw new RuntimeException("Verse to write :" + vv.getNumber() + ", but next verse slot in file: " + nextVerse);
                        for (Headline h : vv.getHeadlines()) {
                            bw.write("<TS" + (h.getDepth() < 3 ? h.getDepth() : 3) + ">");
                            h.accept(twv);
                            twv.reset();
                            bw.write("<Ts>");
                        }
                        for (Verse v : vv.getVerses()) {
                            if (!v.getNumber().equals("" + vv.getNumber())) {
                                bw.write(" (" + v.getNumber() + ")");
                            }
                            v.accept(twv);
                            twv.reset();
                        }
                        bw.write("\r\n");
                        nextVerse++;
                    }
                }
                if (nextVerse > maxVerse + 1)
                    throw new RuntimeException(nextVerse + "/" + (maxVerse + 1));
                for (int i = 0; i <= maxVerse - nextVerse; i++) {
                    bw.write("- - -\r\n");
                }
            }
        }
        bw.write("\r\nabout=Converted by BibleMultiConverter\r\n");
    }
}
Also used : VirtualVerse(biblemulticonverter.data.VirtualVerse) Chapter(biblemulticonverter.data.Chapter) BitSet(java.util.BitSet) BufferedWriter(java.io.BufferedWriter) BookID(biblemulticonverter.data.BookID) Book(biblemulticonverter.data.Book) FileOutputStream(java.io.FileOutputStream) Headline(biblemulticonverter.data.FormattedText.Headline) OutputStreamWriter(java.io.OutputStreamWriter) EnumMap(java.util.EnumMap) File(java.io.File) VirtualVerse(biblemulticonverter.data.VirtualVerse) Verse(biblemulticonverter.data.Verse)

Aggregations

EnumMap (java.util.EnumMap)389 Map (java.util.Map)73 ArrayList (java.util.ArrayList)70 List (java.util.List)61 HashMap (java.util.HashMap)60 Test (org.junit.Test)46 IOException (java.io.IOException)38 Collection (java.util.Collection)35 DecodeHintType (com.google.zxing.DecodeHintType)30 HashSet (java.util.HashSet)26 Set (java.util.Set)26 EncodeHintType (com.google.zxing.EncodeHintType)17 File (java.io.File)17 BitMatrix (com.google.zxing.common.BitMatrix)15 BookID (biblemulticonverter.data.BookID)14 Iterator (java.util.Iterator)14 URL (java.net.URL)12 TreeMap (java.util.TreeMap)12 Header (com.jsql.model.bean.util.Header)10 Request (com.jsql.model.bean.util.Request)10