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;
}
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());
}
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();
}
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);
}
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");
}
}
Aggregations