private boolean equalTo(SMFMetadata another) { return schema.equals(another.schema) && Arrays.equals(data, another.data); }
/** * Computes a hash code from attributes: {@code schema}, {@code data}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + schema.hashCode(); h += (h << 5) + Arrays.hashCode(data); return h; }
/** * Copy the current immutable object by setting a value for the {@link SMFSchemaIdentifierType#schemaMajorVersion() schemaMajorVersion} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for schemaMajorVersion * @return A modified copy of the {@code this} object */ public final SMFSchemaIdentifier withSchemaMajorVersion(int value) { if (this.schemaMajorVersion == value) return this; return new SMFSchemaIdentifier(this.vendorID, this.schemaID, value, this.schemaMinorVersion); }
schema_matches = Objects.equals(meta.schema().name(), s); if (this.version.isPresent()) { final Pair<Integer, Integer> v = this.version.get(); version_matches = v.getLeft().intValue() == meta.schema().versionMajor() && v.getRight().intValue() == meta.schema().versionMinor(); } else { version_matches = true; "removing matched {} -> {}", this.matchString(), meta.schema().toHumanString()); } else { LOG.debug( "preserving unmatched {} -> {}", this.matchString(), meta.schema().toHumanString());
writer.append(id.name().value()); writer.append(" "); writer.append(Integer.toUnsignedString(id.versionMajor())); writer.append(" "); writer.append(Integer.toUnsignedString(id.versionMinor())); writer.newLine();
SMFTV1HeaderParser( final SMFTAbstractParser in_parent, final SMFParserEventsType in_events, final SMFTLineReaderType in_reader, final SMFFormatVersion in_version) { super( in_events, in_reader, NullCheck.notNull(in_parent, "Parent").state); this.attribute_lines = HashMap.empty(); this.attributes_list = List.empty(); this.ok_triangles = false; this.ok_vertices = false; this.schema_id = SMFSchemaIdentifier.of(0, 0, 0, 0); }
/** * Creates an immutable copy of a {@link SMFSchemaIdentifierType} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable SMFSchemaIdentifier instance */ public static SMFSchemaIdentifier copyOf(SMFSchemaIdentifierType instance) { if (instance instanceof SMFSchemaIdentifier) { return (SMFSchemaIdentifier) instance; } return SMFSchemaIdentifier.builder() .from(instance) .build(); }
if (schema_id.vendorID() != 0) { this.writer.append("schema "); this.writer.append(schema_id.toHumanString()); this.writer.newLine();
private static SMFSchemaValidationError errorWrongSchemaID( final SMFSchemaIdentifier schema_id, final SMFSchemaIdentifier file_id) { final StringBuilder sb = new StringBuilder(128); sb.append( "The mesh schema identifier does not match the identifier in the schema."); sb.append(System.lineSeparator()); sb.append(" Expected: "); sb.append(schema_id.toHumanString()); sb.append(System.lineSeparator()); sb.append(" Received: "); sb.append(file_id.toHumanString()); sb.append(System.lineSeparator()); return SMFSchemaValidationError.of(sb.toString(), Optional.empty()); }
/** * This instance is equal to all instances of {@code SMFSchemaIdentifier} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof SMFSchemaIdentifier && equalTo((SMFSchemaIdentifier) another); }
private Validation<List<SMFParseError>, SMFSchemaIdentifier> parseStatementIdentifier( final List<String> text) { if (text.length() == 4) { try { final SMFSchemaName schema = SMFSchemaName.of(text.get(1)); final int major = Integer.parseUnsignedInt(text.get(2)); final int minor = Integer.parseUnsignedInt(text.get(3)); return valid(SMFSchemaIdentifier.of(schema, major, minor)); } catch (final NumberFormatException e) { return invalid(List.of(SMFParseError.of( this.reader.position(), e.getMessage(), Optional.of(e)))); } } final StringBuilder sb = new StringBuilder(128); sb.append("Incorrect number of arguments."); sb.append(System.lineSeparator()); sb.append( " Expected: schema <schema> <version-major> <version-minor>"); sb.append(System.lineSeparator()); sb.append(" Received: "); sb.append(text.toJavaStream().collect(Collectors.joining(" "))); sb.append(System.lineSeparator()); return invalid(List.of(SMFParseError.of( this.reader.position(), sb.toString(), Optional.empty()))); }
/** * Creates an immutable copy of a {@link SMFSchemaIdentifierType} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable SMFSchemaIdentifier instance */ public static SMFSchemaIdentifier copyOf(SMFSchemaIdentifierType instance) { if (instance instanceof SMFSchemaIdentifier) { return (SMFSchemaIdentifier) instance; } return SMFSchemaIdentifier.builder() .from(instance) .build(); }
sb.append(System.lineSeparator()); sb.append("Expected: "); sb.append(this.config.toHumanString()); sb.append(System.lineSeparator()); sb.append("Received: "); if (received_opt.isPresent()) { final SMFSchemaIdentifier received = received_opt.get(); sb.append(received.toHumanString()); } else { sb.append("No schema ID");
/** * This instance is equal to all instances of {@code SMFSchemaIdentifier} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof SMFSchemaIdentifier && equalTo((SMFSchemaIdentifier) another); }
private boolean equalTo(SMFSchema another) { return schemaIdentifier.equals(another.schemaIdentifier) && this.requiredAttributes().equals(another.requiredAttributes()) && this.optionalAttributes().equals(another.optionalAttributes()) && Objects.equals(requiredCoordinateSystem, another.requiredCoordinateSystem) && allowExtraAttributes == another.allowExtraAttributes; }
/** * Computes a hash code from attributes: {@code schemaIdentifier}, {@code requiredAttributes}, {@code optionalAttributes}, {@code requiredCoordinateSystem}, {@code allowExtraAttributes}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + schemaIdentifier.hashCode(); h += (h << 5) + (requiredAttributes().hashCode()); h += (h << 5) + (optionalAttributes().hashCode()); h += (h << 5) + Objects.hashCode(requiredCoordinateSystem); h += (h << 5) + Boolean.hashCode(allowExtraAttributes); return h; }
SMFSchemaIdentifier.of( SMFSchemaName.of("com.io7m.smf.application"), 1,
/** * Copy the current immutable object by setting a value for the {@link SMFSchemaIdentifierType#versionMinor() versionMinor} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for versionMinor * @return A modified copy of the {@code this} object */ public final SMFSchemaIdentifier withVersionMinor(int value) { if (this.versionMinor == value) return this; return new SMFSchemaIdentifier(this, this.name, this.versionMajor, value); }
final int minor = Integer.parseUnsignedInt(text.get(2)); return valid(create( SMFSchemaIdentifier.builder() .setName(schema) .setVersionMajor(major)
private boolean equalTo(SMFHeader another) { return triangles.equals(another.triangles) && vertexCount == another.vertexCount && schemaIdentifier.equals(another.schemaIdentifier) && coordinateSystem.equals(another.coordinateSystem) && this.attributesInOrder().equals(another.attributesInOrder()) && attributesByName.equals(another.attributesByName) && metaCount == another.metaCount; }