@Encoding.Naming(value = "setEntries*") @Encoding.Init void setEntries( final Iterable<Tuple2<K, V>> entries) { this.map = HashMap.ofEntries(entries); }
@Encoding.Naming(value = "setEntries*") @Encoding.Init void setEntries( final Iterable<Tuple2<K, V>> entries) { this.map = HashMap.ofEntries(entries); }
public Builder setEntriesMappings(Iterable<Tuple2<SMFAttributeName, SMFArrayAttributeMapping>> entries) { this.mappings_map = HashMap.ofEntries(entries); return this; }
public Builder setEntriesArrays(Iterable<Tuple2<SMFAttributeName, SMFAttributeArrayType>> entries) { this.arrays_map = HashMap.ofEntries(entries); return this; }
@Encoding.Naming(value = "setMap*") @Encoding.Init void setMap( final Map<K, V> in_map) { this.map = HashMap.ofEntries(in_map.map(x -> x)); }
@Test public void testDuplicate() { final SMFArrayAttributeMapping m0 = SMFArrayAttributeMapping.of( SMFAttributeName.of("a"), 0, Optional.of(JCGLScalarType.TYPE_FLOAT), 4); final SMFArrayAttributeMapping m1 = SMFArrayAttributeMapping.of( SMFAttributeName.of("b"), 0, Optional.of(JCGLScalarType.TYPE_FLOAT), 4); this.expected.expect(IllegalArgumentException.class); SMFArrayObjectConfiguration.builder() .setMappings(HashMap.ofEntries(List.of( Tuple.of(SMFAttributeName.of("a"), m0), Tuple.of(SMFAttributeName.of("b"), m1)))) .build(); }
@Test public void testMappings() { final SMFArrayAttributeMapping m0 = SMFArrayAttributeMapping.of( SMFAttributeName.of("a"), 0, Optional.of(JCGLScalarType.TYPE_FLOAT), 4); final SMFArrayAttributeMapping m1 = SMFArrayAttributeMapping.of( SMFAttributeName.of("b"), 1, Optional.of(JCGLScalarType.TYPE_FLOAT), 4); final SMFArrayObjectConfiguration m = SMFArrayObjectConfiguration.builder() .setMappings(HashMap.ofEntries(List.of( Tuple.of(SMFAttributeName.of("a"), m0), Tuple.of(SMFAttributeName.of("b"), m1)))) .setIndexBufferUsage(JCGLUsageHint.USAGE_DYNAMIC_COPY) .setArrayBufferUsage(JCGLUsageHint.USAGE_STREAM_READ) .build(); Assert.assertEquals(JCGLUsageHint.USAGE_DYNAMIC_COPY, m.indexBufferUsage()); Assert.assertEquals(JCGLUsageHint.USAGE_STREAM_READ, m.arrayBufferUsage()); Assert.assertEquals(m0, m.mappings().get(SMFAttributeName.of("a")).get()); Assert.assertEquals(m1, m.mappings().get(SMFAttributeName.of("b")).get()); Assert.assertEquals(2L, (long) m.mappings().size()); } }