@Encoding.Naming(standard = Encoding.StandardNaming.PUT) @Encoding.Init void put( final K key, final V value) { this.map = this.map.put(key, value); }
/** * @return A module resolver */ public static SMFFilterCommandModuleResolverType create() { SortedMap<String, SMFFilterCommandModuleType> modules = TreeMap.empty(); final ServiceLoader<SMFFilterCommandModuleProviderType> providers = ServiceLoader.load(SMFFilterCommandModuleProviderType.class); final Iterator<SMFFilterCommandModuleProviderType> iter = providers.iterator(); while (iter.hasNext()) { final SMFFilterCommandModuleProviderType provider = iter.next(); final SortedMap<String, SMFFilterCommandModuleType> available = provider.available(); for (final String name : available.keySet()) { final SMFFilterCommandModuleType module = available.get(name).get(); if (modules.containsKey(name)) { LOG.warn("multiple modules with the same name: {}", name); } if (LOG.isDebugEnabled()) { LOG.debug("registered module {} via provider {}", name, provider); } modules = modules.put(name, module); } } return new SMFFilterCommandModuleResolver(modules); }
protected SMFFilterCommandModuleProviderAbstract( final SMFFilterCommandModuleType... in_modules) { NullCheck.notNull(in_modules, "Modules"); SortedMap<String, SMFFilterCommandModuleType> m = TreeMap.empty(); for (int index = 0; index < in_modules.length; ++index) { final SMFFilterCommandModuleType module = in_modules[index]; if (m.containsKey(module.name())) { throw new IllegalArgumentException( "Duplicate published module: " + module.name()); } m = m.put(module.name(), module); } this.available = m; }
final SMFAttribute attribute = p._2; if (required_by_name.containsKey(name)) { final SMFSchemaAttribute attr_schema = required_by_name.get(name).get(); error_x = checkComponentType(error_x, name, attr_schema, attribute); error_x = checkComponentSize(error_x, name, attr_schema, attribute); error_x = checkComponentCount(error_x, name, attr_schema, attribute); } else if (optional_by_name.containsKey(name)) { final SMFSchemaAttribute attr_schema = optional_by_name.get(name).get(); error_x = checkComponentType(error_x, name, attr_schema, attribute); error_x = checkComponentSize(error_x, name, attr_schema, attribute); required_by_name.keySet().diff(by_name.keySet()); error_x = error_x.appendAll( missing.toList().map(SMFSchemaValidator::errorMissingAttribute));
/** * Check preconditions for the type. */ @Value.Check default void checkPreconditions() { HashMap<Integer, SMFByteBufferPackedAttribute> m = HashMap.empty(); final SortedMap<Integer, SMFByteBufferPackedAttribute> by_offset = this.packedAttributesByOffset(); for (final Integer offset : by_offset.keySet()) { Preconditions.checkPreconditionI( offset.intValue(), !m.containsKey(offset), i -> "All attribute offsets must be unique"); m = m.put(offset, by_offset.get(offset).get()); } } }
@Override public Optional<SMFParserEventsDataAttributeValuesType> onDataAttributeStart( final SMFAttribute attribute) { TreeMap<Integer, SMFByteBufferAttributePacker> packers = TreeMap.empty(); final SMFAttributeName name = attribute.name(); for (final Tuple2<Integer, SMFByteBufferPackingConfiguration> p : this.config) { final Integer id = p._1; final SMFByteBufferPackingConfiguration bc = p._2; final SortedMap<SMFAttributeName, SMFByteBufferPackedAttribute> by_name = bc.packedAttributesByName(); if (by_name.containsKey(name)) { final ByteBuffer b = this.attr_buffers.get(id).get(); final SMFByteBufferPackedAttribute pa = by_name.get(name).get(); final SMFByteBufferAttributePacker packer = new SMFByteBufferAttributePacker( this, b, bc, pa, this.header.vertexCount()); packers = packers.put(id, packer); } } this.attr_packers = packers; return Optional.of(this); }
@Override public void onFinish() { if (this.errors.isEmpty()) { Invariants.checkInvariantI( this.attr_buffers.size(), this.attr_buffers.size() == this.config.size(), x -> "Must have correct number of buffers"); final SMFByteBufferPackedMesh.Builder mb = SMFByteBufferPackedMesh.builder(); for (final Tuple2<Integer, ByteBuffer> p : this.attr_buffers) { mb.addAttributeSets(SMFByteBufferPackedAttributeSet.of( p._1.intValue(), this.config.get(p._1).get(), p._2)); } if (this.tri_buffer != null) { final SMFTriangles triangles = this.header.triangles(); mb.setTriangles(SMFByteBufferPackedTriangles.of( this.tri_buffer, triangles.triangleCount(), Math.toIntExact(triangles.triangleIndexSizeBits()))); } mb.setHeader(this.header); this.mesh = mb.build(); } }
/** * Check preconditions for the type. */ @Value.Check default void checkPreconditions() { final SortedSet<SMFAttributeName> both = this.requiredAttributes().keySet().intersect( this.optionalAttributes().keySet()); Preconditions.checkPrecondition( both, both.isEmpty(), s -> "The intersection of the required and optional attributes must be empty"); } }
this.header.attributesByName().get(name); if (attribute_opt.isDefined()) { final SMFAttribute attribute = attribute_opt.get();
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; }
/** * @return The packed attributes by name */ @Value.Derived default SortedMap<SMFAttributeName, SMFByteBufferPackedAttribute> packedAttributesByName() { return this.packedAttributesByOffset() .map((offset, attr) -> Tuple.of(attr.attribute().name(), attr)); }
/** * @return The attributes by name */ @Value.Derived default SortedMap<SMFAttributeName, SMFAttribute> attributesByName() { SortedMap<SMFAttributeName, SMFAttribute> m = TreeMap.empty(); final List<SMFAttribute> ordered = this.attributesInOrder(); for (int index = 0; index < ordered.size(); ++index) { final SMFAttribute attr = ordered.get(index); if (m.containsKey(attr.name())) { final StringBuilder sb = new StringBuilder(128); sb.append("Duplicate attribute name."); sb.append(System.lineSeparator()); sb.append(" Attribute: "); sb.append(attr.name().value()); sb.append(System.lineSeparator()); throw new IllegalArgumentException(sb.toString()); } m = m.put(attr.name(), attr); } return m; }
/** * Check preconditions for the type. */ @Value.Check default void checkPreconditions() { final SortedSet<SMFAttributeName> both = this.requiredAttributes().keySet().intersect( this.optionalAttributes().keySet()); Preconditions.checkPrecondition( both, both.isEmpty(), s -> "The intersection of the required and optional attributes must be empty"); } }
try { final SMFAttribute original = by_name.get(this.attribute).get(); final SMFAttribute resampled = original.withComponentSizeBits(this.size);
final int named_size = this.attributesByName().size(); if (order_size != named_size) { final StringBuilder sb = new StringBuilder(128);
this.attr_buffers = this.config.map((id, buffer_config) -> { final long size_attr = Math.multiplyExact(
/** * @return The attributes by name */ @Value.Derived default SortedMap<SMFAttributeName, SMFAttribute> attributesByName() { SortedMap<SMFAttributeName, SMFAttribute> m = TreeMap.empty(); final List<SMFAttribute> ordered = this.attributesInOrder(); for (int index = 0; index < ordered.size(); ++index) { final SMFAttribute attr = ordered.get(index); if (m.containsKey(attr.name())) { final StringBuilder sb = new StringBuilder(128); sb.append("Duplicate attribute name."); sb.append(System.lineSeparator()); sb.append(" Attribute: "); sb.append(attr.name().value()); sb.append(System.lineSeparator()); throw new IllegalArgumentException(sb.toString()); } m = m.put(attr.name(), attr); } return m; }
@Encoding.Naming(value = "putEntry*", depluralize = true) @Encoding.Init void putEntry( final Tuple2<K, V> entry) { this.map = this.map.put(entry); }
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())); } }
final int named_size = this.attributesByName().size(); if (order_size != named_size) { final StringBuilder sb = new StringBuilder(128);