@Encoding.Naming(value = "setMap*") @Encoding.Init void setMap( final Map<K, V> in_map) { this.map = TreeMap.ofEntries(in_map.map(x -> x)); }
@Encoding.Naming(value = "putEntry*", depluralize = true) @Encoding.Init void putEntry( final Tuple2<K, V> entry) { this.map = this.map.put(entry); }
private void parseHeaderCheckUniqueAttributeNames() { final Collection<SMFAttributeName> names = new HashSet<>(this.attributes_list.size()); for (final SMFAttribute attribute : this.attributes_list) { final SMFAttributeName name = attribute.name(); if (names.contains(name)) { Invariants.checkInvariant( name, this.attribute_lines.containsKey(name), a_name -> "Attribute lines must contain " + a_name); this.failWithLineNumber( this.attribute_lines.get(name).get().intValue(), "Duplicate attribute name: " + name.value(), Optional.empty()); } names.add(name); } }
in_header.attributesByName(); for (final SMFAttributeName name : required_attributes.keySet()) { final SMFArrayAttributeMapping required_attribute = required_attributes.get(name).get(); if (received_attributes.containsKey(name)) { final SMFAttribute received_attribute = received_attributes.get(name).get();
final Option<SMFAttribute> attribute_opt = named.get(attribute.name()); if (attribute_opt.isDefined()) { if (!Objects.equals(attribute, attribute_opt.get())) {
final javaslang.collection.List<Component> componentList) { final javaslang.collection.Map<String, Component> newComponentMap = componentMap.removeAll(components.map(DMPObject::getUuid)); final javaslang.collection.List<Component> newComponentList = componentList.prependAll(components); if (newComponentMap.isEmpty()) { .map(inputComponent -> newComponentMap.get(inputComponent.getUuid())) .filter(optionInputComponent -> !optionInputComponent.isEmpty()) .map(Option::get)
@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()); } }
final SMFAttributeArrayType array = arrays.get(this.source).get(); final Map<SMFAttributeName, SMFAttributeArrayType> renamed_arrays = arrays.replace( Tuple.of(this.source, array), Tuple.of(this.target, array)); orig_header.attributesByName(); final SMFAttribute orig_attrib = orig_by_name.get(this.source).get(); final SMFAttribute new_attrib = orig_attrib.withName(this.target);
final SMFAttribute attribute = attribute_opt.get(); if (this.attributes_attempted.containsKey(name)) { super.fail( "An attempt has already been made to supply data for attribute " + name.value(), this.attributes_attempted.put(name, Boolean.TRUE); this.attributes_ok = this.attributes_ok.put(name, Boolean.TRUE); } finally { super.events.onDataAttributeFinish(attribute);
final SMFAttributeName name) if (!attributes.containsKey(name)) { final StringBuilder sb = new StringBuilder(128); sb.append("Mesh does not contain the given attribute."); attributes.iterator();
private boolean isBodyDone() { final boolean ok_triangles = this.header.triangles().triangleCount() == this.parsed_triangles; final boolean attribute_size_ok = this.attributes_ok.size() == this.header.attributesByName().size(); final boolean attribute_all_done = this.attributes_ok.foldRight( Boolean.TRUE, (p, x) -> Boolean.valueOf(p._2.booleanValue() && x.booleanValue())).booleanValue(); this.log().trace( "triangles done: {}", Boolean.valueOf(ok_triangles)); this.log().trace( "attributes size: {}", Boolean.valueOf(attribute_size_ok)); this.log().trace( "attributes done: {}", Boolean.valueOf(attribute_all_done)); return ok_triangles && attribute_size_ok && attribute_all_done; }
@Nonnull @Override public Object convert(Object source) { if (source instanceof javaslang.collection.Seq) { return ((javaslang.collection.Seq<?>) source).toJavaList(); } if (source instanceof javaslang.collection.Map) { return ((javaslang.collection.Map<?, ?>) source).toJavaMap(); } if (source instanceof javaslang.collection.Set) { return ((javaslang.collection.Set<?>) source).toJavaSet(); } throw new IllegalArgumentException("Unsupported Javaslang collection " + source.getClass()); } }
private void failMissedAttributes() { final Set<SMFAttributeName> names = this.header.attributesByName().keySet().diff( this.attributes_attempted.keySet()); if (!names.isEmpty()) { names.forEach( name -> this.fail( "No data specified for attribute: " + name.value(), Optional.empty())); } }
m.header().attributesByName(); if (by_name.containsKey(this.config.name())) { final SMFAttribute attr = by_name.get(this.config.name()).get();
final Option<SMFAttribute> attribute_opt = named.get(attribute.name()); if (attribute_opt.isDefined()) { if (!Objects.equals(attribute, attribute_opt.get())) {
@Override public Option<Errors> extract(Json.JObject node) { Function<Json.JArray, List<Error>> toErrors = arr -> arr. getListAsObjects(). map(factory::createError). toJavaList(); Option<Json.JObject> errors = node.getAsObject("errors"); return errors.map( j -> j.value.map((k, v) -> Tuple.of(k, toErrors.apply(v.asJsonArrayOrEmpty()))).toJavaMap() ).map(Errors::new); }
final SMFAttributeName name) if (attributes.containsKey(name)) { final StringBuilder sb = new StringBuilder(128); sb.append("Mesh already contains an attribute with the given name."); attributes.iterator();